Skip to content

Allow ui tests to have dependencies in a reliable way#2373

Merged
bors merged 1 commit into
masterfrom
test_dependencies
Jul 20, 2022
Merged

Allow ui tests to have dependencies in a reliable way#2373
bors merged 1 commit into
masterfrom
test_dependencies

Conversation

@oli-obk

@oli-obk oli-obk commented Jul 14, 2022

Copy link
Copy Markdown
Contributor

This completely sidesteps the issue that compiletest-rs has where old artifacts of a dependency cause multiple available crates of name XXX errors. At this point I think we've reached feature parity for clippy, too, so I'm going to try publishing a version once this is merged.

Comment thread miri Outdated
@RalfJung

Copy link
Copy Markdown
Member

Could you describe the design at a high level? That would help with reviewing. :)

@oli-obk

oli-obk commented Jul 15, 2022

Copy link
Copy Markdown
Contributor Author
  1. There is a crate that we build once to generate all dependencies
  2. we grab all the artifacts that were built for that crate
  3. we link every test against all those artifacts

coincidentally this removes the implicit trick of using dev-dependencies from the main miri crate for tests via extern crate imports. the dev-deps scheme can require cargo clean when updating dependencies as you'd then get "multiple imports found" when there are two versions available

@RalfJung

Copy link
Copy Markdown
Member

this removes the implicit trick of using dev-dependencies from the main miri crate for tests via extern crate imports

I never heard of this, no idea what you are talking about here.

@oli-obk

oli-obk commented Jul 15, 2022

Copy link
Copy Markdown
Contributor Author

I never heard of this, no idea what you are talking about here.

we have lots of tests that use extern crate libc; which just accidentally works by picking the libc from the sysroot. But with compiletest-rs you could have picked any dev-dependency and used that (clippy tests against usages of serde types and derives in its ui tests this way)

@RalfJung

Copy link
Copy Markdown
Member

Oh lol, I had no idea. Like, taking the sysroot libc seems fine, but I didn't know the other thing would have worked. Good thing I didn't.^^

@bors

bors commented Jul 18, 2022

Copy link
Copy Markdown
Contributor

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

@oli-obk
oli-obk force-pushed the test_dependencies branch from 5c97ff3 to cf74b1f Compare July 18, 2022 08:04
@oli-obk oli-obk changed the title Allow ui tests to have reliable dependencies Allow ui tests to have dependencies in a reliable way Jul 18, 2022
@oli-obk
oli-obk force-pushed the test_dependencies branch from cf74b1f to e5736f9 Compare July 18, 2022 08:38
@oli-obk

oli-obk commented Jul 18, 2022

Copy link
Copy Markdown
Contributor Author

Do you want to review this? Or can I merge myself?

@RalfJung

Copy link
Copy Markdown
Member

It's in my queue :)

@RalfJung RalfJung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wow this is clever, I like it a lot. :)

Comment thread miri Outdated
Comment thread test_dependencies/Cargo.toml
Comment thread tests/compiletest.rs Outdated
Comment thread tests/compiletest.rs Outdated
Comment thread ui_test/Cargo.toml
Comment thread ui_test/README.md Outdated
Comment thread ui_test/src/dependencies.rs
Comment thread ui_test/src/dependencies.rs Outdated
@RalfJung

Copy link
Copy Markdown
Member

We will probably want to move some tests from test-cargo-miri to here, in particular the getrandom tests. Those use the renaming feature of cargo:

getrandom_1 = { package = "getrandom", version = "0.1" }
getrandom_2 = { package = "getrandom", version = "0.2" }

Will that work?

@RalfJung

RalfJung commented Jul 19, 2022

Copy link
Copy Markdown
Member

Oh also please check that this works in the rustc workspace via x.py. The ./miri will probably not be the right call there...

@oli-obk

oli-obk commented Jul 19, 2022

Copy link
Copy Markdown
Contributor Author

Will that work?

I was afraid of this ^^ it doesn't work with my current scheme. The fix is obvious and I knew I should've done it this way, but 🤷

Basically what I need to do is to also run cargo metadata to get these renames and how they map to the artifacts

EDIT: works now correctly

Comment thread ui_test/src/lib.rs Outdated
@oli-obk

oli-obk commented Jul 19, 2022

Copy link
Copy Markdown
Contributor Author

Oh also please check that this works in the rustc workspace via x.py. The ./miri will probably not be the right call there...

even the latest version doesn't work from rustc yet, so this PR is not ready yet

Comment thread test-cargo-miri/tests/test.rs
Comment thread test-cargo-miri/run-test.py Outdated
Comment thread ui_test/src/lib.rs Outdated
Comment thread ui_test/src/dependencies.rs Outdated
@RalfJung

Copy link
Copy Markdown
Member

even the latest version doesn't work from rustc yet, so this PR is not ready yet

@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Jul 19, 2022
@oli-obk
oli-obk force-pushed the test_dependencies branch from 0c41b5a to b0353b5 Compare July 19, 2022 13:53
Comment thread tests/pass/random.rs Outdated
@oli-obk

oli-obk commented Jul 19, 2022

Copy link
Copy Markdown
Contributor Author

status update

I can reproduce the failure with x.py now: running

cargo run --manifest-path=cargo-miri/Cargo.toml -- miri run --manifest-path=test_dependencies/Cargo.toml

via the bootstrap machinery will suceed to build cargo-miri (that already worked for cargo miri setup), but fail when cargo-miri tries to build build scripts (or proc macros), as they can't find the libstd.

edit: manually adding --sysroot = build/...../stage1 makes it compile, now I gotta figure out why/where we're losing that

Comment thread tests/pass/libc.rs
Comment thread miri Outdated
@oli-obk

oli-obk commented Jul 20, 2022

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Jul 20, 2022
Comment thread cargo-miri/bin.rs Outdated
Comment thread cargo-miri/bin.rs Outdated
Comment thread cargo-miri/bin.rs
Comment thread miri Outdated
Comment thread test-cargo-miri/run-test.py Outdated
@RalfJung

Copy link
Copy Markdown
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Jul 20, 2022
Comment thread cargo-miri/bin.rs
Comment thread cargo-miri/bin.rs
@oli-obk

oli-obk commented Jul 20, 2022

Copy link
Copy Markdown
Contributor Author

@rustbot ready

Comment thread test-cargo-miri/run-test.py
@RalfJung

Copy link
Copy Markdown
Member

r=me with run-test.py fixed and commits squashed

@oli-obk
oli-obk force-pushed the test_dependencies branch from 5474f13 to ab6fb9d Compare July 20, 2022 15:59
@oli-obk

oli-obk commented Jul 20, 2022

Copy link
Copy Markdown
Contributor Author

@bors r=RalfJung

@bors

bors commented Jul 20, 2022

Copy link
Copy Markdown
Contributor

📌 Commit ab6fb9d has been approved by RalfJung

It is now in the queue for this repository.

@bors

bors commented Jul 20, 2022

Copy link
Copy Markdown
Contributor

⌛ Testing commit ab6fb9d with merge 1366bf6...

@bors

bors commented Jul 20, 2022

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 1366bf6 to master...

Comment thread tests/fail/tokio_mvp.rs
//@only-target-linux: the errors differ too much between platforms

#[tokio::main]
async fn main() {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Btw would be nice to also have a 'pass' test for #602 (comment).

Should we have these tests of non-stdlib crates in a subdir in our test folders? The root dirs are already quite messy, so something like {pass,fail}/crates or so might make sense?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yea grouping them into a custom folder makes sense.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#2408 does these changes.

@oli-obk
oli-obk deleted the test_dependencies branch July 21, 2022 12:14
github-actions Bot pushed a commit that referenced this pull request Jun 6, 2025
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.

4 participants