1
1
package ftl.ios
2
2
3
+ import ftl.config.FtlConstants.macOS
3
4
import ftl.util.Bash
5
+ import ftl.util.Utils.copyBinaryResource
4
6
import java.io.File
5
7
6
8
object Parse {
7
9
10
+ private val installBinaries by lazy {
11
+ if (! macOS) {
12
+ copyBinaryResource(" nm" )
13
+ copyBinaryResource(" swift-demangle" )
14
+ copyBinaryResource(" libatomic.so.1" ) // swift-demangle dependency
15
+ copyBinaryResource(" libatomic.so.1.2.0" )
16
+ }
17
+ }
18
+
8
19
private fun validateFile (path : String ) {
9
20
val file = File (path)
10
21
if (! file.exists()) {
@@ -16,16 +27,20 @@ object Parse {
16
27
17
28
private fun methodName (matcher : MatchResult ): String {
18
29
return matcher.groupValues.last()
19
- .replace(' .' , ' /' )
20
- .replace(' ' , ' /' )
30
+ .replace(' .' , ' /' )
31
+ .replace(' ' , ' /' )
21
32
}
22
33
23
34
internal fun parseObjcTests (binary : String ): List <String > {
35
+ installBinaries
24
36
validateFile(binary)
25
37
26
38
val results = mutableListOf<String >()
27
39
// https://github.com/linkedin/bluepill/blob/37e7efa42472222b81adaa0e88f2bd82aa289b44/Source/Shared/BPXCTestFile.m#L18
28
- val output = Bash .execute(" nm -U $binary " )
40
+ var cmd = " nm -U $binary "
41
+ if (! macOS) cmd = " PATH=~/.flank $cmd "
42
+ val output = Bash .execute(cmd)
43
+
29
44
output.lines().forEach { line ->
30
45
// 000089b0 t -[EarlGreyExampleTests testLayout]
31
46
// 00008330 t -[EarlGreyExampleTests testCustomAction]
@@ -39,15 +54,22 @@ object Parse {
39
54
}
40
55
41
56
internal fun parseSwiftTests (binary : String ): List <String > {
57
+ installBinaries
42
58
validateFile(binary)
43
-
44
59
val results = mutableListOf<String >()
45
-
46
60
// The OS limits the list of arguments to ARG_MAX. Setting the xargs limit avoids a fatal
47
61
// 'argument too long' error. xargs will split the args and run the command for each chunk.
48
- val argMax = Bash .execute(" getconf ARG_MAX" )
62
+ // getconf ARG_MAX
63
+ val argMax = 262_144
64
+
65
+ val cmd = if (macOS) {
66
+ " nm -gU $binary | xargs -s $argMax xcrun swift-demangle"
67
+ } else {
68
+ " export LD_LIBRARY_PATH=~/.flank; export PATH=~/.flank:\$ PATH; nm -gU $binary | xargs -s $argMax swift-demangle"
69
+ }
70
+
49
71
// https://github.com/linkedin/bluepill/blob/37e7efa42472222b81adaa0e88f2bd82aa289b44/Source/Shared/BPXCTestFile.m#L17-18
50
- val demangledOutput = Bash .execute(" nm -gU $binary | xargs -s $argMax xcrun swift-demangle " )
72
+ val demangledOutput = Bash .execute(cmd )
51
73
demangledOutput.lines().forEach { line ->
52
74
// _T025EarlGreyExampleTestsSwift0abceD0C10testLayoutyyF ---> EarlGreyExampleTestsSwift.EarlGreyExampleSwiftTests.testLayout() -> ()
53
75
// _T025EarlGreyExampleTestsSwift0abceD0C16testCustomActionyyF ---> EarlGreyExampleTestsSwift.EarlGreyExampleSwiftTests.testCustomAction() -> ()
0 commit comments