-
Notifications
You must be signed in to change notification settings - Fork 207
Ensure temp dir is different between testIncremental and testIncrementalDiagnostics to see if that fixes the test breakage in CI #374
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
Conversation
…talDiagnostics to see if that fixes the test breakage in CI
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a better way to do this that avoids having to use #line
and remembering to call prepare
on new tests:
We can keep the setUp
method in place and use the self.name
XCTestCase
property for the prefix on withTemporaryDirectory
. This name
property will have the format that, for a given test, looks like this:
"-[IncrementalCompilationTests testIncrementalDiagnostics]"
self.name
docs:
https://developer.apple.com/documentation/xctest/xctest/1500990-name
@@ -357,12 +358,12 @@ final class IncrementalCompilationTests: XCTestCase { | |||
|
|||
// FIXME: why does it fail on Linux in CI? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stale comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for reviewing so quickly. Nice catch!
What about removing the setup all together and wrapping the tests in withTemporaryDirectory. Has the additional benefit of deleting the folder after the test completes. |
@swift-ci please test |
I like your idea! I found a refinement, of overriding the constructor, so that tempDir can be constant. Thanks. |
Thanks for looking at this. Even if setup is removed, all that stuff has to go somewhere. Somehow it seems easier to factor this way. And there is a deinit to rm the temp dir. |
Okay, yeah these tests you would have to pass the temp directory through quite a few layers, so this approach is definitely easier. Normally I think the closure approach is superior. We use it in other places. func testInputModifiedDuringSingleJobBuild() throws {
try withTemporaryDirectory { path in
let main = path.appending(component: "main.swift")
try localFileSystem.writeFileContents(main) {
$0 <<< "let foo = 1"
}
var driver = try Driver(args: ["swift", main.pathString])
let jobs = try driver.planBuild()
XCTAssertTrue(jobs.count == 1 && jobs[0].requiresInPlaceExecution)
// Change the file
try localFileSystem.writeFileContents(main) {
$0 <<< "let foo = 1"
}
XCTAssertThrowsError(try driver.run(jobs: jobs)) {
XCTAssertEqual($0 as? Job.InputError,
.inputUnexpectedlyModified(TypedVirtualPath(file: .absolute(main), type: .swift)))
}
}
} |
@swift-ci please test |
Thanks, @artemcm |
Best theory to explain a mysterious test failure on CI Linux. Land it and if test starts failing, disable the test again.