-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fixed Driver Dependency Tests on Windows #22638
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
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.
Clever! But I'm worried about the files being left behind on the filesystem—we'll have to do something about that.
lib/Basic/Default/TaskQueue.inc
Outdated
@@ -56,7 +58,7 @@ public: | |||
|
|||
bool TaskQueue::supportsBufferingOutput() { | |||
// The default implementation does not support buffering output. |
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.
Comment needs updating!
@@ -14,7 +16,7 @@ | |||
// CHECK-FIRST: {{^{$}} | |||
// CHECK-FIRST: "kind": "finished" | |||
// CHECK-FIRST: "name": "compile" | |||
// CHECK-FIRST: "output": "Handled main.swift\n" | |||
// CHECK-FIRST: "output": "Handled main.swift" |
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.
Why the change in behavior here?
@@ -14,7 +16,7 @@ | |||
// CHECK-FIRST: {{^{$}} | |||
// CHECK-FIRST: "kind": "finished" | |||
// CHECK-FIRST: "name": "compile" | |||
// CHECK-FIRST: "output": "Handled main.swift\n" | |||
// CHECK-FIRST: "output": "Handled main.swift{{\r?}}\n" |
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.
This backslash isn't going to bind correctly, is it?
lib/Basic/Default/TaskQueue.inc
Outdated
SmallVector<Optional<StringRef>, 3> redirects; | ||
redirects.push_back(llvm::None); | ||
redirects.push_back(Optional<StringRef>(stdoutFile)); | ||
redirects.push_back(Optional<StringRef>(stderrFile)); |
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.
No need to do any of this type conversion, or to use a SmallVector instead of a plain array. There's an implicit conversion from SmallString (a subclass of SmallVector) to StringRef, and from StringRef to Optional<StringRef>. So you should be able to just pass stdoutPath
and stderrPath
directly here. (We've also brought None into scope, so you don't need the llvm::
qualification.)
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.
That way is much more pleasant!
llvm::SmallVector<char, 64> stdoutPath; | ||
llvm::SmallVector<char, 64> stderrPath; | ||
if (fs::createTemporaryFile("stdout", "tmp", stdoutPath) | ||
|| fs::createTemporaryFile("stderr", "tmp", stderrPath)) { |
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.
This is clever, but what deletes the files after the run is finished?
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.
Hrm, I think ideally it would register with the compilation via addTemporaryFile
but that would involve passing the compilation context all the way down which seem unideal. Would just removing the temp files after calling the callback be reasonable? Perhaps also registering with RemoveFileOnSignal()
?
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.
:-/ Maybe? I suppose we don't expect them to be so big (on the offchance we can't clean them up), and they are going to be in a system temporary directory.
lib/Basic/Default/TaskQueue.inc
Outdated
|
||
StringRef stdoutContents = | ||
stdoutBuffer ? StringRef(stdoutBuffer.get()->getBufferStart(), | ||
stdoutBuffer.get()->getBufferSize()) |
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.
This is just stdoutBuffer.get()->getBuffer()
. :-)
8c2c5b8
to
3c40d08
Compare
Cleaned up both the code and the temp files! |
lib/Basic/Default/TaskQueue.inc
Outdated
@@ -100,10 +103,27 @@ bool TaskQueue::execute(TaskBeganCallback Began, TaskFinishedCallback Finished, | |||
T->Env.empty() ? decltype(Envp)(None) | |||
: decltype(Envp)(llvm::toStringRefArray(T->Env.data())); | |||
|
|||
llvm::SmallVector<char, 64> stdoutPath; | |||
llvm::SmallVector<char, 64> stderrPath; |
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.
Ah, this is where to use SmallString, so that you don't need to explicitly make StringRefs later!
3c40d08
to
0c7303d
Compare
TIL, list initialization is really neat.
They did need the extra braces though, clang wasn't able to go from the stdoutPath: SmallString directly to Optional |
lib/Basic/Default/TaskQueue.inc
Outdated
llvm::sys::RemoveFileOnSignal(stdoutPath); | ||
llvm::sys::RemoveFileOnSignal(stderrPath); | ||
|
||
SmallVector<Optional<StringRef>, 4> redirects = {None, {stdoutPath}, {stderrPath}}; |
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.
Last nitpick: This repo has an 80-column limit. But you can solve that anyway by using a plain fixed-sized array instead of a SmallVector.
Optional<StringRef> redirects[] = {None, {stdoutPath}, {stderrPath}};
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.
Fixed.
0c7303d
to
f78387b
Compare
(not running full tests because the code being changed isn't used on POSIXy platforms…) @swift-ci Please smoke test |
Oops, I forgot that this one requires the other one. |
@swift-ci Please smoke test |
Looks like something's not quite right even after merging the other PR. Can you take a look? |
I'm not entirely sure what happened. I'm unable to reproduce it on either a Linux (CentOS) or macOS machine locally. Is there something special about the Jenkins environment that I should know about? The expected stdout and stderr look okay: the ls error is expected, but fake-ld.py never ran. The test overrides ld with fake-ld.py then expects swift to call it which then does a few assertions and prints out "Handled link" It seems like one of the tasks the driver spawned got killed before fake-ld was able to print...
|
…Well, I don't get it either, but to not block this PR, how about you just revert the changes to test/Driver/filelists.swift for now? The test is still using symlinks so it's already marked unsupported on win32. |
All Driver/Dependency Tests now pass on Windows!
f78387b
to
ac0d9ef
Compare
Reverted the filelists.swift changes. Let's see if it's happier now. |
@swift-ci please test |
Build failed |
@swift-ci please test macOS platform |
Build failed |
Same as the previous run, During iphone simulator tests: |
That might have been an Xcode update. Let's try one more time. (If not, it's a test change again and we'll have to figure out why.) @swift-ci Please test macOS |
Build failed |
@swift-ci Please test macOS |
Yay, gonna merge this, as this prevents the test harness from dying! |
All Driver/Dependency tests now pass on Windows!
Requires #22596
The two expected failures are due to tests which expect parallel execution. The unsupported tests are due to the use of
$(subshells)
, mostly to get the version of swift compiler that is running.As part of this, I've also implemented output buffering for the default TaskQueue implementation since it was required for a few of the tests. Are there platforms besides Windows that use the default implementation that I need to be aware of? @compnerd had mentioned rewriting the Windows TasksQueue implementation so that it supports parallel execution soon, so this might be a temporary thing anyways.
@jrose-apple