@@ -12,6 +12,7 @@ import Foundation
12
12
import LLBuildManifest
13
13
@_spi ( SwiftPMInternal)
14
14
import SPMTestSupport
15
+ import TSCBasic
15
16
import XCTest
16
17
17
18
class PrepareForIndexTests : XCTestCase {
@@ -34,35 +35,38 @@ class PrepareForIndexTests: XCTestCase {
34
35
// Make sure we're not building things that link
35
36
XCTAssertNil ( manifest. commands [ " C.Core-debug.exe " ] )
36
37
37
- let outputs = manifest. commands. flatMap ( \. value. tool. outputs) . map ( \. name)
38
+ let outputs = try manifest. commands. flatMap ( \. value. tool. outputs) . map ( \. name)
39
+ . filter ( { $0. hasPrefix ( " /path/to/ " ) } )
40
+ . map ( { try AbsolutePath ( validating: $0) . components. suffix ( 3 ) . joined ( separator: " / " ) } )
38
41
39
42
// Make sure we're building the swift modules
40
43
let swiftModules = Set ( outputs. filter ( { $0. hasSuffix ( " .swiftmodule " ) } ) )
41
44
XCTAssertEqual ( swiftModules, Set ( [
42
- " /path/to/build/arm64-apple-macosx15.0/ debug/Core.build/Core.swiftmodule" ,
43
- " /path/to/build/arm64-apple-macosx15.0/ debug/Modules/CoreTests.swiftmodule" ,
44
- " /path/to/build/arm64-apple-macosx15.0/ debug/Modules/HAL.swiftmodule" ,
45
- " /path/to/build/arm64-apple-macosx15.0/ debug/Modules/HALTests.swiftmodule" ,
46
- " /path/to/build/arm64-apple-macosx15.0/ debug/Modules/MMIO.swiftmodule" ,
47
- " /path/to/build/arm64-apple-macosx15.0/ debug/Modules/SwiftSyntax.swiftmodule" ,
48
- " /path/to/build/arm64-apple-macosx15.0/ debug/Modules-tool/MMIOMacros.swiftmodule" ,
49
- " /path/to/build/arm64-apple-macosx15.0/ debug/Modules-tool/SwiftSyntax.swiftmodule" ,
45
+ " debug/Core.build/Core.swiftmodule " ,
46
+ " debug/Modules/CoreTests.swiftmodule " ,
47
+ " debug/Modules/HAL.swiftmodule " ,
48
+ " debug/Modules/HALTests.swiftmodule " ,
49
+ " debug/Modules/MMIO.swiftmodule " ,
50
+ " debug/Modules/SwiftSyntax.swiftmodule " ,
51
+ " debug/Modules-tool/MMIOMacros.swiftmodule " ,
52
+ " debug/Modules-tool/SwiftSyntax.swiftmodule " ,
50
53
] ) )
51
54
52
55
// Ensure swiftmodules built with correct arguments
53
56
let coreCommands = manifest. commands. values. filter ( {
54
57
$0. tool. outputs. contains ( where: {
55
- $0. name == " /path/to/build/arm64-apple-macosx15.0/ debug/Core.build/Core.swiftmodule"
58
+ $0. name. hasSuffix ( " debug/Core.build/Core.swiftmodule " )
56
59
} )
57
60
} )
61
+
58
62
XCTAssertEqual ( coreCommands. count, 1 )
59
63
let coreSwiftc = try XCTUnwrap ( coreCommands. first? . tool as? SwiftCompilerTool )
60
64
XCTAssertTrue ( coreSwiftc. otherArguments. contains ( " -experimental-skip-all-function-bodies " ) )
61
65
62
66
// Ensure tools are built normally
63
67
let toolCommands = manifest. commands. values. filter ( {
64
68
$0. tool. outputs. contains ( where: {
65
- $0. name == " /path/to/build/arm64-apple-macosx15.0/ debug/Modules-tool/SwiftSyntax.swiftmodule"
69
+ $0. name. hasSuffix ( " debug/Modules-tool/SwiftSyntax.swiftmodule " )
66
70
} )
67
71
} )
68
72
XCTAssertEqual ( toolCommands. count, 1 )
@@ -72,8 +76,8 @@ class PrepareForIndexTests: XCTestCase {
72
76
// Make sure only object files for tools are built
73
77
let objectFiles = Set ( outputs. filter ( { $0. hasSuffix ( " .o " ) } ) )
74
78
XCTAssertEqual ( objectFiles, Set ( [
75
- " /path/to/build/arm64-apple-macosx15.0/ debug/MMIOMacros-tool.build/source.swift.o" ,
76
- " /path/to/build/arm64-apple-macosx15.0/ debug/SwiftSyntax-tool.build/source.swift.o"
79
+ " debug/MMIOMacros-tool.build/source.swift.o " ,
80
+ " debug/SwiftSyntax-tool.build/source.swift.o "
77
81
] ) )
78
82
79
83
// Check diff with regular build plan
@@ -90,14 +94,16 @@ class PrepareForIndexTests: XCTestCase {
90
94
let outputs0 = manifest0. commands. flatMap ( \. value. tool. outputs) . map ( \. name)
91
95
92
96
// The prepare shouldn't create any other object files.
93
- let objectFiles0 = Set ( outputs0. filter ( { $0. hasSuffix ( " .o " ) } ) ) . subtracting ( objectFiles)
97
+ let objectFiles0 = try Set ( outputs0. filter ( { $0. hasSuffix ( " .o " ) } )
98
+ . map ( { try AbsolutePath ( validating: $0) . components. suffix ( 3 ) . joined ( separator: " / " ) } )
99
+ ) . subtracting ( objectFiles)
94
100
XCTAssertEqual ( objectFiles0, Set ( [
95
- " /path/to/build/arm64-apple-macosx15.0/ debug/Core.build/source.swift.o" ,
96
- " /path/to/build/arm64-apple-macosx15.0/ debug/CoreTests.build/source.swift.o" ,
97
- " /path/to/build/arm64-apple-macosx15.0/ debug/HAL.build/source.swift.o" ,
98
- " /path/to/build/arm64-apple-macosx15.0/ debug/HALTests.build/source.swift.o" ,
99
- " /path/to/build/arm64-apple-macosx15.0/ debug/MMIO.build/source.swift.o" ,
100
- " /path/to/build/arm64-apple-macosx15.0/ debug/SwiftSyntax.build/source.swift.o" ,
101
+ " debug/Core.build/source.swift.o " ,
102
+ " debug/CoreTests.build/source.swift.o " ,
103
+ " debug/HAL.build/source.swift.o " ,
104
+ " debug/HALTests.build/source.swift.o " ,
105
+ " debug/MMIO.build/source.swift.o " ,
106
+ " debug/SwiftSyntax.build/source.swift.o " ,
101
107
] ) )
102
108
}
103
109
}
0 commit comments