xctest_list 1.1.4 → 1.2.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.
Files changed (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/xctest_list.rb +22 -12
  3. metadata +2 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b135528c2930823c1b2b1c80114718e6e592ef03
4
- data.tar.gz: c83baaf81dbc8711c4ee88783ae97adff34ecc4e
2
+ SHA256:
3
+ metadata.gz: 5ba4ec13aa03904dd67add015a892024392888ca2249507a4374dba75e877ea6
4
+ data.tar.gz: 3e2e5a315360be63e4b4811f7d9cc49163ccefc56a00b806b98665928d2ad8a2
5
5
  SHA512:
6
- metadata.gz: 3d490fa698a812624133584bf815898d043ecb95b529f581de5689adf149ea8e503b0e8f56a4a525f7c8f4899fca5cd6f816af0760c7ab4e7896e43bb461e1da
7
- data.tar.gz: 5a434f60320cc64d6297825239c02ea484b8207f09b564395c06180b5bff1f1c44cc16adc800f5ec6e2dde82d0485c970e084388de27e7fd0124a373e8243a13
6
+ metadata.gz: 4e92a404299ddbfaa80402f7e44463eb17e4c98f6655ce8f93766682377ec89baa2847a85e37b68abe7ca60f62815ffbd7aba7353bc9337ad20675299c65e84d
7
+ data.tar.gz: ee4c4972c09a280f787521cd655ae603883d4c5fb0ca80ead55bc2ec322cafa93d9cb1cc454fb505d7ba226640e9ad6d24e6b65863b4c2635685ad1ece41977e
@@ -30,45 +30,55 @@ class XCTestList
30
30
  unless File.exist?(xctest_binary_path)
31
31
  raise "Missing xctest binary: '#{xctest_binary_path}'"
32
32
  end
33
+
33
34
  xctest_binary_path
34
35
  end
35
36
 
36
37
  # find the Objective-C symbols in the bundle's binary
37
- def self.objc_tests(xctest_bundle_path)
38
+ def self.objc_tests(xctest_bundle_path, test_prefix: "test")
38
39
  tests = []
39
40
  objc_symbols_command_output_tempfile = Tempfile.new(File.basename(xctest_bundle_path) + "objc")
40
41
  system("nm -U '#{binary_path(xctest_bundle_path)}' > '#{objc_symbols_command_output_tempfile.path}'")
41
42
  tests = []
42
43
  File.foreach(objc_symbols_command_output_tempfile.path) do |line|
43
- if / t -\[(?<testclass>\w+) (?<testmethod>test\w+)\]/ =~ line
44
- tests << "#{testclass}/#{testmethod}"
44
+ regex = / t -\[(?<testclass>\w+) (?<testmethod>#{test_prefix}\w*)\]/
45
+ if (matches = regex.match(line))
46
+ tests << "#{matches[:testclass]}/#{matches[:testmethod]}"
45
47
  end
46
48
  end
47
49
  tests
48
50
  end
49
51
 
50
52
  # cleanup the Swift nm output to only provide the swift symbols
51
- def self.swift_symbols(swift_symbols_cmd_output)
53
+ def self.swift_symbols(swift_symbols_cmd_output, test_prefix: "test")
52
54
  swift_symbols_cmd_output.gsub(/^.* .* (.*)$/, '\1')
53
55
  end
54
56
 
57
+ def self.swift_symbol_dump_command(xctest_binary_path, test_prefix: "test")
58
+ nm_version_string = `nm -version | head -n 1 | sed -E 's/Apple LLVM version ([0-9]+\.[0-9]+\.[0-9]+).*/\\1/'`.chomp
59
+ if Gem::Version.new(nm_version_string) < Gem::Version.new('9.0.0')
60
+ "nm -gU '#{xctest_binary_path}' | cut -d' ' -f3 | xcrun swift-demangle | grep -E '^\\S+\\.test[^.]+\\(\\)$' | sed 's/ () -> ()/()/'"
61
+ else
62
+ "nm -gU '#{xctest_binary_path}' | cut -d' ' -f3 | xargs -s 131072 xcrun swift-demangle | cut -d' ' -f3 | grep -e '[\\.|_]'#{test_prefix}"
63
+ end
64
+ end
65
+
55
66
  # find the Swift symbols in the bundle's binary
56
- def self.swift_tests(xctest_bundle_path)
67
+ def self.swift_tests(xctest_bundle_path, test_prefix: "test")
57
68
  swift_symbols_command_output_tempfile = Tempfile.new(File.basename(xctest_bundle_path) + "swift")
58
- system("nm -gU '#{binary_path(xctest_bundle_path)}' > '#{swift_symbols_command_output_tempfile.path}'")
69
+ system("#{swift_symbol_dump_command(binary_path(xctest_bundle_path), test_prefix: test_prefix)} > '#{swift_symbols_command_output_tempfile.path}'")
59
70
  tests = []
60
71
  File.foreach(swift_symbols_command_output_tempfile.path) do |line|
61
- next unless /.*__\w+test\w*/ =~ line
62
-
63
- if /.*-\[.*\]/ !~ line && /\w+\.(?<testclass>[^\.]+)\.(?<testmethod>test[^\(]+)\(/ =~ system("xcrun swift-demangle #{line}")
64
- tests << "#{testclass}/#{testmethod}"
72
+ regex = /\w+\.(?<testclass>[^\.]+)\.(?<testmethod>#{test_prefix}[^\(]*)\(/
73
+ if /.*-\[.*\]/ !~ line && (matches = regex.match(line))
74
+ tests << "#{matches[:testclass]}/#{matches[:testmethod]}"
65
75
  end
66
76
  end
67
77
  tests
68
78
  end
69
79
 
70
80
  # find the Objective-C and Swift tests in the binary's bundle
71
- def self.tests(xctest_bundle_path)
72
- objc_tests(xctest_bundle_path) | swift_tests(xctest_bundle_path)
81
+ def self.tests(xctest_bundle_path, test_prefix: 'test')
82
+ objc_tests(xctest_bundle_path, test_prefix: test_prefix) | swift_tests(xctest_bundle_path, test_prefix: test_prefix)
73
83
  end
74
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xctest_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lyndsey Ferguson
@@ -50,8 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  - !ruby/object:Gem::Version
51
51
  version: '0'
52
52
  requirements: []
53
- rubyforge_project:
54
- rubygems_version: 2.6.11
53
+ rubygems_version: 3.0.6
55
54
  signing_key:
56
55
  specification_version: 4
57
56
  summary: List the tests in the given xctest bundle