Skip to content

use ui_test dependency builder for test dependencies #14883

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

Merged
merged 1 commit into from
Jul 2, 2025

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented May 24, 2025

changelog: none

This tries to make progress on rust-lang/rust#78717 by using the ui_test dependency handling instead of linking in the dependencies of clippy itself with the tests. This partially reverts #11045. However, we still use the old style of dealing with dependencies for clippy's own crates and the "internal" tests, as otherwise those would get rebuilt which takes too long.

@rustbot
Copy link
Collaborator

rustbot commented May 24, 2025

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 24, 2025
@RalfJung RalfJung marked this pull request as draft May 24, 2025 09:34
@Alexendoo
Copy link
Member

No clue about the ui_test error, but ui-internal tests still depend on clippy_utils

@RalfJung
Copy link
Member Author

Oh I see, and those are driven by the same runner. So depending on the test suite we'll need to use one or the other logic.

@oli-obk
Copy link
Contributor

oli-obk commented May 26, 2025

This effectively reverts #11045.

that PR was made because it was prohibitively slow for many maintainers and contributors to build the deps in the test suite instead of in the main build. I don't see how that issue can be avoided.

@oli-obk
Copy link
Contributor

oli-obk commented May 26, 2025

I am not sure which exact dependencies ui_test is referring to here -- clippy_test_deps does not have any build-dependencies.

@oli-obk do you know what could be done here?

this is about quote, which iirc I could not differentiate in cargo_metadata output by rustc and cargo to properly detect which ones are build as proc macro deps or as direct deps

@RalfJung
Copy link
Member Author

RalfJung commented May 26, 2025

I don't see how that issue can be avoided.

The issue is avoided by noting having the clippy crates in clippy_test_deps. Only the ui-internal tests need them; those will still use the old style of adding dependencies -- which is fine as they don't run in the rustc repo at all.

I didn't implement this part yet; it's what I referred to here.

@RalfJung
Copy link
Member Author

RalfJung commented May 26, 2025

this is about quote, which iirc I could not differentiate in cargo_metadata output by rustc and cargo to properly detect which ones are build as proc macro deps or as direct deps

Ah so the problem is that we pull in serde which pulls in a proc macro which has quote as a proc macro dep? Hm...

They look different in what you print, one is in the x86_64-unknown-linux-gnu folder and one is not. Not sure if there's a good way to use that.

Do clippy tests need serde with the proc macro or could we disable that feature?

@flip1995
Copy link
Member

A lot of Clippy tests use derive(Deserialize), which needs those proc macros. The tests/ui/unsafe_derive_deserialize.rs specifically is about this derive attribute.

@RalfJung
Copy link
Member Author

Okay, damn. Then ui_test has to somehow figure out which dependencies belong where...

@oli-obk
Copy link
Contributor

oli-obk commented May 26, 2025

I can give it another shot, but I may have to ask cargo to emit more data

@RalfJung
Copy link
Member Author

I tried to understand the problem and created an issue for further discussion: oli-obk/ui_test#327.

@RalfJung RalfJung force-pushed the test-deps branch 2 times, most recently from b839767 to c3087c8 Compare June 30, 2025 19:31
@RalfJung RalfJung force-pushed the test-deps branch 3 times, most recently from 10fe036 to c81f3ee Compare June 30, 2025 20:25
@RalfJung
Copy link
Member Author

After adding the internal dependencies back for the internal tests, this PR now passes when using a ui_test that includes oli-obk/ui_test#329. :)

@RalfJung RalfJung force-pushed the test-deps branch 3 times, most recently from 6b5f9f2 to c2d0a45 Compare July 1, 2025 05:39
@RalfJung RalfJung marked this pull request as ready for review July 1, 2025 11:39
@RalfJung
Copy link
Member Author

RalfJung commented Jul 1, 2025

Okay this should be good to go now :)

@RalfJung RalfJung changed the title WIP: use ui_test dependency builder for test dependencies use ui_test dependency builder for test dependencies Jul 1, 2025
Copy link
Contributor

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

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

Even if the main is empty today and may stay empty, could you add clippy_test_deps to the list of packages in test/dogfood.rs so that it gets linted as well when running cargo dev dogfood? (for cargo dev fmt, this is handled already as it looks for all *.rs files, so there is nothing to do there)

@RalfJung
Copy link
Member Author

RalfJung commented Jul 1, 2025

I don't understand what that has to do with my PR...?

@RalfJung
Copy link
Member Author

RalfJung commented Jul 1, 2025

Oh, because I added a new crate, and that's supposed to be a list of all crates there, I see. Will do.

That crate really should stay empty though, it's code is not run or tested by anything anyway.

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! LGTM overall. I would not add that test crate to the dogfood list though. See below.

tests/dogfood.rs Outdated
@@ -40,6 +40,7 @@ fn dogfood() {
"clippy_lints",
"clippy_utils",
"clippy_config",
"clippy_test_deps",
Copy link
Member

Choose a reason for hiding this comment

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

I disagree here. If this crate is empty and should stay empty, we just add time to the dogfood tests waiting for the dependencies to be compiled. This will just increase the time of dogfood tests without any benefit.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fine either way, I hope the clippy maintainers can come to a consensus here. :)

Copy link
Member

@flip1995 flip1995 Jul 2, 2025

Choose a reason for hiding this comment

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

@samueltardieu Do you feel strongly about adding it to the dogfood list?

If not, r=me

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope, I thought it was more "belts and suspensers" here in case something crept it, but I'm fine without it!

Comment on lines +36 to +37
/// in `clippy_test_devs`. That saves a lot of time but also means they don't work in a stage 1
/// test in rustc bootstrap.
Copy link
Member

Choose a reason for hiding this comment

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

rustc bootstrap doesn't run Clippy's internal tests anyway. Which is sometimes annoying during the sync, so I'd like to enable this at some point. This kinda closes the door on that. At least for stage 1. IIUC on a stage 2 build, this would still be possible?

Anyway, the benefits of this is way bigger than the slight annoyance of not running ui-internal in the Rust repo.

Copy link
Member Author

@RalfJung RalfJung Jul 2, 2025

Choose a reason for hiding this comment

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

This kinda closes the door on that. At least for stage 1. IIUC on a stage 2 build, this would still be possible?

I think so, yeah. Or alternatively, when running in ./x, the internal dependencies could also be managed by the clippy_test_deps crate. But that seems messy... so only doing it in stage 2 is probably best, similar to the "fulldep" tests in rustc.

It doesn't close any door on stage 1, the internal tests are equally broken in stage 1 before and after this PR. What the PR changes is that it hopefully un-breaks the other tests.

Copy link
Member

Choose a reason for hiding this comment

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

Understood! Thanks for the explanation!

@samueltardieu samueltardieu added this pull request to the merge queue Jul 2, 2025
Merged via the queue into rust-lang:master with commit 8e4b544 Jul 2, 2025
26 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants