Skip to content

Commit de8eb4f

Browse files
committed
Introduce an egregious hack to work around older CI toolchains
Blame Owen for the evil genius of this hack, me for trying to put it in
1 parent 3d7cac5 commit de8eb4f

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

Tests/CommandsTests/PackageCommandTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,13 +1953,13 @@ final class PackageCommandTests: CommandsTestCase {
19531953

19541954
try fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
19551955
func runPlugin(flags: [String], diagnostics: [String], completion: (String, String) -> Void) throws {
1956-
let (stdout, stderr) = try SwiftPM.Package.execute(flags + ["print-diagnostics"] + diagnostics, packagePath: fixturePath)
1956+
let (stdout, stderr) = try SwiftPM.Package.execute(flags + ["print-diagnostics"] + diagnostics, packagePath: fixturePath, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
19571957
completion(stdout, stderr)
19581958
}
19591959

19601960
// Diagnostics.error causes SwiftPM to return a non-zero exit code, but we still need to check stdout and stderr
19611961
func runPluginWithError(flags: [String], diagnostics: [String], completion: (String, String) -> Void) throws {
1962-
XCTAssertThrowsError(try SwiftPM.Package.execute(flags + ["print-diagnostics"] + diagnostics, packagePath: fixturePath)) { error in
1962+
XCTAssertThrowsError(try SwiftPM.Package.execute(flags + ["print-diagnostics"] + diagnostics, packagePath: fixturePath, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])) { error in
19631963
guard case SwiftPMError.executionFailure(_, let stdout, let stderr) = error else {
19641964
return XCTFail("invalid error \(error)")
19651965
}
@@ -2151,28 +2151,28 @@ final class PackageCommandTests: CommandsTestCase {
21512151

21522152
// Check than nothing is echoed when echoLogs is false
21532153
try fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
2154-
let (stdout, stderr) = try SwiftPM.Package.execute(["print-diagnostics", "build"], packagePath: fixturePath)
2154+
let (stdout, stderr) = try SwiftPM.Package.execute(["print-diagnostics", "build"], packagePath: fixturePath, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
21552155
XCTAssertMatch(stdout, isEmpty)
21562156
XCTAssertMatch(stderr, isEmpty)
21572157
}
21582158

21592159
// Check that logs are returned to the plugin when echoLogs is false
21602160
try fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
2161-
let (stdout, stderr) = try SwiftPM.Package.execute(["print-diagnostics", "build", "printlogs"], packagePath: fixturePath)
2161+
let (stdout, stderr) = try SwiftPM.Package.execute(["print-diagnostics", "build", "printlogs"], packagePath: fixturePath, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
21622162
XCTAssertMatch(stdout, containsLogtext)
21632163
XCTAssertMatch(stderr, isEmpty)
21642164
}
21652165

21662166
// Check that logs echoed to the console (on stderr) when echoLogs is true
21672167
try fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
2168-
let (stdout, stderr) = try SwiftPM.Package.execute(["print-diagnostics", "build", "echologs"], packagePath: fixturePath)
2168+
let (stdout, stderr) = try SwiftPM.Package.execute(["print-diagnostics", "build", "echologs"], packagePath: fixturePath, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
21692169
XCTAssertMatch(stdout, isEmpty)
21702170
XCTAssertMatch(stderr, containsLogecho)
21712171
}
21722172

21732173
// Check that logs are returned to the plugin and echoed to the console (on stderr) when echoLogs is true
21742174
try fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
2175-
let (stdout, stderr) = try SwiftPM.Package.execute(["print-diagnostics", "build", "printlogs", "echologs"], packagePath: fixturePath)
2175+
let (stdout, stderr) = try SwiftPM.Package.execute(["print-diagnostics", "build", "printlogs", "echologs"], packagePath: fixturePath, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
21762176
XCTAssertMatch(stdout, containsLogtext)
21772177
XCTAssertMatch(stderr, containsLogecho)
21782178
}
@@ -2465,14 +2465,14 @@ final class PackageCommandTests: CommandsTestCase {
24652465

24662466
// Check arguments
24672467
do {
2468-
let (stdout, stderr) = try SwiftPM.Package.execute(["plugin", "MyPlugin", "--foo", "--help", "--version", "--verbose"], packagePath: packageDir)
2468+
let (stdout, stderr) = try SwiftPM.Package.execute(["plugin", "MyPlugin", "--foo", "--help", "--version", "--verbose"], packagePath: packageDir, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
24692469
XCTAssertMatch(stdout, .contains("success"))
24702470
XCTAssertEqual(stderr, "")
24712471
}
24722472

24732473
// Check default command arguments
24742474
do {
2475-
let (stdout, stderr) = try SwiftPM.Package.execute(["MyPlugin", "--foo", "--help", "--version", "--verbose"], packagePath: packageDir)
2475+
let (stdout, stderr) = try SwiftPM.Package.execute(["MyPlugin", "--foo", "--help", "--version", "--verbose"], packagePath: packageDir, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
24762476
XCTAssertMatch(stdout, .contains("success"))
24772477
XCTAssertEqual(stderr, "")
24782478
}

Tests/FunctionalTests/MiscellaneousTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ class MiscellaneousTestCase: XCTestCase {
665665

666666
func testRootPackageWithConditionals() throws {
667667
try fixture(name: "Miscellaneous/RootPackageWithConditionals") { path in
668-
let (_, stderr) = try SwiftPM.Build.execute(packagePath: path)
668+
let (_, stderr) = try SwiftPM.Build.execute(packagePath: path, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
669669
let errors = stderr.components(separatedBy: .newlines).filter { !$0.contains("[logging] misuse") && !$0.isEmpty }
670670
XCTAssertEqual(errors, [], "unexpected errors: \(errors)")
671671
}

Tests/FunctionalTests/PluginTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ final class PluginTests: XCTestCase {
227227
let pathOfGeneratedFile = packageDir.appending(components: [".build", "plugins", "outputs", "mypackage", "SomeTarget", "Plugin", "best.txt"])
228228

229229
try createPackageUnderTest(packageDir: packageDir, toolsVersion: .v5_9)
230-
let (_, stderr) = try executeSwiftBuild(packageDir)
230+
let (_, stderr) = try executeSwiftBuild(packageDir, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
231231
XCTAssertTrue(stderr.contains("warning: Build tool command 'empty' (applied to target 'SomeTarget') does not declare any output files"), "expected warning not emitted")
232232
XCTAssertFalse(localFileSystem.exists(pathOfGeneratedFile), "plugin generated file unexpectedly exists at \(pathOfGeneratedFile.pathString)")
233233

234234
try createPackageUnderTest(packageDir: packageDir, toolsVersion: .v6_0)
235-
let (_, stderr2) = try executeSwiftBuild(packageDir)
235+
let (_, stderr2) = try executeSwiftBuild(packageDir, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
236236
XCTAssertEqual("", stderr2)
237237
XCTAssertTrue(localFileSystem.exists(pathOfGeneratedFile), "plugin did not run, generated file does not exist at \(pathOfGeneratedFile.pathString)")
238238
}

Tests/FunctionalTests/ResourcesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class ResourcesTests: XCTestCase {
157157
try localFileSystem.createDirectory(resource.parentDirectory, recursive: true)
158158
try localFileSystem.writeFileContents(resource, string: "best")
159159

160-
let (_, stderr) = try executeSwiftBuild(packageDir, env: ["DYLD_PRINT_SEARCHING": "1"])
160+
let (_, stderr) = try executeSwiftBuild(packageDir, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
161161
// Filter some unrelated output that could show up on stderr.
162162
let filteredStderr = stderr.components(separatedBy: "\n").filter { !$0.contains("[logging]") }.joined(separator: "\n")
163163
XCTAssertEqual(filteredStderr, "", "unexpectedly received error output: \(stderr)")

0 commit comments

Comments
 (0)