xctest_list 0.0.1 → 1.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 +4 -4
- data/lib/xctest_list.rb +37 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeb06d21421204888562b72281a9fb7efd691324
|
4
|
+
data.tar.gz: 17212dbff04fe9604bfd1dd901109165f01ca79c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3845223a72733c488073e4a441f6bf74a1aa916b60f22aa4b74d3941021605589e2f0c8211ce6e7454ccdd3b4a5a4e08e9fb207526f1403ca0e68f3e361e64f
|
7
|
+
data.tar.gz: 706b3f8803ab8898221cf5ccefc8b4cd5c5219d486096df1d0e4c7846f0dcfb2a8012943dc62ee67eb81c7baf6396df8d31e87c2756135831b9f3a33f2711a5d
|
data/lib/xctest_list.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
-
# NSString *swiftNmCmdline = @"nm -gU '%@' | cut -d' ' -f3 | xargs xcrun swift-demangle | cut -d' ' -f3 | grep -e '[\\.|_]'test";
|
2
|
-
|
3
|
-
require 'pathname'
|
4
1
|
|
2
|
+
# A class to parse xctest bundles and return a list of tests that
|
3
|
+
# are in the bundle's binary.
|
5
4
|
class XCTestList
|
5
|
+
# refactored into its own method to allow mocking in the spec
|
6
|
+
def self.system(command)
|
7
|
+
`#{command}`
|
8
|
+
end
|
9
|
+
|
10
|
+
# validate that the basic bundle parts exist
|
6
11
|
def self.validate_bundle(xctest_bundle_path)
|
7
|
-
raise "Cannot find xctest bundle at path '#{xctest_bundle_path}'" unless Dir.exist?(xctest_bundle_path)
|
12
|
+
raise "Cannot find xctest bundle at path: '#{xctest_bundle_path}'" unless Dir.exist?(xctest_bundle_path)
|
8
13
|
|
9
14
|
is_xctest_bundle = File.extname(xctest_bundle_path) == '.xctest'
|
10
15
|
raise "Invalid xctest bundle given: '#{xctest_bundle_path}'" unless is_xctest_bundle
|
11
16
|
end
|
12
17
|
|
18
|
+
# add the expected binary to the bundle path and validate that it exists
|
13
19
|
def self.binary_path(xctest_bundle_path)
|
14
20
|
validate_bundle(xctest_bundle_path)
|
15
21
|
|
@@ -21,16 +27,39 @@ class XCTestList
|
|
21
27
|
xctest_binary_path
|
22
28
|
end
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
# find the Objective-C symbols in the bundle's binary
|
31
|
+
def self.objc_tests(xctest_bundle_path)
|
32
|
+
objc_symbols_cmd = 'nm -U '
|
33
|
+
objc_symbols_cmd << "'#{binary_path(xctest_bundle_path)}'"
|
27
34
|
|
28
35
|
tests = []
|
29
|
-
|
36
|
+
system(objc_symbols_cmd).each_line do |line|
|
30
37
|
if / t -\[(?<testclass>\w+) (?<testmethod>test\w+)\]/ =~ line
|
31
38
|
tests << "#{testclass}/#{testmethod}"
|
32
39
|
end
|
33
40
|
end
|
34
41
|
tests
|
35
42
|
end
|
43
|
+
|
44
|
+
# cleanup the Swift nm output to only provide the swift symbols
|
45
|
+
def self.swift_symbols(swift_symbols_cmd_output)
|
46
|
+
swift_symbols_cmd_output.gsub(/^.* .* (.*)$/, '\1')
|
47
|
+
end
|
48
|
+
|
49
|
+
# find the Swift symbols in the bundle's binary
|
50
|
+
def self.swift_tests(xctest_bundle_path)
|
51
|
+
swift_symbols_cmd_output = system("nm -gU '#{binary_path(xctest_bundle_path)}'")
|
52
|
+
tests = []
|
53
|
+
swift_symbols(swift_symbols_cmd_output).each_line do |symbol|
|
54
|
+
if /\w+\.(?<testclass>[^\.]+)\.(?<testmethod>test[^\(]+)/ =~ system("xcrun swift-demangle #{symbol}")
|
55
|
+
tests << "#{testclass}/#{testmethod}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
tests
|
59
|
+
end
|
60
|
+
|
61
|
+
# find the Objective-C and Swift tests in the binary's bundle
|
62
|
+
def self.tests(xctest_bundle_path)
|
63
|
+
objc_tests(xctest_bundle_path) | swift_tests(xctest_bundle_path)
|
64
|
+
end
|
36
65
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xctest_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.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-09-
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A gem to retrieve the tests in an iOS xctest bundle
|
14
|
-
email:
|
14
|
+
email: ldf.public+github@outlook.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|