Skip to content
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

Fix revision support for UI tests. #49812

Merged
merged 2 commits into from
Apr 24, 2018
Merged

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Apr 9, 2018

Fixes #48878

@ehuss
Copy link
Contributor Author

ehuss commented Apr 9, 2018

cc @nikomatsakis

I tried to make the code a little more explicit and cleaner to avoid confusion, though I'm not sure I succeeded. :) Everything should work the same as before, except UI tests can now output TESTNAME.REVISION.stderr/stdout files.

In order to generate the output for a test with multiple revisions, you have to run compiletest separately for each revision because it stops immediately when a revision fails. There doesn't seem to be the equivalent of --no-fail-fast for compiletest. Thoughts?

@nikomatsakis
Copy link
Contributor

r? @nikomatsakis

@nikomatsakis
Copy link
Contributor

@ehuss

In order to generate the output for a test with multiple revisions, you have to run compiletest separately for each revision because it stops immediately when a revision fails. There doesn't seem to be the equivalent of --no-fail-fast for compiletest. Thoughts?

Hmm, one idea would be to fix #47604 -- @spastorino got most of the way there in #48023, but got entangled in some of the mess that you're sorting out in this PR. A side-effect of this change would be that each revision is its own test, so they would all run independently of a failure.

if !file_path.with_file_name(testname)
.with_extension("rs")
.exists() {
println!("Stray file with UI testing output: {:?}", file_path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Grabbing everything up to first dot to derive the source file name sounds like a reasonable start to me.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

On second read, I'm perhaps confused.

.with_extension(&self.config.stage_id)
}

fn output_base_name_stage(&self) -> PathBuf {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this returns foo/bar.stage1, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stage also includes the platform triple (like foo/bar.stage1-x86_64-apple-darwin). That is...a little confusing. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

ok -- in any case I'd like to see a comment =)

@@ -2864,7 +2879,9 @@ impl<'test> TestCx<'test> {
}
}

let output_file = self.output_base_name().with_extension(kind);
let output_file = self.output_base_name()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we not want the stage here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. What are the arguments in favor of including the stage? Is it to guard against using the wrong cached results if you run x.py test --stage 1 and x.py test --stage 2 separately?

One issue is that update-references.sh won't know which stage to use. We could add that as another argument, and print the correct stage in the usage instructions.

Some of the other tests that don't include the stage may need to be updated as well. I was reluctant to do so because I don't fully understand the need and consequences.

Copy link
Contributor

Choose a reason for hiding this comment

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

What are the arguments in favor of including the stage?

The way I always imagined it, we use the stage/target data to effectively "isolate" stage1 and stage2 tests from one another completely. To be honest, I think we should be using separate directories altogether (i.e, src/test/stage1). I'm not sure why we don't, I think for no particularly good reason.

But you're right that I don't know what can go wrong in particular.

Copy link
Contributor

Choose a reason for hiding this comment

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

One issue is that update-references.sh won't know which stage to use. We could add that as another argument, and print the correct stage in the usage instructions.

Seems fair. We can leave as is for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we moved to ./x.py bless, then you could do ./x.py bless --stage 1 and so forth to specify the test suite that you ran. (Maybe it should be ./x.py test --bless? Anyway.)

@pietroalbini pietroalbini added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 10, 2018
@bors
Copy link
Contributor

bors commented Apr 11, 2018

☔ The latest upstream changes (presumably #49861) made this pull request unmergeable. Please resolve the merge conflicts.

@ehuss
Copy link
Contributor Author

ehuss commented Apr 11, 2018

@nikomatsakis I just wanted to confirm, what you'd like me to do in regards to the new NLL compare-mode changes. For this PR, I at least need to redo the tidy checks (cc @pnkfelix).

Long term do you want the output files to be $test.$rev.$mode.stderr (where rev and mode are optional)? The new tidy check might be a little aggressive since it can't handle $test.$rev.stderr.

AFAIK, compiletest currently doesn't handle generating output files with the $mode part (and update-references doesn't handle it either). I'm guessing updates to support that should be in another PR?

@nikomatsakis
Copy link
Contributor

@ehuss that does need to be decided =)

I think though it might be most practical if compare-mode=nll used an nll revision if available but otherwise used a kind of "default" revision.

@nikomatsakis
Copy link
Contributor

That is to say, I feel like 'compare-mode' might perhaps be better considered a kind of "automatic revision" that applies to every test which does not already have one. (And -- indeed -- perhaps revisions also want the same "failover" behavior for their stderr files? I guess that's the question.)

@pietroalbini pietroalbini added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 16, 2018
@bors
Copy link
Contributor

bors commented Apr 19, 2018

☔ The latest upstream changes (presumably #49900) made this pull request unmergeable. Please resolve the merge conflicts.

@ehuss
Copy link
Contributor Author

ehuss commented Apr 20, 2018

I think this is now working well with the latest NLL updates. With a sample test from compile-fail, it was able to successfully create mir, ast, and ast.nll variants, and everything seems happy.

@bors
Copy link
Contributor

bors commented Apr 20, 2018

☔ The latest upstream changes (presumably #50119) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor

I think this is now working well with the latest NLL updates. With a sample test from compile-fail, it was able to successfully create mir, ast, and ast.nll variants, and everything seems happy.

@ehuss can you say a bit more? What was the test you tried? I don't quite understand what "everything seems happy" means. =)

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Apr 23, 2018

I believe the new behavior is as follows:

  • If a test has two revisions, say ast and mir, we expect their output in foo.ast.stderr and foo.mir.stderr respectively
  • If we then run with a compare-mode, say nll, we will look for the new output of each revision in foo.ast.nll.stderr and foo.mir.nll.stderr respectively, falling back to the original paths if those files do not exist

In other words, revisions and compare modes are orthogonal? This seems ok so long as the flags that nll compare-mode passes (e.g., -Zborrowck=mir) are "composable" with the custom flags in the mir revision (in particular, can be given more than once).

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 23, 2018

📌 Commit c3af118 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 23, 2018
@ehuss
Copy link
Contributor Author

ehuss commented Apr 23, 2018

What was the test you tried?

I tried copying over some tests from compile-fail (without the stderr files). Example of going through this dance:

  1. Run x.py test. Test fails.
  2. Run update-references.sh to copy over xxx.ast.stderr.
  3. Run x.py test. Test fails.
  4. Run update-references.sh to copy over xxx.mir.stderr.
  5. Run x.py test. Test fails.
  6. Run update-references.sh to copy over xxx.ast.nll.stderr.
  7. Run x.py test. Test succeeds! (The mir NLL is the same without NLL in this example, so no file is generated.)

And verified that the stderr files look reasonable.

kennytm added a commit to kennytm/rust that referenced this pull request Apr 24, 2018
bors added a commit that referenced this pull request Apr 24, 2018
Rollup of 11 pull requests

Successful merges:

 - #49461 (std: Child::kill() returns error if process has already exited)
 - #49727 (Add Cell::update)
 - #49812 (Fix revision support for UI tests.)
 - #49829 (Add doc links to `std::os` extension traits)
 - #49906 (Stabilize `std::hint::unreachable_unchecked`.)
 - #49970 (Deprecate Read::chars and char::decode_utf8)
 - #49985 (don't see issue #0)
 - #50118 (fix search bar bug)
 - #50139 (encourage descriptive issue titles)
 - #50174 (Use FxHashMap in syntax_pos::symbol::Interner::intern.)
 - #50185 (core: Fix overflow in `int::mod_euc` when `self < 0 && rhs == MIN`)

Failed merges:
@bors bors merged commit c3af118 into rust-lang:master Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants