Skip to content

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

Merged
bors merged 3 commits into
rust-lang:masterfrom
camsteffen:depinfo
Sep 8, 2021
Merged

bors merged 3 commits into
rust-lang:masterfrom
camsteffen:depinfo

Conversation

@camsteffen

@camsteffen camsteffen commented Sep 4, 2021 •

Copy link
Copy Markdown
Contributor

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

Jarcho commented Sep 4, 2021

Copy link
Copy Markdown
Contributor

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

Comment thread .cargo/config
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
Copy Markdown
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
Copy Markdown
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 thread tests/compile-test.rs Outdated
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
Copy Markdown
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
Copy Markdown
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.

@flip1995 flip1995 Sep 6, 2021 •

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.

(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)

@Jarcho Jarcho Sep 6, 2021 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Comment thread tests/compile-test.rs Resolved

@flip1995 flip1995 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.

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

@Jarcho

Jarcho commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

Current version is working on Windows.

@flip1995

flip1995 commented Sep 8, 2021

Copy link
Copy Markdown
Member

Rebased onto master

@flip1995

flip1995 commented Sep 8, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

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

@flip1995

flip1995 commented Sep 8, 2021

Copy link
Copy Markdown
Member

@bors r+

Thanks!

@bors

bors commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

📌 Commit 5d3fc6f has been approved by flip1995

@bors

bors commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

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

@bors

bors commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

☀️ 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