-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Add "modes" to compiletest, for running all tests with NLL enabled and comparing with master #48879
Comments
I'm marking this as belonging to both @rust-lang/wg-compiler-nll and @rust-lang/wg-traits -- this is because we are both going to need this tool! In general, having a mode like this will be useful anytime that we plan to make major alterations to some core component of the system. |
Mentoring instructionsI'm going to assume we will use a command line option to drive this new mode. Let's call "compare-mode". Then we can run the tests with rust/src/tools/compiletest/src/main.rs Line 58 in fedce67
So we have to extend rust/src/tools/compiletest/src/main.rs Line 68 in fedce67
That comparison mode will be translated to some arguments to rustc. Those arguments are arranged in this function: rust/src/tools/compiletest/src/runtest.rs Line 1584 in fedce67
Probably it's best we allow a mapping between the comparison mode and the arguments (that mapping can just be hardcoded into this function though). For example, NLL at least currently really wants three flags added:
This is where the code currently finds the expected files. We'll want to alter these functions to take the comparison mode into account. That's probably a new option to be added, along with revision. rust/src/tools/compiletest/src/runtest.rs Lines 2504 to 2508 in fedce67
Right now, if the revision is Anyway, we'll have to alter this to search for the expected output with the given mode and -- if not found -- to then try with a mode of Finally, to skip checking for rust/src/tools/compiletest/src/runtest.rs Lines 2548 to 2554 in fedce67
Uuuuh at that point we are basically done with the compiletest changes, right? Then the last step is to alter tidy to enforce the FIXME convention, but I don't know much about that. We'll figure that out when we get there. |
Edit: Disregard, that was #48878. |
@kennytm this is different interface from revisions. Revisions are encoded with flags on a test by test basis. A mode is given more privileged status within (There's some chance that code might be shared within |
I think though we will eventually want to specify the intersection of the "comparison mode" with a revision. There are a lot of tests that are already encoded with |
I'd like to try this one. :) |
@memoryleak47 that would be super duper. @pnkfelix and I were just saying that this remains pretty high priority. Let me know if I can help in any way. (Of course there are already mentoring instructions.) |
… r=pnkfelix Add compiletest `--compare-mode nll` option Before implementing the tidy stuff, I'd appreciate if someone reviews the changes so far. This is my first non-trivial pull request, so I could really use some feedback. :) closes #48879. r? @nikomatsakis
I'm going to actually reopen this issue as a way to track when we've gotten this compare-mode into a state where we actually have files checked in that we are referencing against. (I just discovered that tidy complains about a It might be good to even keep this issue open until we have bors set up to be running |
Tidy fix is #49844 |
…tsakis Blindly checkpoint status of NLL mode ui tests This takes the next (and potentially final?) step with #48879. Namely, this PR got things to the point where I can successfully run `compiletest` on `src/test/ui` with `--compile-mode=nll`. Here are the main pieces of it: 1. To figure out how to even run `compiletest` normally on the ui directory, I ran `x.py test -vv`, and then looked for the `compiletest` invocation that mentioned `src/test/ui`. 2. I took the aforementioned `compiletest` invocation and used it, adding `--compile-mode=nll` to the end. It had 170 failing cases. 3. Due to #49855, I had to edit some of the tests so that they fail even under NLL, via `#[rustc_error]`. That's the first commit. (Then goto 2 to double-check no such tests remain.) 4. I took the generated `build/target/test/foo.stderr` file for every case that failed, and blindly copied it to `src/test/foo.nll.stderr`. That's the second commit. 5. Goto 2 until there were no failing cases. 6. Remove any stamp files, and re-run `x.py test` to make sure that the edits and new `.nll.stderr` files haven't broken the pre-existing test suite.
…tsakis Add src/test/ui regression testing for NLL This PR changes `x.py test` so that when you are running the `ui` test suite, it will also always run `compiletest` in the new `--compare-mode=nll`, which just double-checks that when running under the experimental NLL mode, the output matches the `<source-name>.nll.stderr` file, if present. In order to reduce the chance of a developer revolt in response to this change, this PR also includes some changes to make the `--compare-mode=nll` more user-friendly: 1. It now generates nll-specific .stamp files, and uses them (so that repeated runs can reuse previously cached results). 2. Each line of terminal output distinguishes whether we are running under `--compare-mode=nll` by printing with the prefix `[ui (nll)]` instead of just the prefix `[ui]`. Subtask of #48879
I think we can call this done for now until we have a concrete extension in mind. |
namely @nikomatsakis and @pnkfelix agreed that any remaining work here is best spent on resolving #44844 (plus porting the |
In particular closed in favor of #44844 |
The NLL team has been trying to find a good workflow for evaluating the discrepancies between AST borrowck and NLL-based borrowck.
-Z borrowck=compare
and the https://github.com/pnkfelix/nll-probe tool, but here I'm going to try to avoid a deep dive into how those have failed to satisfy our needs.Our goal here: We want a way to track the current state of NLL, including the cases where there are known deviations, in a manner that allows immediate analysis of that state to determine things like:
Here's a new proposal for a (hopefully) relatively small change to
compiletest
that should yield an easier workflow to answer questions like those above, at least for theui/
subset of our tests.ui/
tests are set up so that each test consists of an input$file.rs
, and a set of expected outputs in$file.stderr
(compilation error messages) and$file.stdout
(non erroneous compiler output; rarely used). (For more info, see this chapter in the rustc-guide.)compiletest
, encoded either as a command line parameter or as an environment variable, or both. (The first mode we'll support will be "nll", which tellscompiletest
to pass-Z nll
in addition to any other flags when invokingrustc
, at least for theui/
tests).$file.$mode.stderr
file, then this file will be used as the source of "acceptable output". If there is no such file, thencompiletest
will fallback to the regular filename$file.stderr
.//~ ERROR
that indicate what error is expected on which line (these are mildly redundant with the stderr files above). Because messages may differ in the mode M, but we don't want to edit the sources too much, compiletest should just ignore the//~ ERROR
annotations when running in a particular mode. We will still see the errors that occur from the stderr output, it's just less convenient.$file.$mode.stderr
, then some tool (probablycompiletest
, but maybetidy
?) will be responsible to checking that$file.rs
somewhere contains a comment that explains the source of the discrepancy. This could be a specially formatted FIXME, if the new behavior seems worse than before:// $mode FIXME(#123) -- summary of discrepancy caused by NLL bug with corresponding issue num
or a "YAYME" comment for when the new behavior is an improvement:
// $mode YAYME(#123) -- summary of a beneficial discrepancy
(presumably the ticket linked by YAYME would just be the tracking issue for NLL or whatever other mode is being tested).
Benefits of the proposed system:
ls *.nll.stderr
diff onetest.stderr onetest.nll.stderr
*.$mode.stderr
files.Open Questions (to be resolved by implementor)
compiletest
do about occurrences of//~ ERROR
in the source text? In particular, should it check that the error output still has those cases, even when running under a given mode?compiletest
to ignore the//~ ERROR
annotations when running under a given mode. The reasoning here is this: the//~ ERROR
annotations will already get checked by compiletest runs that don't have a mode. We probably don't want to force an error when there's a discrepancy when running under a given mode; any discrepancies, including any of those errors disappearing, should be accounted for in the linked// $mode FIXME/YAYME
issue, and we want to allow them to disappear or differ.The text was updated successfully, but these errors were encountered: