Skip to content

Add compiler diagnostics to a test that sometimes fails in CI #3424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Tests/FunctionalTests/MiscellaneousTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -518,29 +518,30 @@ class MiscellaneousTestCase: XCTestCase {
}

func testEnableTestDiscoveryDeprecation() throws {
let compilerDiagnosticFlags = ["-Xswiftc", "-Xfrontend", "-Xswiftc", "-Rmodule-interface-rebuild"]
#if canImport(Darwin)
// should emit when LinuxMain is present
fixture(name: "Miscellaneous/TestDiscovery/Simple") { path in
let (_, stderr) = try SwiftPMProduct.SwiftTest.execute(["--enable-test-discovery"], packagePath: path)
let (_, stderr) = try SwiftPMProduct.SwiftTest.execute(["--enable-test-discovery"] + compilerDiagnosticFlags, packagePath: path)
XCTAssertMatch(stderr, .contains("warning: '--enable-test-discovery' option is deprecated"))
}

// should emit when LinuxMain is not present
fixture(name: "Miscellaneous/TestDiscovery/Simple") { path in
try localFileSystem.writeFileContents(path.appending(components: "Tests", SwiftTarget.testManifestNames.first!), bytes: "fatalError(\"boom\")")
let (_, stderr) = try SwiftPMProduct.SwiftTest.execute(["--enable-test-discovery"], packagePath: path)
let (_, stderr) = try SwiftPMProduct.SwiftTest.execute(["--enable-test-discovery"] + compilerDiagnosticFlags, packagePath: path)
XCTAssertMatch(stderr, .contains("warning: '--enable-test-discovery' option is deprecated"))
}
#else
// should emit when LinuxMain is present
fixture(name: "Miscellaneous/TestDiscovery/Simple") { path in
let (_, stderr) = try SwiftPMProduct.SwiftTest.execute(["--enable-test-discovery"], packagePath: path)
let (_, stderr) = try SwiftPMProduct.SwiftTest.execute(["--enable-test-discovery"] + compilerDiagnosticFlags, packagePath: path)
XCTAssertMatch(stderr, .contains("warning: '--enable-test-discovery' option is deprecated"))
}
// should not emit when LinuxMain is present
fixture(name: "Miscellaneous/TestDiscovery/Simple") { path in
try localFileSystem.writeFileContents(path.appending(components: "Tests", SwiftTarget.testManifestNames.first!), bytes: "fatalError(\"boom\")")
let (_, stderr) = try SwiftPMProduct.SwiftTest.execute(["--enable-test-discovery"], packagePath: path)
let (_, stderr) = try SwiftPMProduct.SwiftTest.execute(["--enable-test-discovery"] + compilerDiagnosticFlags, packagePath: path)
XCTAssertNoMatch(stderr, .contains("warning: '--enable-test-discovery' option is deprecated"))
}
#endif
Expand Down