Skip to content

Commit 82e7926

Browse files
authored
PackageLoadingTests: ensure that we use the correct path spelling (#6510)
Tests here verify the paths, which need the native representation. This ensures that we get the correct spelling of the paths in these tests. The memory leak on the non-Darwin platforms exists due to the path string not being pushed into an autorelease pool. The use of `withUnsafeFileSystemRepresentation` ends up mismatching the arc separator resulting in a test failure.
1 parent 5e2dcee commit 82e7926

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Tests/PackageLoadingTests/PackageBuilderTests.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,8 +1440,14 @@ class PackageBuilderTests: XCTestCase {
14401440
try TargetDescription(name: "Random", type: .system),
14411441
]
14421442
)
1443+
let map = "/\(predefinedSourceDir)/module.modulemap"
14431444
PackageBuilderTester(manifest, in: fs) { _, diagnostics in
1444-
diagnostics.check(diagnostic: "package has unsupported layout; missing system target module map at '/\(predefinedSourceDir)/module.modulemap'", severity: .error)
1445+
#if _runtime(_ObjC)
1446+
diagnostics.check(diagnostic: "package has unsupported layout; missing system target module map at '\(map)'", severity: .error)
1447+
#else
1448+
// FIXME: there is a memory leak here
1449+
diagnostics.check(diagnostic: "package has unsupported layout; missing system target module map at '\(String(cString: map.fileSystemRepresentation))'", severity: .error)
1450+
#endif
14451451
}
14461452
}
14471453
do {

Tests/PackageLoadingTests/ToolsVersionParserTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class ToolsVersionParserTests: XCTestCase {
161161

162162
XCTAssertThrowsError(
163163
try ToolsVersionParser.parse(manifestPath: manifestPath, fileSystem: fs),
164-
"empty manifest '/lorem/ipsum/dolor/Package.swift'") { error in
164+
"empty manifest '\(manifestPath.pathString)'") { error in
165165
guard let error = error as? ManifestParseError, case .emptyManifest(let errorPath) = error else {
166166
XCTFail("'ManifestParseError.emptyManifest' should've been thrown, but a different error is thrown")
167167
return
@@ -172,7 +172,7 @@ class ToolsVersionParserTests: XCTestCase {
172172
return
173173
}
174174

175-
XCTAssertEqual(error.description, "'/lorem/ipsum/dolor/Package.swift' is empty")
175+
XCTAssertEqual(error.description, "'\(manifestPath._nativePathString(escaped: false))' is empty")
176176
}
177177
}
178178

0 commit comments

Comments
 (0)