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

Move test suite to ui tests and bless stderr output #2032

Merged
merged 1 commit into from
May 25, 2022
Merged

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Mar 17, 2022

fixes #2027

  • //~ annotations should check that the error happens on their line
  • document all the things

@RalfJung
Copy link
Member

Nice, thanks!

I was not sure yet whether we'd want to merge the passing and failing tests... it is quite nice to be able to immediately see which kind of test this is, and this requires a lot more reorganization. But I guess it makes sense to follow rustc here.

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 17, 2022

Yea I was a bit surprised how the run-pass tests don't need any flags (like build-pass)... so maybe we should indeed keep them separate until that happens..

Anyway, right now we have a problem: paths to the sysroot are flaky, as they depend on where your sysroot is. Gotta figure out how rustc handles this.

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 17, 2022

I reverted the directory moves for now

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 17, 2022

hmm... gotta figure out how to handle the optimized stderr

@RalfJung
Copy link
Member

RalfJung commented Mar 17, 2022

Yea I was a bit surprised how the run-pass tests don't need any flags (like build-pass)... so maybe we should indeed keep them separate until that happens..

Yeah compiletest lags behind the rustc code by a lot by now, and fails to check the exist status most of them time. Plus things like Manishearth/compiletest-rs#123.

Maybe we should use https://crates.io/crates/trybuild instead?^^ (Not sure if that's actually possible.) EDIT: Looking at its API -- no that is probably not possible.

tests/compiletest.rs Outdated Show resolved Hide resolved
miri Show resolved Hide resolved
@RalfJung
Copy link
Member

hmm... gotta figure out how to handle the optimized stderr

Ah, yeah, that has been a problem sometimes even with compile-fail and is a lot worse with ui.
Can we somehow tell compiletest to check the error annotations but not the reference files? Worst case, tell it to bless and un-do the blessing afterwards...

@RalfJung
Copy link
Member

We'll also have to normalize Alloc IDs and SB Tags in many places. Is there a way to add a "default normalizer" to compiletest so we don't have to add the same normalize-stderr to dozens of tests?

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 17, 2022

We'll also have to normalize Alloc IDs and SB Tags in many places. Is there a way to add a "default normalizer" to compiletest so we don't have to add the same normalize-stderr to dozens of tests?

Yea, I haven't figured this out yet.. maybe I can add something to the miri binary instead that filters all the stderr output

@RalfJung
Copy link
Member

Is patching compiletest an option? Shouldn't be too hard to add a new field to the config struct and using that to initialize TestProps.

@bjorn3
Copy link
Member

bjorn3 commented Mar 17, 2022

Anyway, right now we have a problem: paths to the sysroot are flaky, as they depend on where your sysroot is. Gotta figure out how rustc handles this.

You can set the CFG_VIRTUAL_RUST_SOURCE_BASE_DIR env var to the sysroot source path. Compiletest will then replace virtual_rust_source_base_dir.join("library") with the literal $SRC_DIR. At least that is the case with the compiletest version of rustc. I'm not sure if it also works with the version from crates.io. Maybe it needs a different way to configure this.

@bors
Copy link
Contributor

bors commented Mar 20, 2022

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

@RalfJung
Copy link
Member

@oli-obk what are your plans for this? I would love to see this happen. :)

@oli-obk
Copy link
Contributor Author

oli-obk commented May 17, 2022

I talked with pnkfelix about it yesterday. I'm going to add default filters to compiletest, and once that is merged, bump the crates.io version and then we can set some default filters here. That'll probably take a bit tho

@RalfJung
Copy link
Member

Sounds like a great plan. :)

compiletest-rs is quite far behind the rustc version, FWIW. As in, many years. Doing a bump might be more like re-doing the extraction from scratch rather than updating the existing thing...

@oli-obk
Copy link
Contributor Author

oli-obk commented May 17, 2022

compiletest-rs is quite far behind the rustc version, FWIW. As in, many years. Doing a bump might be more like re-doing the extraction from scratch rather than updating the existing thing...

oof yea, I looked at this. And remembered I tried this before... Not sure what the best way forward is, but I think this is a larger project. I don't want to do the change just in the crates.io version, but re-doing a sync when it's just going to get out of sync again is also not great.

@RalfJung
Copy link
Member

RalfJung commented May 17, 2022

Yeah, just doing the change on crates.io is where I would have started. It's terrible but I gave up my hopes for this getting back in sync.^^

Or we go the low-tech way and simply have a common prelude in all our test files, and some ad-hoc hacky scripts to update it when needed...

@oli-obk oli-obk force-pushed the gesundheit branch 2 times, most recently from ab2648f to fe38f1b Compare May 17, 2022 21:19
@oli-obk
Copy link
Contributor Author

oli-obk commented May 17, 2022

Now I just gotta get back //~ ERROR annotations and we're good to go..

@oli-obk
Copy link
Contributor Author

oli-obk commented May 18, 2022

@RalfJung once I get all the targets working, I would like to merge this. While there are still minor bugs that I want to fix before merging, there is one major missing feature that I need to fix: //~ annotations do not check that the diagnostic happened on the line, just that it happened. Fixing this is not a problem, but it still requires a bit of work. Merging now will avoid forcing me to keep maintaining and rebasing this branch until everything works.

Opinions?

@oli-obk
Copy link
Contributor Author

oli-obk commented May 18, 2022

🚀 CI is passing.

I'll see if it still works if we run it from within the rustc repo

@RalfJung
Copy link
Member

This is what I do.

The changes are just some minor things where we now show spans in libstd because the paths are available. I know we also have them here, so I don't know why that makes a difference

Ah, so that will be hard to normalize as well.
Spans in libstd are weird, yeah... but seems fine now to do as you suggest. 👍

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
cargo-miri/bin.rs Outdated Show resolved Hide resolved
ui(Mode::UB, "tests/compile-fail", &target);
ui(Mode::Pass, "tests/run-pass");
ui(Mode::Panic, "tests/run-fail");
ui(Mode::UB, "tests/compile-fail");
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the names of the folders, maybe we should call the variants RunFail and CompileFail?

Though "compile-fail" is not a great name and we should probably rename the folder instead...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to cause the folder renaming churn.

I want run-pass, run-panic and run-fail

Copy link
Member

Choose a reason for hiding this comment

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

I didn't want to cause the folder renaming churn.

Fair, we can leave that to a separate PR.

I want run-pass, run-panic and run-fail

The "run" part looks rather redundant in these names...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeaaa... we don't really have compile-fail tests, so leaving out the run part makes sense

tests/compiletest.rs Outdated Show resolved Hide resolved
ui_test/src/lib.rs Outdated Show resolved Hide resolved
@@ -123,5 +128,5 @@ fn main() {

ui(Mode::Pass, "tests/run-pass");
ui(Mode::Panic, "tests/run-fail");
ui(Mode::UB, "tests/compile-fail");
ui(Mode::Fail, "tests/compile-fail");
Copy link
Member

Choose a reason for hiding this comment

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

So what about "pass", "panic", and "fail" for the folder names?

@RalfJung RalfJung added the S-waiting-on-author Status: Waiting for the PR author to address review comments label May 23, 2022
@oli-obk
Copy link
Contributor Author

oli-obk commented May 24, 2022

I addressed all review comments

tests/compiletest.rs Outdated Show resolved Hide resolved
Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

Generally looks great! I left a bunch of comments/nits on the ui test library. I didn't re-check the test output itself; that part is probably easier to tweak post-landing. I also didn't check the details of how the library prints test failures, and the comment parsing. It seems to work well enough for now. :)

ui_test/README.md Show resolved Hide resolved
ui_test/README.md Outdated Show resolved Hide resolved
ui_test/README.md Show resolved Hide resolved
ui_test/README.md Outdated Show resolved Hide resolved
ui_test/README.md Show resolved Hide resolved
ui_test/README.md Show resolved Hide resolved
CONTRIBUTING.md Show resolved Hide resolved
ui_test/src/lib.rs Show resolved Hide resolved
ui_test/src/lib.rs Outdated Show resolved Hide resolved
ui_test/src/lib.rs Outdated Show resolved Hide resolved
ui_test/src/comments.rs Outdated Show resolved Hide resolved
ui_test/README.md Outdated Show resolved Hide resolved
@oli-obk
Copy link
Contributor Author

oli-obk commented May 25, 2022

Addressed all comments and rebased (no squashing or other history editing)

ui_test/README.md Outdated Show resolved Hide resolved
@RalfJung
Copy link
Member

Apart from these last two nits, LGTM. Please squash and land. :-)

@oli-obk
Copy link
Contributor Author

oli-obk commented May 25, 2022

@bors r+

@oli-obk
Copy link
Contributor Author

oli-obk commented May 25, 2022

@bors ping

@bors
Copy link
Contributor

bors commented May 25, 2022

😪 I'm awake I'm awake

@oli-obk
Copy link
Contributor Author

oli-obk commented May 25, 2022

@bors r+

@bors
Copy link
Contributor

bors commented May 25, 2022

📌 Commit f1756c3 has been approved by oli-obk

@bors
Copy link
Contributor

bors commented May 25, 2022

⌛ Testing commit f1756c3 with merge 0a4279f...

@bors
Copy link
Contributor

bors commented May 25, 2022

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 0a4279f to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: Waiting for the PR author to address review comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch compile-fail tests to ui tests
4 participants