Skip to content

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

Merged
merged 1 commit into from
Feb 23, 2019

Conversation

gmittert
Copy link
Contributor

All Driver/Dependency tests now pass on Windows!

Requires #22596

-- Testing: 52 of 4486 tests, 12 threads --                                                                                   
Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..                                                                    
Testing Time: 150.70s                                                                                                         
  Expected Passes    : 43                                                                                                     
  Expected Failures  : 2                                                                                                      
  Unsupported Tests  : 7 

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

Copy link
Contributor

@jrose-apple jrose-apple left a 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.

@@ -56,7 +58,7 @@ public:

bool TaskQueue::supportsBufferingOutput() {
// The default implementation does not support buffering output.
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

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?

SmallVector<Optional<StringRef>, 3> redirects;
redirects.push_back(llvm::None);
redirects.push_back(Optional<StringRef>(stdoutFile));
redirects.push_back(Optional<StringRef>(stderrFile));
Copy link
Contributor

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.)

Copy link
Contributor Author

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)) {
Copy link
Contributor

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?

Copy link
Contributor Author

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()?

Copy link
Contributor

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.


StringRef stdoutContents =
stdoutBuffer ? StringRef(stdoutBuffer.get()->getBufferStart(),
stdoutBuffer.get()->getBufferSize())
Copy link
Contributor

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(). :-)

@gmittert
Copy link
Contributor Author

Cleaned up both the code and the temp files!

@@ -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;
Copy link
Contributor

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!

@gmittert
Copy link
Contributor Author

TIL, list initialization is really neat.

     SmallVector<Optional<StringRef>, 4> redirects = {None, {stdoutPath}, {stderrPath}};

They did need the extra braces though, clang wasn't able to go from the stdoutPath: SmallString directly to Optional

llvm::sys::RemoveFileOnSignal(stdoutPath);
llvm::sys::RemoveFileOnSignal(stderrPath);

SmallVector<Optional<StringRef>, 4> redirects = {None, {stdoutPath}, {stderrPath}};
Copy link
Contributor

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}};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@jrose-apple
Copy link
Contributor

(not running full tests because the code being changed isn't used on POSIXy platforms…)

@swift-ci Please smoke test

@jrose-apple jrose-apple self-assigned this Feb 20, 2019
@jrose-apple
Copy link
Contributor

Oops, I forgot that this one requires the other one.

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test

@jrose-apple
Copy link
Contributor

Looks like something's not quite right even after merging the other PR. Can you take a look?

@gmittert
Copy link
Contributor Author

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...

13:39:28 --
13:39:28 Exit Code: 1
13:39:28 
13:39:28 Command Output (stdout):
13:39:28 --
13:39:28 /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/test-macosx-x86_64/Driver/Output/filelists.swift.tmp/tmp/outputs-bee66b
13:39:28 /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/test-macosx-x86_64/Driver/Output/filelists.swift.tmp/tmp/sources-7c25b1
13:39:28 /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/test-macosx-x86_64/Driver/Output/filelists.swift.tmp/tmp-crash/outputs-ce9afc
13:39:28 /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/test-macosx-x86_64/Driver/Output/filelists.swift.tmp/tmp-crash/sources-f43471
13:39:28 
13:39:28 --
13:39:28 Command Output (stderr):
13:39:28 --
13:39:28 ls: /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/test-macosx-x86_64/Driver/Output/filelists.swift.tmp/tmp-fail/sources-*: No such file or directory
13:39:28 ls: /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/test-macosx-x86_64/Driver/Output/filelists.swift.tmp/tmp-fail/outputs-*: No such file or directory
13:39:28 

<unknown>:0: error: compile command failed due to signal 9 (use -v to see invocation)
13:39:28 
/Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/test/Driver/filelists.swift:68:16: error: CHECK-LINK: expected string not found in input
13:39:28 // CHECK-LINK: Handled link
13:39:28                ^
13:39:28 <stdin>:1:1: note: scanning from here
13:39:28 Handled a.swift
13:39:28 ^

@jrose-apple
Copy link
Contributor

…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!
@gmittert
Copy link
Contributor Author

Reverted the filelists.swift changes. Let's see if it's happier now.

@compnerd
Copy link
Member

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ac0d9ef

@compnerd
Copy link
Member

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ac0d9ef

@gmittert
Copy link
Contributor Author

Build failed
Swift Test OS X Platform
Git Sha - ac0d9ef

Same as the previous run, During iphone simulator tests:
xcodebuild: error: The authorization was denied since no user interaction was possible.

@jrose-apple
Copy link
Contributor

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

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ac0d9ef

@jrose-apple
Copy link
Contributor

@swift-ci Please test macOS

@compnerd
Copy link
Member

Yay, gonna merge this, as this prevents the test harness from dying!

@compnerd compnerd merged commit 1a949ea into swiftlang:master Feb 23, 2019
@compnerd compnerd mentioned this pull request Feb 23, 2019
@gmittert gmittert deleted the DrivingProgress branch February 23, 2019 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants