Skip to content

Commit 9e1a4e8

Browse files
authored
adjust tests to changes from TSC (#3008)
motivation: TSC had some test API changes that break SwiftPM tests changes: adjust test code to nwe TSC Test aPI
1 parent 1ab1ede commit 9e1a4e8

File tree

15 files changed

+88
-90
lines changed

15 files changed

+88
-90
lines changed

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ final class BuildPlanTests: XCTestCase {
324324
XCTAssertMatch(linkedFileList.description, .contains("PkgLib"))
325325
XCTAssertNoMatch(linkedFileList.description, .contains("ExtLib"))
326326

327-
mktmpdir { path in
327+
try testWithTemporaryDirectory { path in
328328
let yaml = path.appending(component: "release.yaml")
329329
let llbuild = LLBuildManifestBuilder(plan)
330330
try llbuild.generateManifest(at: yaml)
@@ -350,7 +350,7 @@ final class BuildPlanTests: XCTestCase {
350350
XCTAssertNoMatch(linkedFileList.description, .contains("PkgLib"))
351351
XCTAssertNoMatch(linkedFileList.description, .contains("ExtLib"))
352352

353-
mktmpdir { path in
353+
try testWithTemporaryDirectory { path in
354354
let yaml = path.appending(component: "debug.yaml")
355355
let llbuild = LLBuildManifestBuilder(plan)
356356
try llbuild.generateManifest(at: yaml)
@@ -722,7 +722,7 @@ final class BuildPlanTests: XCTestCase {
722722
])
723723
#endif
724724

725-
mktmpdir { path in
725+
try testWithTemporaryDirectory { path in
726726
let yaml = path.appending(component: "debug.yaml")
727727
let llbuild = LLBuildManifestBuilder(plan)
728728
try llbuild.generateManifest(at: yaml)
@@ -2078,7 +2078,7 @@ final class BuildPlanTests: XCTestCase {
20782078

20792079
let plan = try BuildPlan(buildParameters: mockBuildParameters(), graph: graph, diagnostics: diagnostics, fileSystem: fs)
20802080

2081-
mktmpdir { path in
2081+
try testWithTemporaryDirectory { path in
20822082
let yaml = path.appending(component: "debug.yaml")
20832083
let llbuild = LLBuildManifestBuilder(plan)
20842084
try llbuild.generateManifest(at: yaml)
@@ -2130,7 +2130,7 @@ final class BuildPlanTests: XCTestCase {
21302130
XCTAssertNoMatch(barTarget, [.anySequence, "-fmodule-map-file=/path/to/build/debug/Foo.build/module.modulemap", .anySequence])
21312131
#endif
21322132

2133-
mktmpdir { path in
2133+
try testWithTemporaryDirectory { path in
21342134
let yaml = path.appending(component: "debug.yaml")
21352135
let llbuild = LLBuildManifestBuilder(plan)
21362136
try llbuild.generateManifest(at: yaml)
@@ -2198,7 +2198,7 @@ final class BuildPlanTests: XCTestCase {
21982198
XCTAssertNoMatch(barTarget, [.anySequence, "-fmodule-map-file=/path/to/build/debug/Foo.build/module.modulemap", .anySequence])
21992199
#endif
22002200

2201-
mktmpdir { path in
2201+
try testWithTemporaryDirectory { path in
22022202
let yaml = path.appending(component: "debug.yaml")
22032203
let llbuild = LLBuildManifestBuilder(plan)
22042204
try llbuild.generateManifest(at: yaml)
@@ -2267,7 +2267,7 @@ final class BuildPlanTests: XCTestCase {
22672267
XCTAssertNoMatch(barTarget, [.anySequence, "-fmodule-map-file=/path/to/build/debug/Foo.build/module.modulemap", .anySequence])
22682268
#endif
22692269

2270-
mktmpdir { path in
2270+
try testWithTemporaryDirectory { path in
22712271
let yaml = path.appending(component: "debug.yaml")
22722272
let llbuild = LLBuildManifestBuilder(plan)
22732273
try llbuild.generateManifest(at: yaml)
@@ -2314,7 +2314,7 @@ final class BuildPlanTests: XCTestCase {
23142314
XCTAssertTrue(objects.contains(AbsolutePath("/path/to/build/debug/exe.build/exe.swiftmodule.o")), objects.description)
23152315
XCTAssertTrue(objects.contains(AbsolutePath("/path/to/build/debug/lib.build/lib.swiftmodule.o")), objects.description)
23162316

2317-
mktmpdir { path in
2317+
try testWithTemporaryDirectory { path in
23182318
let yaml = path.appending(component: "debug.yaml")
23192319
let llbuild = LLBuildManifestBuilder(result.plan)
23202320
try llbuild.generateManifest(at: yaml)

Tests/CommandsTests/PackageToolTests.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ final class PackageToolTests: XCTestCase {
288288
}
289289

290290
func testInitEmpty() throws {
291-
mktmpdir { tmpPath in
291+
try testWithTemporaryDirectory { tmpPath in
292292
let fs = localFileSystem
293293
let path = tmpPath.appending(component: "Foo")
294294
try fs.createDirectory(path)
@@ -301,7 +301,7 @@ final class PackageToolTests: XCTestCase {
301301
}
302302

303303
func testInitExecutable() throws {
304-
mktmpdir { tmpPath in
304+
try testWithTemporaryDirectory { tmpPath in
305305
let fs = localFileSystem
306306
let path = tmpPath.appending(component: "Foo")
307307
try fs.createDirectory(path)
@@ -321,7 +321,7 @@ final class PackageToolTests: XCTestCase {
321321
}
322322

323323
func testInitLibrary() throws {
324-
mktmpdir { tmpPath in
324+
try testWithTemporaryDirectory { tmpPath in
325325
let fs = localFileSystem
326326
let path = tmpPath.appending(component: "Foo")
327327
try fs.createDirectory(path)
@@ -336,7 +336,7 @@ final class PackageToolTests: XCTestCase {
336336
}
337337

338338
func testInitCustomNameExecutable() throws {
339-
mktmpdir { tmpPath in
339+
try testWithTemporaryDirectory { tmpPath in
340340
let fs = localFileSystem
341341
let path = tmpPath.appending(component: "Foo")
342342
try fs.createDirectory(path)
@@ -609,8 +609,8 @@ final class PackageToolTests: XCTestCase {
609609
}
610610
}
611611

612-
func testSymlinkedDependency() {
613-
mktmpdir { path in
612+
func testSymlinkedDependency() throws {
613+
try testWithTemporaryDirectory { path in
614614
let fs = localFileSystem
615615
let root = path.appending(components: "root")
616616
let dep = path.appending(components: "dep")
@@ -659,8 +659,8 @@ final class PackageToolTests: XCTestCase {
659659
}
660660
}
661661

662-
func testWatchmanXcodeprojgen() {
663-
mktmpdir { path in
662+
func testWatchmanXcodeprojgen() throws {
663+
try testWithTemporaryDirectory { path in
664664
let fs = localFileSystem
665665
let diagnostics = DiagnosticsEngine()
666666

@@ -690,8 +690,8 @@ final class PackageToolTests: XCTestCase {
690690
}
691691
}
692692

693-
func testMirrorConfig() {
694-
mktmpdir { prefix in
693+
func testMirrorConfig() throws {
694+
try testWithTemporaryDirectory { prefix in
695695
let fs = localFileSystem
696696
let packageRoot = prefix.appending(component: "Foo")
697697
let configOverride = prefix.appending(component: "configoverride")
@@ -758,7 +758,7 @@ final class PackageToolTests: XCTestCase {
758758
func testPackageLoadingCommandPathResilience() throws {
759759
#if os(macOS)
760760
fixture(name: "ValidLayouts/SingleModule") { prefix in
761-
mktmpdir { tmpdir in
761+
try testWithTemporaryDirectory { tmpdir in
762762
// Create fake `xcrun` and `sandbox-exec` commands.
763763
let fakeBinDir = tmpdir
764764
for fakeCmdName in ["xcrun", "sandbox-exec"] {

Tests/FunctionalTests/MiscellaneousTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ class MiscellaneousTestCase: XCTestCase {
528528
return
529529
}
530530

531-
mktmpdir { path in
531+
try testWithTemporaryDirectory { path in
532532
let fs = localFileSystem
533533

534534
let package = path.appending(component: "foo")

Tests/FunctionalTests/ToolsVersionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Workspace
2121
class ToolsVersionTests: XCTestCase {
2222

2323
func testToolsVersion() throws {
24-
mktmpdir { path in
24+
try testWithTemporaryDirectory{ path in
2525
let fs = localFileSystem
2626

2727
// Create a repo for the dependency to test against.

Tests/FunctionalTests/VersionSpecificTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import SPMTestSupport
1919
class VersionSpecificTests: XCTestCase {
2020
/// Functional tests of end-to-end support for version specific dependency resolution.
2121
func testEndToEndResolution() throws {
22-
mktmpdir { path in
22+
try testWithTemporaryDirectory{ path in
2323
let fs = localFileSystem
2424

2525
// Create a repo for the dependency to test against.

Tests/PackageGraphTests/RepositoryPackageContainerProviderTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ class RepositoryPackageContainerProviderTests: XCTestCase {
503503
}
504504

505505

506-
func testMissingBranchDiagnostics() {
507-
mktmpdir { tmpDir in
506+
func testMissingBranchDiagnostics() throws {
507+
try testWithTemporaryDirectory { tmpDir in
508508
// Create a repository.
509509
let packageDir = tmpDir.appending(component: "SomePackage")
510510
try localFileSystem.createDirectory(packageDir)

Tests/PackageLoadingPerformanceTests/ManifestLoadingTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ import PackageLoading
1717
class ManifestLoadingPerfTests: XCTestCasePerf {
1818
let manifestLoader = ManifestLoader(manifestResources: Resources.default)
1919

20-
func write(_ bytes: ByteString, body: (AbsolutePath) -> ()) {
21-
mktmpdir { path in
22-
let manifestFile = path.appending(component: "Package.swift")
20+
func write(_ bytes: ByteString, body: (AbsolutePath) -> ()) throws {
21+
try testWithTemporaryDirectory { tmpdir in
22+
let manifestFile = tmpdir.appending(component: "Package.swift")
2323
try localFileSystem.writeFileContents(manifestFile, bytes: bytes)
24-
body(path)
24+
body(tmpdir)
2525
}
2626
}
2727

28-
func testTrivialManifestLoading_X1() {
28+
func testTrivialManifestLoading_X1() throws {
2929
#if os(macOS)
3030
let N = 1
3131
let trivialManifest = ByteString(encodingAsUTF8: ("""
3232
import PackageDescription
3333
let package = Package(name: "Trivial")
3434
"""))
35-
write(trivialManifest) { path in
35+
try write(trivialManifest) { path in
3636
measure {
3737
for _ in 0..<N {
3838
let manifest = try! self.manifestLoader.load(
@@ -47,7 +47,7 @@ class ManifestLoadingPerfTests: XCTestCasePerf {
4747
#endif
4848
}
4949

50-
func testNonTrivialManifestLoading_X1() {
50+
func testNonTrivialManifestLoading_X1() throws {
5151
#if os(macOS)
5252
let N = 1
5353
let manifest = ByteString(encodingAsUTF8: """
@@ -64,7 +64,7 @@ class ManifestLoadingPerfTests: XCTestCasePerf {
6464
)
6565
""")
6666

67-
write(manifest) { path in
67+
try write(manifest) { path in
6868
measure {
6969
for _ in 0..<N {
7070
let manifest = try! self.manifestLoader.load(

Tests/PackageLoadingTests/PD4_2LoadingTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
443443
}
444444
}
445445

446-
func testCacheInvalidationOnEnv() {
447-
mktmpdir { path in
446+
func testCacheInvalidationOnEnv() throws {
447+
try testWithTemporaryDirectory { path in
448448
let fs = localFileSystem
449449

450450
let manifestPath = path.appending(components: "pkg", "Package.swift")
@@ -499,8 +499,8 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
499499
}
500500
}
501501

502-
func testCaching() {
503-
mktmpdir { path in
502+
func testCaching() throws {
503+
try testWithTemporaryDirectory { path in
504504
let fs = localFileSystem
505505

506506
let manifestPath = path.appending(components: "pkg", "Package.swift")
@@ -579,7 +579,7 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
579579
}
580580

581581
func testContentBasedCaching() throws {
582-
mktmpdir { path in
582+
try testWithTemporaryDirectory { path in
583583
let stream = BufferedOutputByteStream()
584584
stream <<< """
585585
import PackageDescription

Tests/PackageLoadingTests/PD5LoadingTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class PackageDescription5LoadingTests: PackageDescriptionLoadingTests {
323323
}
324324

325325
func testSerializedDiagnostics() throws {
326-
mktmpdir { path in
326+
try testWithTemporaryDirectory { path in
327327
let fs = localFileSystem
328328

329329
let manifestPath = path.appending(components: "pkg", "Package.swift")

Tests/PackageLoadingTests/PackageBuilderTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class PackageBuilderTests: XCTestCase {
5656
}
5757

5858
func testBrokenSymlink() throws {
59-
mktmpdir { path in
59+
try testWithTemporaryDirectory { path in
6060
let fs = localFileSystem
6161

6262
let sources = path.appending(components: "Sources", "foo")
@@ -88,7 +88,7 @@ class PackageBuilderTests: XCTestCase {
8888
}
8989

9090
func testSymlinkedSourcesDirectory() throws {
91-
mktmpdir { path in
91+
try testWithTemporaryDirectory { path in
9292
let fs = localFileSystem
9393

9494
let sources = path.appending(components: "Sources")

0 commit comments

Comments
 (0)