danger-xcodebuild 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e64658c29cf07253dd9cc5b037582d59a75155ab
4
- data.tar.gz: 81da85368c2827f9a75b2bd254c89523f52ac57f
3
+ metadata.gz: cc2d72bf13b78e81c22dbdfda0d47b0c77efda80
4
+ data.tar.gz: d70faff0e519ce80fe7d632a8fe9f3ce708990c7
5
5
  SHA512:
6
- metadata.gz: ace20c3da72cff0ef7a271993745ddf019e9d216b89367e10fe6502e9bbf9543a976ad3b9ab27ef108ae45d2d6eccc0f09a7836263c72f5173370884f7e08d88
7
- data.tar.gz: 2111c49a248ed3ad9919259c71ef4e2344b925a66ba3c52960a209dedd4e4f31ee11d7dae98d8ce3f3a052dd829e015b8fab470bf7146294696ce37d63e41748
6
+ metadata.gz: 2617f5f06c452356db13e67fca6ce2c8b5432d8dde250deda83bd3423cfa669397c419c2fbf4e70893ea4c6f53459760f80e1d07d79ad6d57344e90276e98b46
7
+ data.tar.gz: abdfafcde92bb8bb636d26381a3fea2efd61ebfa8270fa4fe41b797081c3b33c595c602d9426c289e45a34f731dfab86146bd44c716fa82e8c34376460de87cd
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-xcodebuild (0.0.4)
4
+ danger-xcodebuild (0.0.5)
5
5
  danger (~> 3.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  addressable (2.4.0)
11
- claide (1.0.0)
12
- claide-plugins (0.9.1)
11
+ claide (1.0.1)
12
+ claide-plugins (0.9.2)
13
13
  cork
14
14
  nap
15
15
  open4 (~> 1.3)
data/README.md CHANGED
@@ -12,10 +12,14 @@ Exposes warnings, errors and test results. It requires a JSON generated using [x
12
12
 
13
13
  xcodebuild.json_file = "./fastlane/reports/xcpretty-json-formatter-results.json"
14
14
 
15
- xcodebuild.parse_warnings
16
- xcodebuild.parse_errors
17
- xcodebuild.parse_tests
18
- xcodebuild.perfect_build
15
+ xcodebuild.parse_warnings # returns number of warnings
16
+ xcodebuild.parse_errors # returns number of errors
17
+ xcodebuild.parse_tests # returns number of test failures
18
+ xcodebuild.perfect_build # returns a bool indicating if the build was perfect
19
+
20
+ Messages are posted by default. You can stop them like this:
21
+
22
+ xcodebuild.post_messages = false
19
23
 
20
24
  ## Development
21
25
 
@@ -1,3 +1,3 @@
1
1
  module Xcodebuild
2
- VERSION = "0.0.4".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
@@ -21,6 +21,7 @@ module Danger
21
21
  @error_count = 0
22
22
  @test_failures_count = 0
23
23
  @xcodebuild_json = nil
24
+ @post_messages = true
24
25
  end
25
26
 
26
27
  # Allows you to specify a build title to prefix all the reported messages.
@@ -39,6 +40,11 @@ module Danger
39
40
  @xcodebuild_json = JSON.parse(File.open(value, 'r').read)
40
41
  end
41
42
 
43
+ # Allows you to specify whether default messages should be posted when parsing
44
+ # @return [Bool]
45
+ #
46
+ attr_accessor :post_messages
47
+
42
48
  # Parses and exposes eventual warnings.
43
49
  # @return [warning_count]
44
50
  #
@@ -46,7 +52,7 @@ module Danger
46
52
  @warning_count = @xcodebuild_json["warnings"].count
47
53
  @warning_count = @warning_count + @xcodebuild_json["ld_warnings"].count
48
54
  @warning_count = @warning_count + @xcodebuild_json["compile_warnings"].count
49
- if @warning_count > 0
55
+ if @warning_count > 0 && post_messages
50
56
  warning_string = @warning_count == 1 ? "warning" : "warnings"
51
57
  message = Array.new
52
58
  message.push (@build_title) unless @build_title.nil?
@@ -65,7 +71,7 @@ module Danger
65
71
  errors += @xcodebuild_json["file_missing_errors"].map {|x| "`[#{x["file_path"].split("/").last}] #{x["reason"]}`"}
66
72
  errors += @xcodebuild_json["undefined_symbols_errors"].map {|x| "`#{x["message"]}`"}
67
73
  errors += @xcodebuild_json["duplicate_symbols_errors"].map {|x| "`#{x["message"]}`"}
68
- if errors.count > 0
74
+ if errors.count > 0 && post_messages
69
75
  error_string = errors.count == 1 ? "error" : "errors"
70
76
  message = Array.new
71
77
  message.push (@build_title) unless @build_title.nil?
@@ -88,7 +94,7 @@ module Danger
88
94
  test_failures += value.map {|x| "`[#{x["file_path"].split("/").last}] [#{x["test_case"]}] #{x["reason"]}`"}
89
95
  end
90
96
 
91
- if test_failures.count > 0
97
+ if test_failures.count > 0 && post_messages
92
98
  test_string = test_failures.count == 1 ? "error" : "errors"
93
99
  message = Array.new
94
100
  message.push (@build_title) unless @build_title.nil?
@@ -107,10 +113,12 @@ module Danger
107
113
  #
108
114
  def perfect_build
109
115
  is_perfect_build = @warning_count == 0 && @error_count == 0 && @test_failures_count == 0
110
- message = Array.new
111
- message.push (@build_title) unless @build_title.nil?
112
- message.push ("Perfect build 👍🏻")
113
- message(message.reject(&:empty?).join(" ")) if is_perfect_build
116
+ if post_messages
117
+ message = Array.new
118
+ message.push (@build_title) unless @build_title.nil?
119
+ message.push ("Perfect build 👍🏻")
120
+ message(message.reject(&:empty?).join(" ")) if is_perfect_build
121
+ end
114
122
  return is_perfect_build
115
123
  end
116
124
 
@@ -137,6 +137,57 @@ module Danger
137
137
 
138
138
  end
139
139
 
140
+ describe "with post messages set to false" do
141
+
142
+ before do
143
+ data = {
144
+ :warnings => ['warning1', 'warning2'],
145
+ :ld_warnings => ['ld_warnings'],
146
+ :compile_warnings => ['compile_warnings'],
147
+ :errors => ['error1', 'error2'],
148
+ :compile_errors => [
149
+ { :file_path => '/tmp/file1.m', :reason => 'reason1' },
150
+ { :file_path => '/tmp/file2.m', :reason => 'reason2' }
151
+ ],
152
+ :file_missing_errors => [
153
+ { :file_path => '/tmp/missing_file1.m', :reason => 'reason1' },
154
+ { :file_path => '/tmp/missing_file2.m', :reason => 'reason2' }
155
+ ],
156
+ :undefined_symbols_errors => [{ :message => 'undefined_symbols' }],
157
+ :duplicate_symbols_errors => [{ :message => 'duplicate_symbols' }],
158
+ :tests_failures => {
159
+ :suite1 => [{ :file_path => '/tmp/file1.m', :test_case => "testCase1", :reason => 'reason1' }],
160
+ :suite2 => [{ :file_path => '/tmp/file2.m', :test_case => "testCase2", :reason => 'reason2' }]
161
+ }
162
+ }.to_json
163
+
164
+ filename = 'xcodebuild_tests.json'
165
+ allow(File).to receive(:open).with(filename, 'r').and_return(StringIO.new(data))
166
+
167
+ @xcodebuild.json_file = filename
168
+ end
169
+
170
+ it "must not post messages" do
171
+ @xcodebuild.post_messages = false
172
+ warnings = @xcodebuild.parse_warnings
173
+ errors = @xcodebuild.parse_errors
174
+ tests_failures = @xcodebuild.parse_tests
175
+ is_perfect_build = @xcodebuild.perfect_build
176
+
177
+ expect(warnings).to eq(4)
178
+ expect(@dangerfile.status_report[:warnings]).to be_empty
179
+
180
+ expect(errors).to eq(8)
181
+ expect(tests_failures).to eq(2)
182
+ expect(@dangerfile.status_report[:errors]).to be_empty
183
+
184
+ expect(is_perfect_build).to eq(false)
185
+ expect(@dangerfile.status_report[:messages]).to be_empty
186
+ expect(@dangerfile.status_report[:markdowns]).to be_empty
187
+ end
188
+
189
+ end
190
+
140
191
  end
141
192
  end
142
193
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-xcodebuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valerio Mazzeo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-27 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger