fastlane-plugin-test_center 3.8.6 → 3.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88bf82b019ae47ea885712887f7e36b824e69bf3956f36d4a9d561b46c73d77b
4
- data.tar.gz: cb59d58624a9262fc0ad76afdd309ee1eef355646b2add4f086cf7a7af075f9e
3
+ metadata.gz: e79e02f37cfc5ea26854f135fad277dc194d225927b3a6f03ce8a43ea603ae20
4
+ data.tar.gz: 598759f0e60635a798a08d1c238f699a068e0fd6ab34ef286990a4bfe8565711
5
5
  SHA512:
6
- metadata.gz: 4d343c8d43b24e634cdea321f407656011ec874d6a26b2f17a7b002cbcab1e5c2cfef36b3ee278d71453c23b94983d69f2062df29c728e44be9ef24978a63b51
7
- data.tar.gz: 77b1bcc10f4066abdc5602448d8a6e714dd0b2f80a9c629e9a4b39509eec34bfec5d1f907dda68b4cba19239fe740067e16939c39969be6e3cbf85f84dd4fbea
6
+ metadata.gz: ef2ea4f6585fa7b363a9c5b3c7d543052ecb5dcfde31e7dd9676de84e1d23d2f11541acebdaf26ca1cc01effadcdc0489cc20935dc0a3f16e769a059ea0f1717
7
+ data.tar.gz: c8ceb6f97190d96588dc995a201aa1ff87a334968cbfb0a7237a28ba5fe32ccebb789348d2f5f3bf26bef6a7246ea7fea10d7b8bd38dfcdb47fba137b9ac48a7
@@ -6,6 +6,9 @@ module Fastlane
6
6
  def self.run(params)
7
7
  test_result_bundlepaths = params[:bundles]
8
8
  base_bundle_path = test_result_bundlepaths[0]
9
+
10
+ return if collate_version3_formatted_bundles(params)
11
+
9
12
  if test_result_bundlepaths.size > 1
10
13
  base_bundle_path = Dir.mktmpdir(['base', '.test_result'])
11
14
  FileUtils.cp_r(File.join(test_result_bundlepaths[0], '.'), base_bundle_path)
@@ -19,6 +22,63 @@ module Fastlane
19
22
  UI.message("Finished collating test_result bundle to '#{params[:collated_bundle]}'")
20
23
  end
21
24
 
25
+ def self.collate_version3_formatted_bundles(params)
26
+ test_result_bundlepaths = params[:bundles]
27
+ found_version3_format_bundle = test_result_bundlepaths.any? do |test_result_bundlepath|
28
+ is_bundle_format_3?(test_result_bundlepath)
29
+ end
30
+
31
+ if found_version3_format_bundle
32
+ FastlaneCore::UI.verbose("result bundles are of format version 3")
33
+ `xcrun xcresulttool version 2> /dev/null`
34
+ unless $?.exitstatus.zero?
35
+ UI.user_error!("""
36
+ Unable to collate version 3 format test_result bundle without the xcrun xcresulttool.
37
+ Please install and select Xcode 11, and then run the command again.""")
38
+ end
39
+ xcresulttool_merge(params)
40
+ end
41
+ FastlaneCore::UI.verbose("result bundles are NOT of format version 3")
42
+ return false
43
+ end
44
+
45
+ def self.xcresulttool_merge(params)
46
+ collated_bundlepath = File.expand_path(params[:collated_bundle])
47
+ Dir.mktmpdir do |dir|
48
+ tmp_xcresult_bundlepaths = []
49
+ test_result_bundlepaths.each do |test_result_bundlepath|
50
+ bundlename = File.basename(test_result_bundlepath)
51
+ # Note: the `xcresulttool` requires that the bundle names end in `.xcresult`.
52
+ tmp_xcresult_bundlepath = Dir.mktmpdir([bundlename, '.xcresult'])
53
+ FileUtils.rmdir([tmp_xcresult_bundlepath])
54
+ FileUtils.symlink(test_result_bundlepath, "#{tmp_xcresult_bundlepath}", force: true)
55
+ tmp_xcresult_bundlepaths << tmp_xcresult_bundlepath
56
+ end
57
+ tmp_collated_bundlepath = File.join(dir, File.basename(collated_bundlepath))
58
+ xcresulttool_cmd = 'xcrun xcresulttool merge '
59
+ xcresulttool_cmd += tmp_xcresult_bundlepaths.map(&:shellescape).join(' ')
60
+ xcresulttool_cmd += " --output-path #{tmp_collated_bundlepath}"
61
+ UI.message(xcresulttool_cmd)
62
+ sh(xcresulttool_cmd)
63
+ FileUtils.safe_unlink(tmp_xcresult_bundlepaths)
64
+ FileUtils.rm_rf(collated_bundlepath)
65
+ FileUtils.cp_r(tmp_collated_bundlepath, collated_bundlepath)
66
+ UI.message("Finished collating test_result bundle to '#{collated_bundlepath}'")
67
+ return true
68
+ end
69
+ end
70
+
71
+ def self.is_bundle_format_3?(bundle_path)
72
+ infoplist_filepath = File.join(bundle_path, 'Info.plist')
73
+ if File.exist?(infoplist_filepath)
74
+ base_infoplist = Plist.parse_xml(infoplist_filepath)
75
+ if base_infoplist.key?('version')
76
+ return true if base_infoplist.dig('version', 'major') > 2
77
+ end
78
+ end
79
+ false
80
+ end
81
+
22
82
  def self.collate_bundles(base_bundle_path, other_bundle_path)
23
83
  Dir.foreach(other_bundle_path) do |child_item|
24
84
  if child_item == 'Info.plist'
@@ -48,14 +48,14 @@ module TestCenter
48
48
  def test_count
49
49
  REXML::XPath.first(@root, ".//*[@id = 'counters']//*[@id='test-count']/*[@class = 'number']/text()").to_s.to_i
50
50
  end
51
-
51
+
52
52
  def set_test_count(test_count)
53
53
  test_count_element = REXML::XPath.first(@root, ".//*[@id = 'counters']//*[@id='test-count']/*[@class = 'number']/text()")
54
54
  test_count_element.value = test_count.to_s
55
55
  end
56
-
56
+
57
57
  def update_test_count
58
- testcase_elements = REXML::XPath.match(@root, ".//*[contains(@class, 'tests')]//*[contains(concat(' ', @class, ' '), ' test ')]")
58
+ testcase_elements = REXML::XPath.match(@root, "//*[contains(@class, 'tests')]//*[contains(concat(' ', @class, ' '), ' test ')]").uniq
59
59
  set_test_count(testcase_elements.size)
60
60
  end
61
61
 
@@ -89,7 +89,7 @@ module TestCenter
89
89
  "contains(concat(' ', @class, ' '), ' failing ')"
90
90
  ].join(' and ')
91
91
 
92
- failing_testcase_elements = REXML::XPath.match(@root, ".//[#{xpath_class_attributes}]")
92
+ failing_testcase_elements = REXML::XPath.match(@root, ".//*[#{xpath_class_attributes}]")
93
93
  set_fail_count(failing_testcase_elements.size)
94
94
  end
95
95
 
@@ -143,8 +143,11 @@ module TestCenter
143
143
  end
144
144
 
145
145
  def testcase_with_title(title)
146
- testcase_element = REXML::XPath.first(@root, ".//*[contains(@class, 'tests')]//*[contains(concat(' ', @class, ' '), ' test ')]//*[@class='title']/[normalize-space()='#{title}']/../../..")
147
- TestCase.new(testcase_element) unless testcase_element.nil?
146
+ found_title_element = REXML::XPath.match(@root, ".//*[contains(@class, 'tests')]//*[contains(concat(' ', @class, ' '), ' test ')]//*[@class='title']").find { |n| n.text.to_s.strip == title }
147
+ if found_title_element
148
+ testcase_element = found_title_element.parent.parent
149
+ TestCase.new(testcase_element) unless testcase_element.nil?
150
+ end
148
151
  end
149
152
 
150
153
  def passing?
@@ -243,8 +246,7 @@ module TestCenter
243
246
  "contains(concat(' ', @class, ' '), ' failing ')",
244
247
  "contains(concat(' ', @class, ' '), ' #{title} ')"
245
248
  ].join(' and ')
246
-
247
- REXML::XPath.first(@root.parent, ".//[#{xpath_class_attributes}]")
249
+ REXML::XPath.first(@root.parent, ".//*[#{xpath_class_attributes}]")
248
250
  end
249
251
 
250
252
  def remove_failure_details
@@ -114,7 +114,10 @@ module TestCenter
114
114
  return unless @result_bundle
115
115
 
116
116
  test_result_bundlepaths = sort_globbed_files("#{@source_reports_directory_glob}/#{@scheme}*.test_result")
117
- collated_test_result_bundlepath = File.absolute_path("#{File.join(@output_directory, @scheme)}.test_result")
117
+ result_bundlename_suffix = ''
118
+ result_bundlename_suffix = "-#{@reportnamer.report_count + 1}" if @reportnamer.report_count > 0
119
+
120
+ collated_test_result_bundlepath = File.absolute_path("#{File.join(@output_directory, @scheme)}#{result_bundlename_suffix}.test_result")
118
121
  if test_result_bundlepaths.size > 1
119
122
  FastlaneCore::UI.verbose("Collating test_result bundles #{test_result_bundlepaths}")
120
123
  config = create_config(
@@ -40,6 +40,9 @@ module TestCenter
40
40
  def delete_xcresults
41
41
  derived_data_path = File.expand_path(@options[:derived_data_path] || Scan.config[:derived_data_path])
42
42
  xcresults = Dir.glob("#{derived_data_path}/Logs/Test/*.xcresult")
43
+ if FastlaneCore::Helper.xcode_at_least?('11.0.0')
44
+ xcresults += Dir.glob("#{output_directory}/*.xcresult")
45
+ end
43
46
  FastlaneCore::UI.verbose("Deleting xcresults:")
44
47
  xcresults.each do |xcresult|
45
48
  FastlaneCore::UI.verbose(" #{xcresult}")
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TestCenter
3
- VERSION = "3.8.6"
3
+ VERSION = "3.8.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-test_center
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.6
4
+ version: 3.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lyndsey Ferguson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-09 00:00:00.000000000 Z
11
+ date: 2019-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json