10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
- import Basics
13
+ @ testable import Basics
14
14
@testable import Build
15
15
@_implementationOnly import DriverSupport
16
16
import PackageLoading
@@ -43,12 +43,14 @@ final class BuildPlanTests: XCTestCase {
43
43
" /barPkg/Sources/BarLogging/file.swift "
44
44
)
45
45
let observability = ObservabilitySystem . makeForTesting ( )
46
+ let fooPkg : AbsolutePath = " /fooPkg "
47
+ let barPkg : AbsolutePath = " /barPkg "
46
48
XCTAssertThrowsError ( try loadPackageGraph (
47
49
fileSystem: fs,
48
50
manifests: [
49
51
Manifest . createFileSystemManifest (
50
52
displayName: " fooPkg " ,
51
- path: " / fooPkg" ,
53
+ path: fooPkg,
52
54
products: [
53
55
ProductDescription ( name: " Logging " , type: . library( . dynamic) , targets: [ " FooLogging " ] ) ,
54
56
] ,
@@ -57,7 +59,7 @@ final class BuildPlanTests: XCTestCase {
57
59
] ) ,
58
60
Manifest . createFileSystemManifest (
59
61
displayName: " barPkg " ,
60
- path: " / barPkg" ,
62
+ path: barPkg,
61
63
products: [
62
64
ProductDescription ( name: " Logging " , type: . library( . static) , targets: [ " BarLogging " ] ) ,
63
65
] ,
@@ -69,24 +71,21 @@ final class BuildPlanTests: XCTestCase {
69
71
path: " /thisPkg " ,
70
72
toolsVersion: . v5_8,
71
73
dependencies: [
72
- . localSourceControl( path: " / fooPkg" , requirement: . upToNextMajor( from: " 1.0.0 " ) ) ,
73
- . localSourceControl( path: " / barPkg" , requirement: . upToNextMajor( from: " 2.0.0 " ) ) ,
74
+ . localSourceControl( path: fooPkg, requirement: . upToNextMajor( from: " 1.0.0 " ) ) ,
75
+ . localSourceControl( path: barPkg, requirement: . upToNextMajor( from: " 2.0.0 " ) ) ,
74
76
] ,
75
77
targets: [
76
78
TargetDescription ( name: " exe " ,
77
- dependencies: [ . product( name: " Logging " ,
78
- package : " fooPkg "
79
- ) ,
80
- . product( name: " Logging " ,
81
- package : " barPkg "
82
- ) ,
79
+ dependencies: [ . product( name: " Logging " , package : " fooPkg " ) ,
80
+ . product( name: " Logging " , package : " barPkg " ) ,
83
81
] ,
84
82
type: . executable) ,
85
83
] ) ,
86
84
] ,
87
85
observabilityScope: observability. topScope
88
86
) ) { error in
89
- XCTAssertEqual ( ( error as? PackageGraphError ) ? . description, " multiple products named 'Logging' in: 'barpkg' (at '/barPkg'), 'foopkg' (at '/fooPkg') " )
87
+ XCTAssertEqual ( ( error as? PackageGraphError ) ? . description,
88
+ " multiple products named 'Logging' in: 'barpkg' (at ' \( barPkg) '), 'foopkg' (at ' \( fooPkg) ') " )
90
89
}
91
90
}
92
91
@@ -418,13 +417,15 @@ final class BuildPlanTests: XCTestCase {
418
417
" /barPkg/Sources/BarLogging/file.swift "
419
418
)
420
419
let observability = ObservabilitySystem . makeForTesting ( )
420
+ let fooPkg : AbsolutePath = " /fooPkg "
421
+ let barPkg : AbsolutePath = " /barPkg "
421
422
422
423
XCTAssertThrowsError ( try loadPackageGraph (
423
424
fileSystem: fs,
424
425
manifests: [
425
426
Manifest . createFileSystemManifest (
426
427
displayName: " fooPkg " ,
427
- path: " / fooPkg" ,
428
+ path: fooPkg,
428
429
toolsVersion: . v5_8,
429
430
products: [
430
431
ProductDescription ( name: " Logging " , type: . library( . automatic) , targets: [ " FooLogging " ] ) ,
@@ -434,7 +435,7 @@ final class BuildPlanTests: XCTestCase {
434
435
] ) ,
435
436
Manifest . createFileSystemManifest (
436
437
displayName: " barPkg " ,
437
- path: " / barPkg" ,
438
+ path: barPkg,
438
439
products: [
439
440
ProductDescription ( name: " Logging " , type: . library( . automatic) , targets: [ " BarLogging " ] ) ,
440
441
] ,
@@ -450,19 +451,16 @@ final class BuildPlanTests: XCTestCase {
450
451
] ,
451
452
targets: [
452
453
TargetDescription ( name: " exe " ,
453
- dependencies: [ . product( name: " Logging " ,
454
- package : " fooPkg "
455
- ) ,
456
- . product( name: " Logging " ,
457
- package : " barPkg "
458
- ) ,
454
+ dependencies: [ . product( name: " Logging " , package : " fooPkg " ) ,
455
+ . product( name: " Logging " , package : " barPkg " ) ,
459
456
] ,
460
457
type: . executable) ,
461
458
] ) ,
462
459
] ,
463
460
observabilityScope: observability. topScope
464
461
) ) { error in
465
- XCTAssertEqual ( ( error as? PackageGraphError ) ? . description, " multiple products named 'Logging' in: 'barpkg' (at '/barPkg'), 'foopkg' (at '/fooPkg') " )
462
+ XCTAssertEqual ( ( error as? PackageGraphError ) ? . description,
463
+ " multiple products named 'Logging' in: 'barpkg' (at ' \( barPkg) '), 'foopkg' (at ' \( fooPkg) ') " )
466
464
}
467
465
}
468
466
@@ -3585,7 +3583,7 @@ final class BuildPlanTests: XCTestCase {
3585
3583
toolset: . init(
3586
3584
knownTools: [
3587
3585
. cCompiler: . init( extraCLIOptions: [ " -I/fake/sdk/sysroot " , " -clang-flag-from-json " ] ) ,
3588
- . swiftCompiler: . init( extraCLIOptions: [ " -swift-flag-from-json " ] )
3586
+ . swiftCompiler: . init( extraCLIOptions: [ " -use-ld=lld " , " - swift-flag-from-json" ] )
3589
3587
] ,
3590
3588
rootPaths: try UserToolchain . default. swiftSDK. toolset. rootPaths
3591
3589
) ,
@@ -3616,7 +3614,17 @@ final class BuildPlanTests: XCTestCase {
3616
3614
XCTAssertMatch ( try lib. basicArguments ( isCXX: false ) , args)
3617
3615
3618
3616
let exe = try result. target ( for: " exe " ) . swiftTarget ( ) . compileArguments ( )
3619
- XCTAssertMatch ( exe, [ " -module-cache-path " , " \( buildPath. appending ( components: " ModuleCache " ) ) " , . anySequence, " -swift-flag-from-json " , " -g " , " -swift-command-line-flag " , . anySequence, " -Xcc " , " -clang-flag-from-json " , " -Xcc " , " -g " , " -Xcc " , " -clang-command-line-flag " ] )
3617
+ XCTAssertMatch ( exe, [
3618
+ " -module-cache-path " , " \( buildPath. appending ( components: " ModuleCache " ) ) " ,
3619
+ . anySequence,
3620
+ " -swift-flag-from-json " ,
3621
+ . anySequence,
3622
+ " -swift-command-line-flag " ,
3623
+ . anySequence,
3624
+ " -Xcc " , " -clang-flag-from-json " ,
3625
+ . anySequence,
3626
+ " -Xcc " , " -clang-command-line-flag "
3627
+ ] )
3620
3628
}
3621
3629
3622
3630
func testUserToolchainWithToolsetCompileFlags( ) throws {
@@ -3799,14 +3807,17 @@ final class BuildPlanTests: XCTestCase {
3799
3807
XCTAssertNoDiagnostics ( observability. diagnostics)
3800
3808
3801
3809
let targetTriple = try UserToolchain . default. targetTriple
3802
- let sdkIncludeSearchPath = " /usr/lib/swift_static/none/include "
3803
- let sdkLibrarySearchPath = " /usr/lib/swift_static/none/lib "
3810
+ let sdkIncludeSearchPath = AbsolutePath ( " /usr/lib/swift_static/none/include " )
3811
+ let sdkLibrarySearchPath = AbsolutePath ( " /usr/lib/swift_static/none/lib " )
3804
3812
let swiftSDK = try SwiftSDK (
3805
3813
targetTriple: targetTriple,
3806
3814
properties: . init(
3807
3815
sdkRootPath: " /fake/sdk " ,
3808
- includeSearchPaths: [ sdkIncludeSearchPath] ,
3809
- librarySearchPaths: [ sdkLibrarySearchPath] ) )
3816
+ includeSearchPaths: [ sdkIncludeSearchPath. pathString] ,
3817
+ librarySearchPaths: [ sdkLibrarySearchPath. pathString] ) ,
3818
+ toolset: . init( knownTools: [
3819
+ . swiftCompiler: . init( extraCLIOptions: [ " -use-ld=lld " ] ) ,
3820
+ ] ) )
3810
3821
let toolchain = try UserToolchain ( swiftSDK: swiftSDK)
3811
3822
let buildParameters = mockBuildParameters ( toolchain: toolchain)
3812
3823
let result = try BuildPlanResult ( plan: BuildPlan (
@@ -4798,10 +4809,10 @@ final class BuildPlanTests: XCTestCase {
4798
4809
try llbuild. generateManifest ( at: yaml)
4799
4810
4800
4811
let yamlContents : String = try fs. readFileContents ( yaml)
4801
- XCTAssertMatch ( yamlContents , . contains ( """
4802
- inputs: [ " /Pkg/Snippets/ASnippet.swift " , " /Pkg/.build/debug/Lib.swiftmodule "
4803
- """ ) )
4804
-
4812
+ let inputs : SerializedJSON = """
4813
+ inputs: [ " \( AbsolutePath ( " /Pkg/Snippets/ASnippet.swift " ) ) " , " \( AbsolutePath ( " /Pkg/.build/debug/Lib.swiftmodule " ) ) "
4814
+ """
4815
+ XCTAssertMatch ( yamlContents , . contains ( inputs . underlying ) )
4805
4816
}
4806
4817
4807
4818
private func sanitizerTest( _ sanitizer: PackageModel . Sanitizer , expectedName: String ) throws {
0 commit comments