-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Tests: make FileCheck a substitution that sanitizes the input #4187
Conversation
@tkremenek Would you mind reviewing? |
be0e85b
to
cc79e5c
Compare
@swift-ci Please test |
If FileCheck is going to be a substitution, it really should have |
Also, what if the path to the source dir contains regex metacharacters, or |
This is a massive change to all tests, is it actually worth it? I tried making it, but then ended up reverting it because the resulting patch was huge and the percent sign didn't seem provide enough benefit for the reader of the RUN line. Seeing I don't have a strong preference here, just wanted to hear your thoughts about it. |
Good point. I'll escape them. |
I feel very strongly that anything without a % should work when you write the equivalent thing on the command line. The way we get around the "raw" bit is to have another substitution for " FileCheck " that produces an error; you can see that in action in lit.cfg. If someone really wants the raw one, they can then quote it. |
lit already does some pretty serious command-line parsing, I think; I don't think it's too weird for it to substitute "plaintext" commands, especially since that will be reflected in its logged command lines. Although maybe we should ask @ddunbar. If we create a subtle difference between FileCheck and %FileCheck, we're just going to end up with this bug duplicated incrementally. |
I don't think that's true. lit's command-line parsing has only gotten more shell-like over the years. And nobody complains about a subtle difference between |
That's not a subtle difference, then. |
Right, as I said above we should do the same for FileCheck. |
My $0.02:
|
Ah, I'm actually against expanding |
What is your objection to expanding |
I like being able to read both the initial RUN lines and what lit spits out. But maybe I lost that battle already. |
FWIW I very frequently need to read and understand the RUN line's full expansion. I'm constantly manually breaking tests just to find out what the actual run line is. I don't want that process to get any worse. |
For that last, I'd actually like to add a mode to lit where it just dumps run lines and doesn't run tests. checks |
Debugging a failure for me usually starts with understanding exactly how the test was invoked. I often want to reduce it to a smaller command line, smaller test case, and run lldb. |
That would be a great idea, and shouldn't actually be very hard. The existing --no-execute isn't very useful (I used it for perf timing, but that doesn't deserve that command line arg spelling). |
cc79e5c
to
123e076
Compare
stdin = sys.stdin.read() | ||
for s in args.sanitize_strings: | ||
replacement, pattern = s.split('=', 1) | ||
stdin = stdin.replace(pattern, replacement) |
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.
Seems expensive to do this in-memory rather than via pipe, but we can add that later.
279a2dc
to
6d313b0
Compare
@jrose-apple I have addressed your comments:
|
@swift-ci Please test |
The substitution is still in-memory, but that's probably fine for now. Thanks, Dmitri! |
Just caught up on this. I think this is a great addition. |
OS X failed with a SwiftPM failure in @swift-ci Please smoke test OS X platform |
@swift-ci Please smoke test OS X platform |
@swift-ci Please test OS X platform |
SceneKit_test.swift failures look unrelated. Will retry tomorrow, maybe the CI will be in a better state. |
'%FileCheck' removes absolute paths of the source and build directory from the input. Overwhelming majority of tests don't intend to match these paths. Also add a substitution '%raw-FileCheck' that does not sanitize the input.
This reverts commit 02039a1. With the new `%FileCheck` substitution that removess full paths to the build directory from FileCheck inputs, this workaround is no longer needed.
6d313b0
to
94c7c3a
Compare
Resolved conflicts and rebased. Retrying. |
@swift-ci Please smoke test OS X platform |
@swift-ci Please test OS X platform |
Tested locally on Linux, tests pass. |
macOS passed on CI, merging! |
Resolve conflicts with upstream `main`
In the Swift testsuite, FileCheck is used to check for (or for absence of) fixed strings in the input. It is not an issue when the string is long and complex (e.g., a full SIL instruction). But sometimes the string is a common word (e.g., 'sdk' or 'branch'). Tests that use such patterns are known break when the path to the build directory contains these words.
This change makes
%FileCheck
a lit substitution that replaces paths to source and build directories with fixed strings.Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
A smoke test on macOS does the following:
device standard libraries are not built.
version of these tests are not run.
A smoke test on Linux does the following:
tests are not run.
Validation Testing
Lint Testing
Note: Only members of the Apple organization can trigger swift-ci.