Skip to content

Commit d47f2e4

Browse files
authored
Tests: replace use of AbsolutePath.appending(RelativePath(_:)) (#4242)
This cleans up the last of the instances of `AbsolutePath.appending(RelativePath(_:))` in favour of `AbsolutePath(_:relativeTo:)`. The three remaining instances are of `AbsolutePath.appending(RelativePath(validating:))`.
1 parent a84ebbc commit d47f2e4

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

IntegrationTests/Tests/IntegrationTests/BasicTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class BasicTests: XCTestCase {
2828
XCTAssertMatch(build1Output, .contains("Build complete"))
2929

3030
// Verify that the app works.
31-
let dealerOutput = try sh(packagePath.appending(RelativePath(".build/debug/dealer")), "10").stdout
31+
let dealerOutput = try sh(AbsolutePath(".build/debug/dealer", relativeTo: packagePath), "10").stdout
3232
XCTAssertEqual(dealerOutput.filter(\.isPlayingCardSuit).count, 10)
3333

3434
// Verify that the 'git status' is clean after a build.

IntegrationTests/Tests/IntegrationTests/Helpers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func fixture(
209209

210210
// Construct the expected path of the fixture.
211211
// FIXME: This seems quite hacky; we should provide some control over where fixtures are found.
212-
let fixtureDir = AbsolutePath(#file).appending(RelativePath("../../../Fixtures")).appending(fixtureSubpath)
212+
let fixtureDir = AbsolutePath("../../../Fixtures/\(name)", relativeTo: AbsolutePath(#file))
213213

214214
// Check that the fixture is really there.
215215
guard localFileSystem.isDirectory(fixtureDir) else {
@@ -317,7 +317,7 @@ func binaryTargetsFixture(_ closure: (AbsolutePath) throws -> Void) throws {
317317
let subpath = inputsPath.appending(component: "SwiftFramework")
318318
let projectPath = subpath.appending(component: "SwiftFramework.xcodeproj")
319319
try sh(xcodebuild, "-project", projectPath, "-scheme", "SwiftFramework", "-derivedDataPath", tmpDir, "COMPILER_INDEX_STORE_ENABLE=NO")
320-
let frameworkPath = tmpDir.appending(RelativePath("Build/Products/Debug/SwiftFramework.framework"))
320+
let frameworkPath = AbsolutePath("Build/Products/Debug/SwiftFramework.framework", relativeTo: tmpDir)
321321
let xcframeworkPath = packagePath.appending(component: "SwiftFramework.xcframework")
322322
try sh(xcodebuild, "-create-xcframework", "-framework", frameworkPath, "-output", xcframeworkPath)
323323
}

IntegrationTests/Tests/IntegrationTests/SwiftPMTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,24 @@ final class SwiftPMTests: XCTestCase {
6262
for entry in try localFileSystem.getDirectoryContents(packagePath.appending(components: "Sources", "foo")) {
6363
try localFileSystem.removeFileTree(packagePath.appending(components: "Sources", "foo", entry))
6464
}
65-
try localFileSystem.writeFileContents(packagePath.appending(RelativePath("Sources/foo/main.m"))) {
65+
try localFileSystem.writeFileContents(AbsolutePath("Sources/foo/main.m", relativeTo: packagePath)) {
6666
$0 <<< "int main() {}"
6767
}
6868
let archs = ["x86_64", "arm64"]
6969

7070
for arch in archs {
7171
try sh(swiftBuild, "--package-path", packagePath, "--arch", arch)
72-
let fooPath = packagePath.appending(RelativePath(".build/\(arch)-apple-macosx/debug/foo"))
72+
let fooPath = AbsolutePath(".build/\(arch)-apple-macosx/debug/foo", relativeTo: packagePath)
7373
XCTAssertFileExists(fooPath)
7474
}
7575

7676
let args = [swiftBuild.pathString, "--package-path", packagePath.pathString] + archs.flatMap{ ["--arch", $0] }
7777
try _sh(args)
7878

79-
let fooPath = packagePath.appending(RelativePath(".build/apple/Products/Debug/foo"))
79+
let fooPath = AbsolutePath(".build/apple/Products/Debug/foo", relativeTo: packagePath)
8080
XCTAssertFileExists(fooPath)
8181

82-
let objectsDir = packagePath.appending(RelativePath(".build/apple/Intermediates.noindex/foo.build/Debug/foo.build/Objects-normal"))
82+
let objectsDir = AbsolutePath(".build/apple/Intermediates.noindex/foo.build/Debug/foo.build/Objects-normal", relativeTo: packagePath)
8383
for arch in archs {
8484
XCTAssertDirectoryExists(objectsDir.appending(component: arch))
8585
}

Tests/CommandsTests/PackageRegistryToolTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ final class PackageRegistryToolTests: CommandsTestCase {
5252
func testLocalConfiguration() throws {
5353
try fixture(name: "DependencyResolution/External/Simple") { fixturePath in
5454
let packageRoot = fixturePath.appending(component: "Bar")
55-
let configurationFilePath = packageRoot.appending(RelativePath(".swiftpm/configuration/registries.json"))
55+
let configurationFilePath = AbsolutePath(".swiftpm/configuration/registries.json", relativeTo: packageRoot)
5656

5757
XCTAssertFalse(localFileSystem.exists(configurationFilePath))
5858

@@ -131,7 +131,7 @@ final class PackageRegistryToolTests: CommandsTestCase {
131131
func testSetMissingURL() throws {
132132
try fixture(name: "DependencyResolution/External/Simple") { fixturePath in
133133
let packageRoot = fixturePath.appending(component: "Bar")
134-
let configurationFilePath = packageRoot.appending(RelativePath(".swiftpm/configuration/registries.json"))
134+
let configurationFilePath = AbsolutePath(".swiftpm/configuration/registries.json", relativeTo: packageRoot)
135135

136136
XCTAssertFalse(localFileSystem.exists(configurationFilePath))
137137

@@ -148,7 +148,7 @@ final class PackageRegistryToolTests: CommandsTestCase {
148148
func testSetInvalidURL() throws {
149149
try fixture(name: "DependencyResolution/External/Simple") { fixturePath in
150150
let packageRoot = fixturePath.appending(component: "Bar")
151-
let configurationFilePath = packageRoot.appending(RelativePath(".swiftpm/configuration/registries.json"))
151+
let configurationFilePath = AbsolutePath(".swiftpm/configuration/registries.json", relativeTo: packageRoot)
152152

153153
XCTAssertFalse(localFileSystem.exists(configurationFilePath))
154154

@@ -165,7 +165,7 @@ final class PackageRegistryToolTests: CommandsTestCase {
165165
func testSetInvalidScope() throws {
166166
try fixture(name: "DependencyResolution/External/Simple") { fixturePath in
167167
let packageRoot = fixturePath.appending(component: "Bar")
168-
let configurationFilePath = packageRoot.appending(RelativePath(".swiftpm/configuration/registries.json"))
168+
let configurationFilePath = AbsolutePath(".swiftpm/configuration/registries.json", relativeTo: packageRoot)
169169

170170
XCTAssertFalse(localFileSystem.exists(configurationFilePath))
171171

@@ -182,7 +182,7 @@ final class PackageRegistryToolTests: CommandsTestCase {
182182
func testUnsetMissingEntry() throws {
183183
try fixture(name: "DependencyResolution/External/Simple") { fixturePath in
184184
let packageRoot = fixturePath.appending(component: "Bar")
185-
let configurationFilePath = packageRoot.appending(RelativePath(".swiftpm/configuration/registries.json"))
185+
let configurationFilePath = AbsolutePath(".swiftpm/configuration/registries.json", relativeTo: packageRoot)
186186

187187
XCTAssertFalse(localFileSystem.exists(configurationFilePath))
188188

Tests/FunctionalTests/ResourcesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ResourcesTests: XCTestCase {
3737
try fixture(name: "Resources/Localized") { fixturePath in
3838
try executeSwiftBuild(fixturePath)
3939

40-
let exec = fixturePath.appending(RelativePath(".build/debug/exe"))
40+
let exec = AbsolutePath(".build/debug/exe", relativeTo: fixturePath)
4141
// Note: <rdar://problem/59738569> Source from LANG and -AppleLanguages on command line for Linux resources
4242
let output = try Process.checkNonZeroExit(args: exec.pathString, "-AppleLanguages", "(en_US)")
4343
XCTAssertEqual(output, """

Tests/XcodeprojTests/FunctionalTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class FunctionalTests: XCTestCase {
2727
let pbx = fixturePath.appending(component: "Library.xcodeproj")
2828
XCTAssertDirectoryExists(pbx)
2929
XCTAssertXcodeBuild(project: pbx)
30-
let build = fixturePath.appending(RelativePath("build/Build/Products/Debug"))
30+
let build = AbsolutePath("build/Build/Products/Debug", relativeTo: fixturePath)
3131
XCTAssertDirectoryExists(build.appending(component: "Library.framework"))
3232
}
3333
}
@@ -45,7 +45,7 @@ class FunctionalTests: XCTestCase {
4545
XCTAssertFileExists(pbx.appending(component: "SeaLib_Info.plist"))
4646

4747
XCTAssertXcodeBuild(project: pbx)
48-
let build = fixturePath.appending(RelativePath("build/Build/Products/Debug"))
48+
let build = AbsolutePath("build/Build/Products/Debug", relativeTo: fixturePath)
4949
XCTAssertDirectoryExists(build.appending(component: "SeaLib.framework"))
5050
XCTAssertFileExists(build.appending(component: "SeaExec"))
5151
XCTAssertFileExists(build.appending(component: "CExec"))
@@ -84,7 +84,7 @@ class FunctionalTests: XCTestCase {
8484
let pbx = moduleUser.appending(component: "SystemModuleUser.xcodeproj")
8585
XCTAssertDirectoryExists(pbx)
8686
XCTAssertXcodeBuild(project: pbx)
87-
let build = moduleUser.appending(RelativePath("build/Build/Products/Debug"))
87+
let build = AbsolutePath("build/Build/Products/Debug", relativeTo: moduleUser)
8888
XCTAssertFileExists(build.appending(components: "SystemModuleUser"))
8989
}
9090
}
@@ -98,7 +98,7 @@ class FunctionalTests: XCTestCase {
9898
let pbx = fixturePath.appending(component: "PackageWithNonc99NameModules.xcodeproj")
9999
XCTAssertDirectoryExists(pbx)
100100
XCTAssertXcodeBuild(project: pbx)
101-
let build = fixturePath.appending(RelativePath("build/Build/Products/Debug"))
101+
let build = AbsolutePath("build/Build/Products/Debug", relativeTo: fixturePath)
102102
XCTAssertDirectoryExists(build.appending(component: "A_B.framework"))
103103
XCTAssertDirectoryExists(build.appending(component: "B_C.framework"))
104104
XCTAssertDirectoryExists(build.appending(component: "C_D.framework"))

0 commit comments

Comments
 (0)