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

Use binary-dep-depinfo to resolve UI test dependencies #7631

Merged
merged 3 commits into from
Sep 8, 2021

Conversation

camsteffen
Copy link
Contributor

@camsteffen camsteffen commented Sep 4, 2021

Closes #7343
Closes #6809
Closes #3643

changelog: none

r? @flip1995
cc @Jarcho

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 4, 2021
@Jarcho
Copy link
Contributor

Jarcho commented Sep 4, 2021

This looks like the better approach. I'll close the other one.

Comment on lines 7 to +9
[build]
rustflags = ["-Zunstable-options"]
# -Zbinary-dep-depinfo allows us to track which rlib files to use for compiling UI tests
rustflags = ["-Zunstable-options", "-Zbinary-dep-depinfo"]
Copy link
Member

Choose a reason for hiding this comment

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

the new "nightly-only" flag can't cause problems when running clippy tests on the stable channel inside the rustc repo in a couple of months, can it? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I mean, we have the nightly-only flag -Zunstable-options in there forever, so I assume it won't. (?)

Comment on lines 70 to 78
let path = line.strip_suffix(':')?;
let part = path
.strip_suffix(".rlib")
.or_else(|| path.strip_suffix(".so"))
.or_else(|| path.strip_suffix(".dylib"))
.or_else(|| path.strip_suffix(".dll"))?;
let part = part.rsplit_once('-')?.0;
let name = part.rsplit_once(|c| matches!(c, '/' | '\\'))?.1.strip_prefix("lib")?;
CRATES.contains(&name).then(|| (name, path))?
Copy link
Member

Choose a reason for hiding this comment

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

This seems to make really strong assumptions about the format of the depinfo file. Since this is still unstable this may just change without a warning. Also reading the tracking issue rust-lang/rust#63012, I wonder if this also works on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well let's spell out those assumptions (I should put this in a comment too). The depinfo file is a Makefile. For every rlib, there is a "rule" where the "target" is the rlib file and there are no "prerequisites" after the :. There is no extra whitespace around the :. On the plus side there is no assumption about where the path is in the filesystem.

I agree these are pretty strong assumptions. But I also think this buys us much better stability overall than the current solution. The file is machine-generated and seems to be unchanged for 2 years, which is quite good in this ecosystem. The flag is also used in rustc builds so that's a plus.

I wonder if this also works on Windows?

I think it will since I allow for either slash and don't look at the beginning of the path. But someone should test this before merging for sure.

Copy link
Member

@flip1995 flip1995 Sep 6, 2021

Choose a reason for hiding this comment

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

(I should put this in a comment too)

Yep :D

The file is machine-generated and seems to be unchanged for 2 years

Sounds good!

I think it will since I allow for either slash and don't look at the beginning of the path. But someone should test this before merging for sure.

@rust-lang/clippy anyone has access/uses a windows PC where they can test this? (I'll also provide a rust repo branch to test this in the Rust repo)

Copy link
Contributor

@Jarcho Jarcho Sep 6, 2021

Choose a reason for hiding this comment

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

You'll need to do:

let part = part.rsplit_once('-')?.0.rsplit_once(|c| matches!(c, '/' | '\\'))?.1;
let name = part.strip_prefix("lib").unwrap_or(part);

dll names on windows don't have a lib prefix. Works fine with that change.

@camsteffen
Copy link
Contributor Author

  • Made some stylistic changes, added comments
  • Fixed depinfo parsing for Windows (@Jarcho could you test again please?)
  • Added an assertion that all crates are found in depinfo
  • Removed clippy_lints from the list of dependencies

@flip1995 flip1995 added the I-sync-blocker Issue: Prevents a change to be synced to rust-lang/rust label Sep 7, 2021
tests/compile-test.rs Outdated Show resolved Hide resolved
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

Thanks! I'll try this out tomorrow during sync.

@Jarcho
Copy link
Contributor

Jarcho commented Sep 8, 2021

Current version is working on Windows.

@flip1995
Copy link
Member

flip1995 commented Sep 8, 2021

Rebased onto master

@flip1995
Copy link
Member

flip1995 commented Sep 8, 2021

This seemed to fix the problem in the Clippy update rust-lang/rust#88615. I had to add allow(unused_extern_crates) though. Any idea why that is?

@camsteffen
Copy link
Contributor Author

It's rust_2018_idioms. Added this and deny warnings to all test modules.

@flip1995
Copy link
Member

flip1995 commented Sep 8, 2021

@bors r+

Thanks!

@bors
Copy link
Collaborator

bors commented Sep 8, 2021

📌 Commit 5d3fc6f has been approved by flip1995

@bors
Copy link
Collaborator

bors commented Sep 8, 2021

⌛ Testing commit 5d3fc6f with merge 27afd6a...

@bors
Copy link
Collaborator

bors commented Sep 8, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 27afd6a to master...

@bors bors merged commit 27afd6a into rust-lang:master Sep 8, 2021
@camsteffen camsteffen deleted the depinfo branch September 8, 2021 13:47
camsteffen added a commit to camsteffen/rust-clippy that referenced this pull request Jan 10, 2022
I believe this is possible as of rust-lang#7631
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-sync-blocker Issue: Prevents a change to be synced to rust-lang/rust S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
6 participants