fastlane-plugin-test_center 1.2.0 → 2.0.0

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: 7c46c83ee933f5f236e9b6b2d6b75c0b7f9f3bc2
4
- data.tar.gz: c86c033bcc93a1eb6d83a86029fae1a4ba0d660d
3
+ metadata.gz: 1260815a43648f4c6b82c856b8113b96906bb757
4
+ data.tar.gz: 902bf36489b92aa7ce6c9ab3590d2c0cf99b9fd9
5
5
  SHA512:
6
- metadata.gz: 4b2f5a8ce473ed081db5edda0969e9df423f153876152d865f8955b9486d32cbc4f99899ebb80cdf3ed86656fe45dafc40f780e46aff5c8348d573f223949701
7
- data.tar.gz: 28598d3337505c1fc033ac6da1cc5fe086f09bf4f1ef4f744087473b2260aad10f3300dec80f756af2ef6e84f0492b8ab7fc810df3a4bafd8969784ca35fb55f
6
+ metadata.gz: b80ac781c34de4efc71202e5b14e187abd6801bd61d4e731168e32702dc703935b4e5a7dc7b70b3825d25ebbd1f79492ceaf38276e19a03107f04c9a82e545a2
7
+ data.tar.gz: c4ded416a5215782795b81ed066b2210ad70e0dcc419b4ac475fb149bdc90d1b6a9d57b2283b6691f2ddc7941eff1c2e7f3109db0b362a99389552f42d098656
@@ -1,6 +1,7 @@
1
1
  module Fastlane
2
2
  module Actions
3
3
  require 'fastlane/actions/scan'
4
+ require 'shellwords'
4
5
 
5
6
  class MultiScanAction < Action
6
7
  def self.run(params)
@@ -22,9 +23,10 @@ module Fastlane
22
23
  rescue FastlaneCore::Interface::FastlaneTestFailure => e
23
24
  UI.verbose("Scan failed with #{e}")
24
25
  if try_count < params[:try_count]
25
- report_filepath = junit_report_filepath(scan_options)
26
- scan_options[:only_testing] = other_action.tests_from_junit(junit: report_filepath)[:failed]
27
- increment_junit_report_filename(scan_options)
26
+ report_filepath = junit_report_filepath(scan_options)
27
+ failed_tests = other_action.tests_from_junit(junit: report_filepath)[:failed]
28
+ scan_options[:only_testing] = failed_tests.map(&:shellescape)
29
+ increment_junit_report_filename(scan_options)
28
30
  retry
29
31
  end
30
32
  end
@@ -123,7 +125,7 @@ module Fastlane
123
125
  end
124
126
 
125
127
  def self.authors
126
- ["lyndsey-ferguson/@ldferguson"]
128
+ ["lyndsey-ferguson/@lyndseydf"]
127
129
  end
128
130
 
129
131
  def self.is_supported?(platform)
@@ -5,7 +5,7 @@ module Fastlane
5
5
 
6
6
  def self.run(params)
7
7
  project_path = params[:xcodeproj]
8
- tests_to_skip = params[:tests]
8
+ all_tests_to_skip = params[:tests]
9
9
  scheme = params[:scheme]
10
10
 
11
11
  scheme_filepaths = Dir.glob("#{project_path}/{xcshareddata,xcuserdata}/**/xcschemes/#{scheme || '*'}.xcscheme")
@@ -18,6 +18,11 @@ module Fastlane
18
18
  is_dirty = false
19
19
  xcscheme = Xcodeproj::XCScheme.new(scheme_filepath)
20
20
  xcscheme.test_action.testables.each do |testable|
21
+ buildable_name = File.basename(testable.buildable_references[0].buildable_name, '.xctest')
22
+
23
+ tests_to_skip = all_tests_to_skip.select { |test| test.start_with?(buildable_name) }
24
+ .map { |test| test.sub("#{buildable_name}/", '') }
25
+
21
26
  tests_to_skip.each do |test_to_skip|
22
27
  skipped_test = Xcodeproj::XCScheme::TestAction::TestableReference::SkippedTest.new
23
28
  skipped_test.identifier = test_to_skip
@@ -55,9 +60,9 @@ module Fastlane
55
60
  verify_block: proc do |tests|
56
61
  UI.user_error!("Error: no tests were given to suppress!") unless tests and !tests.empty?
57
62
  tests.each do |test_identifier|
58
- is_valid_test_identifier = %r{^[a-zA-Z][a-zA-Z0-9]+(\/test[a-zA-Z0-9]+)?$} =~ test_identifier
63
+ is_valid_test_identifier = %r{^[a-zA-Z][a-zA-Z0-9]+\/[a-zA-Z][a-zA-Z0-9]+(\/test[a-zA-Z0-9]+)?$} =~ test_identifier
59
64
  unless is_valid_test_identifier
60
- UI.user_error!("Error: invalid test identifier '#{test_identifier}'. It must be in the format of 'TestSuiteToSuppress' or 'TestSuiteToSuppress/testToSuppress'")
65
+ UI.user_error!("Error: invalid test identifier '#{test_identifier}'. It must be in the format of 'Testable/TestSuiteToSuppress' or 'Testable/TestSuiteToSuppress/testToSuppress'")
61
66
  end
62
67
  end
63
68
  end,
@@ -76,7 +81,7 @@ module Fastlane
76
81
  end
77
82
 
78
83
  def self.authors
79
- ["lyndsey-ferguson/@ldferguson"]
84
+ ["lyndsey-ferguson/@lyndseydf"]
80
85
  end
81
86
 
82
87
  def self.is_supported?(platform)
@@ -11,14 +11,20 @@ module Fastlane
11
11
  UI.user_error!("Error: cannot find any schemes in the Xcode project")
12
12
  end
13
13
 
14
- report_file = File.open(params[:junit]) { |f| REXML::Document.new(f) }
15
- UI.user_error!("Malformed XML test report file given") if report_file.root.nil?
16
- UI.user_error!("Valid XML file is not an Xcode test report") if report_file.get_elements('testsuites').empty?
17
-
18
- if params[:suppress_type] == :failed
19
- tests_per_target_to_suppress = failing_tests(report_file)
20
- else
21
- tests_per_target_to_suppress = passing_tests(report_file)
14
+ testables = Hash.new([])
15
+ desired_passed_status = (params[:suppress_type] == :passing)
16
+
17
+ report = ::TestCenter::Helper::XcodeJunit::Report.new(params[:junit])
18
+
19
+ report.testables.each do |testable|
20
+ testables[testable.name] = []
21
+ testable.testsuites.each do |testsuite|
22
+ testsuite.testcases.each do |testcase|
23
+ if testcase.passed? == desired_passed_status
24
+ testables[testable.name] << testcase.skipped_test
25
+ end
26
+ end
27
+ end
22
28
  end
23
29
 
24
30
  scheme_filepaths.each do |scheme_filepath|
@@ -27,10 +33,7 @@ module Fastlane
27
33
 
28
34
  xcscheme.test_action.testables.each do |testable|
29
35
  buildable_name = testable.buildable_references[0].buildable_name
30
-
31
- tests_per_target_to_suppress[buildable_name].each do |test_to_skip|
32
- skipped_test = Xcodeproj::XCScheme::TestAction::TestableReference::SkippedTest.new
33
- skipped_test.identifier = test_to_skip
36
+ testables[buildable_name].each do |skipped_test|
34
37
  testable.add_skipped_test(skipped_test)
35
38
  is_dirty = true
36
39
  end
@@ -39,49 +42,6 @@ module Fastlane
39
42
  end
40
43
  end
41
44
 
42
- def self.failing_tests(report_file)
43
- tests = Hash.new { |hash, key| hash[key] = [] }
44
-
45
- report_file.elements.each('*/testsuite/testcase/failure') do |failure_element|
46
- testcase = failure_element.parent
47
- testsuite_element = testcase.parent
48
- buildable_name = buildable_name_from_testcase(testcase)
49
-
50
- tests[buildable_name] << xctest_identifier(testcase)
51
- # Remove all the failures from this in-memory xml file to make
52
- # it easier to find the passing tests below
53
- testsuite_element.delete_element testcase
54
- end
55
- tests
56
- end
57
-
58
- def self.passing_tests(report_file)
59
- tests = Hash.new { |hash, key| hash[key] = [] }
60
-
61
- report_file.elements.each('*/testsuite/testcase') do |testcase|
62
- buildable_name = buildable_name_from_testcase(testcase)
63
-
64
- tests[buildable_name] << xctest_identifier(testcase)
65
- end
66
- tests
67
- end
68
-
69
- def self.buildable_name_from_testcase(testcase)
70
- testsuite_element = testcase.parent
71
- buildable_element = testsuite_element.parent
72
- buildable_element.attributes['name']
73
- end
74
-
75
- def self.xctest_identifier(testcase)
76
- testcase_class = testcase.attributes['classname']
77
- testcase_testmethod = testcase.attributes['name']
78
-
79
- is_swift = testcase_class.include?('.')
80
- testcase_class.gsub!(/.*\./, '')
81
- testcase_testmethod << '()' if is_swift
82
- "#{testcase_class}/#{testcase_testmethod}"
83
- end
84
-
85
45
  #####################################################
86
46
  # @!group Documentation
87
47
  #####################################################
@@ -131,7 +91,7 @@ module Fastlane
131
91
  end
132
92
 
133
93
  def self.authors
134
- ["lyndsey-ferguson/@ldferguson"]
94
+ ["lyndsey-ferguson/@lyndseydf"]
135
95
  end
136
96
 
137
97
  def self.is_supported?(platform)
@@ -17,8 +17,12 @@ module Fastlane
17
17
  scheme_filepaths.each do |scheme_filepath|
18
18
  xcscheme = Xcodeproj::XCScheme.new(scheme_filepath)
19
19
  xcscheme.test_action.testables.each do |testable|
20
+ buildable_name = testable.buildable_references[0]
21
+ .buildable_name
22
+
23
+ buildable_name = File.basename(buildable_name, '.xctest')
20
24
  testable.skipped_tests.map do |skipped_test|
21
- skipped_tests.add(skipped_test.identifier)
25
+ skipped_tests.add("#{buildable_name}/#{skipped_test.identifier}")
22
26
  end
23
27
  end
24
28
  end
@@ -57,7 +61,7 @@ module Fastlane
57
61
  end
58
62
 
59
63
  def self.authors
60
- ["lyndsey-ferguson/@ldferguson"]
64
+ ["lyndsey-ferguson/@lyndseydf"]
61
65
  end
62
66
 
63
67
  def self.is_supported?(platform)
@@ -2,43 +2,26 @@ module Fastlane
2
2
  module Actions
3
3
  class TestsFromJunitAction < Action
4
4
  def self.run(params)
5
- report_file = File.open(params[:junit]) { |f| REXML::Document.new(f) }
6
- UI.user_error!("Malformed XML test report file given") if report_file.root.nil?
7
- UI.user_error!("Valid XML file is not an Xcode test report") if report_file.get_elements('testsuites').empty?
8
-
5
+ report = ::TestCenter::Helper::XcodeJunit::Report.new(params[:junit])
6
+ passing = []
7
+ failed = []
8
+ report.testables.each do |testable|
9
+ testable.testsuites.each do |testsuite|
10
+ testsuite.testcases.each do |testcase|
11
+ if testcase.passed?
12
+ passing << testcase.identifier
13
+ else
14
+ failed << testcase.identifier
15
+ end
16
+ end
17
+ end
18
+ end
9
19
  {
10
- passing: passing_tests(report_file).to_a,
11
- failed: failing_tests(report_file).to_a
20
+ failed: failed,
21
+ passing: passing
12
22
  }
13
23
  end
14
24
 
15
- def self.failing_tests(report_file)
16
- tests = Set.new
17
-
18
- report_file.elements.each('*/testsuite/testcase/failure') do |failure_element|
19
- testcase = failure_element.parent
20
- tests << xctest_identifier(testcase)
21
- end
22
- tests
23
- end
24
-
25
- def self.passing_tests(report_file)
26
- tests = Set.new
27
-
28
- report_file.elements.each('*/testsuite/testcase[not(failure)]') do |testcase|
29
- tests << xctest_identifier(testcase)
30
- end
31
- tests
32
- end
33
-
34
- def self.xctest_identifier(testcase)
35
- testcase_class = testcase.attributes['classname']
36
- testcase_testmethod = testcase.attributes['name']
37
-
38
- testcase_class.gsub!(/.*\./, '')
39
- "#{testcase_class}/#{testcase_testmethod}"
40
- end
41
-
42
25
  #####################################################
43
26
  # @!group Documentation
44
27
  #####################################################
@@ -65,7 +48,7 @@ module Fastlane
65
48
  end
66
49
 
67
50
  def self.authors
68
- ["lyndsey-ferguson/ldferguson"]
51
+ ["lyndsey-ferguson/lyndseydf"]
69
52
  end
70
53
 
71
54
  def self.is_supported?(platform)
@@ -0,0 +1,94 @@
1
+ require_relative 'xcodebuild_string'
2
+
3
+ module TestCenter
4
+ module Helper
5
+ module XcodeJunit
6
+ require 'xcodeproj'
7
+
8
+ class Report
9
+ def initialize(junit_report_filepath)
10
+ report_file = File.open(junit_report_filepath) { |f| REXML::Document.new(f) }
11
+ UI.user_error!("Malformed XML test report file given") if report_file.root.nil?
12
+ UI.user_error!("Valid XML file is not an Xcode test report") if report_file.get_elements('testsuites').empty?
13
+
14
+ @testables = []
15
+ report_file.elements.each('testsuites') do |testsuites_element|
16
+ @testables << Testable.new(testsuites_element)
17
+ end
18
+ end
19
+
20
+ def testables
21
+ return @testables
22
+ end
23
+ end
24
+
25
+ class Testable
26
+ def initialize(xml_element)
27
+ @root = xml_element
28
+ @testsuites = []
29
+ @root.elements.each('testsuite') do |testsuite_element|
30
+ @testsuites << TestSuite.new(testsuite_element)
31
+ end
32
+ end
33
+
34
+ def name
35
+ return @root.attributes['name']
36
+ end
37
+
38
+ def testsuites
39
+ return @testsuites
40
+ end
41
+ end
42
+
43
+ class TestSuite
44
+ def initialize(xml_element)
45
+ @root = xml_element
46
+ @testcases = []
47
+ @root.elements.each('testcase') do |testcase_element|
48
+ @testcases << TestCase.new(testcase_element)
49
+ end
50
+ end
51
+
52
+ def name
53
+ return @root.attributes['name']
54
+ end
55
+
56
+ def identifier
57
+ name.testsuite
58
+ end
59
+
60
+ def is_swift?
61
+ return name.include?('.')
62
+ end
63
+
64
+ def testcases
65
+ return @testcases
66
+ end
67
+ end
68
+
69
+ class TestCase
70
+ attr_reader :identifier
71
+ attr_reader :skipped_test
72
+
73
+ def initialize(xml_element)
74
+ @root = xml_element
75
+ name = xml_element.attributes['name']
76
+ full_testsuite = xml_element.parent.attributes['name']
77
+ testsuite = full_testsuite.testsuite
78
+ is_swift = full_testsuite.testsuite_swift?
79
+
80
+ testable_filename = xml_element.parent.parent.attributes['name']
81
+ testable = File.basename(testable_filename, '.xctest')
82
+ @identifier = "#{testable}/#{testsuite}/#{name}"
83
+ @skipped_test = Xcodeproj::XCScheme::TestAction::TestableReference::SkippedTest.new
84
+ @skipped_test.identifier = "#{testsuite}/#{name}#{'()' if is_swift}"
85
+ @passed = xml_element.get_elements('failure').size.zero?
86
+ end
87
+
88
+ def passed?
89
+ @passed
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,14 @@
1
+
2
+ class String
3
+ def testsuite_swift?
4
+ self.include?('.')
5
+ end
6
+
7
+ def testsuite
8
+ if self.testsuite_swift?
9
+ self.split('.')[1]
10
+ else
11
+ self
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TestCenter
3
- VERSION = "1.2.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-test_center
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lyndsey Ferguson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-18 00:00:00.000000000 Z
11
+ date: 2017-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xcodeproj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -142,7 +156,9 @@ files:
142
156
  - lib/fastlane/plugin/test_center/actions/suppress_tests_from_junit.rb
143
157
  - lib/fastlane/plugin/test_center/actions/suppressed_tests.rb
144
158
  - lib/fastlane/plugin/test_center/actions/tests_from_junit.rb
159
+ - lib/fastlane/plugin/test_center/helper/junit_helper.rb
145
160
  - lib/fastlane/plugin/test_center/helper/test_center_helper.rb
161
+ - lib/fastlane/plugin/test_center/helper/xcodebuild_string.rb
146
162
  - lib/fastlane/plugin/test_center/version.rb
147
163
  homepage: https://github.com/lyndsey-ferguson/fastlane-plugin-test_center
148
164
  licenses: