Skip to content

[Batch mode] Restore -### functionality for batch-mode by extending OutputLevel. #14961

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 2 commits into from
Mar 6, 2018

Conversation

davidungar
Copy link
Contributor

The current implementation of the -### does not produce the right results for batch mode. This PR reimplements that drive option by extended the OutputLevel enumeration in the driver. It reuses the machinery that is already there.

@davidungar davidungar requested review from graydon, jrose-apple and abertelrud and removed request for abertelrud March 4, 2018 04:52
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar davidungar force-pushed the PR-18-10-HHH branch 4 times, most recently from d60eb6e to 524e59c Compare March 4, 2018 21:23
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

At least one of these tests is failing because -### printing to stdout, but with these changes, it prints to stderr. I'm assuming that I need to fix this to preserve the old behavior.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@graydon graydon left a comment

Choose a reason for hiding this comment

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

LGTM

@davidungar
Copy link
Contributor Author

davidungar commented Mar 5, 2018

@jrose-apple I’m assuming you want to look at this, let me know if not.

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.

Nice, glad it worked out this easily. Can you add a test for it doing the right thing with batch mode?

if (Level == OutputLevel::Verbose)
Cmd->printCommandLine(llvm::errs());
switch (Level) {
case OutputLevel::Normal:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: accidentally-indented cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tx. I'm on it! And will do a test, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indentation fixed! On to the test.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

//
// CHECK-COMBINED: -primary-file {{.*}}/file-01.swift -primary-file {{.*}}/file-02.swift {{.*}}/file-03.swift {{.*}}/main.swift
//
// CHECK-ANYTHING-NOT: {{.+}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you're not using this anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch. Removed.

//
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -driver-print-jobs | %FileCheck %s -check-prefix=CHECK-COMBINED
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -### | %FileCheck %s -check-prefix=CHECK-COMBINED
// RUN: %swiftc_driver -enable-batch-mode -driver-print-jobs -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift 2>%t/shouldBeEmpty >/dev/null && test -z `cat %t/shouldBeEmpty`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the implementation, it is important to get -### to output on the expected file descriptor. Many existing tests depend on it. So I test for the right output on the right fd, and for no output on the wrong fd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other output flags write on the other fd.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh, I missed that. Maybe leave a comment? Or just do one invocation that writes both output streams to separate files, which makes it more obvious that they're being treated differently.

// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -driver-print-jobs | %FileCheck %s -check-prefix=CHECK-COMBINED
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -### | %FileCheck %s -check-prefix=CHECK-COMBINED
// RUN: %swiftc_driver -enable-batch-mode -driver-print-jobs -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift 2>%t/shouldBeEmpty >/dev/null && test -z `cat %t/shouldBeEmpty`
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -### 2>%t/shouldBeEmpty > /dev/null && test -z `cat %t/shouldBeEmpty`
Copy link
Contributor

Choose a reason for hiding this comment

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

Please put quotes around the sub-command, so that the argument doesn't get dropped entirely with a different shell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Thanks.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

davidungar commented Mar 6, 2018

I've added a comment to explain the test better; it did need it, thanks. Also streamlined the test.
Edit: looks like I hadn't pushed it, till just now (7:15 PM).

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@jrose-apple Thanks!

@davidungar davidungar merged commit 90d2740 into swiftlang:master Mar 6, 2018
@davidungar davidungar deleted the PR-18-10-HHH branch March 6, 2018 17:54
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.

3 participants