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

RFC: Simplify version handling of UI tests. #3171

Merged
merged 6 commits into from May 25, 2023
Merged

Conversation

adamreichold
Copy link
Member

Due to checking in error outputs these tests only work reliably on stable and not on intermediate version between our MSRV (currently 1.48) and the current stable version.

Hence this simplifies things to run only MSRV-compatible tests for the MSRV builds, anything else for stable builds except for those tests which require the nightly feature, i.e. the Ungil being distinct from the Send trait.

Finally, not_send3 is disabled when using the nightly feature since while Rc is not send, it also not GIL-bound and hence can be passed into allow_threads as it does not actually spawn a new thread.

@adamreichold adamreichold added the CI-skip-changelog Skip checking changelog entry label May 21, 2023
@adamreichold adamreichold force-pushed the simplify-compile-error-tests branch 2 times, most recently from 9eff940 to 3e40fa5 Compare May 21, 2023 10:47
@adamreichold
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request May 21, 2023
@bors
Copy link
Contributor

bors bot commented May 21, 2023

try

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@adamreichold
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request May 21, 2023
@bors
Copy link
Contributor

bors bot commented May 21, 2023

try

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@davidhewitt
Copy link
Member

Due to checking in error outputs these tests only work reliably on stable and not on intermediate version between our MSRV (currently 1.48) and the current stable version.

Can you clarify where the current tests broke? It was a best effort but I was hoping that by gating tests on each version in the way it was currently done it should be the case that when a test output changed it would be bumped to run only on that rust version or newer. The effect hopefully being that older intermediate versions would only run tests which that version produced the same output as current stable.

@adamreichold
Copy link
Member Author

Can you clarify where the current tests broke?

I ran the tests using 1.63 and immediately, meaning on main unmodified, got changes in the error output of 8 test cases.

It was a best effort but I was hoping that by gating tests on each version in the way it was currently done it should be the case that when a test output changed it would be bumped to run only on that rust version or newer.

I suspect we failed to do this at some point in the past when we updated the expected error outputs to match a new stable release. These test cases would have had to be moved to a later rustversion::since-gated section since their output retroactively changed from stable to stable, but we did not do that and hence they are broken when using an older compiler.

Personally, I don't think the effort to keep this aligned is worth it: We do not test these intermediate versions in the CI. (Which is also why we did not notice them breaking.) Even for MSRV and nightly, it seems enough to check that these test cases fail to build as expected. The detailed error message could then just be kept in sync with the current stable release and that would be it. Hence the change proposed here.

(With this change, we could also drop the dev dependency on rustversion after the MSRV bump to 1.56 because the only other use (besides xtask) is in the tests that do not even parse on 1.48.)

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Ah right. That makes sense and I'm in favour of simplification.

So the one concern I have is for system package distributors, who I think may sometimes run cargo test as part of their package build / distribution? If that's the case I suspect they use the distro's rust, which probably isn't latest stable.

That said, as you note, it's already broken. I suppose that if we go this route and only support the UI tests on latest stable, we can perhaps just recommend any distro packagers who hit this just ignore the UI tests.

tests/test_compile_error.rs Outdated Show resolved Hide resolved
.github/workflows/build.yml Show resolved Hide resolved
@adamreichold
Copy link
Member Author

adamreichold commented May 22, 2023

So the one concern I have is for system package distributors, who I think may sometimes run cargo test as part of their package build / distribution? If that's the case I suspect they use the distro's rust, which probably isn't latest stable.

One idea I see to fix this is to just not ship tests/test_compile_error.rs on crates.io, i.e. adding it to package.exclude via Cargo.toml so that package distributors using the sources from crates.io do not get this particular test case at all. (We could also exclude tests/ui then to save a few bytes.)

While this may appear a bit heavy-handed, alternatives like environment variables or Cargo features seem to loose out on discoverability and brittleness.

@davidhewitt
Copy link
Member

One idea I see to fix this is to just not ship tests/test_compile_error.rs on crates.io, i.e. adding it to package.exclude via Cargo.toml so that package distributors using the sources from crates.io do not get this particular test case at all. (We could also exclude tests/ui then to save a few bytes.)

That sounds like a very reasonable idea, as long as we don't have other references to those files which might otherwise break the distributed crate.

I suppose some vendors might be using the GitHub archive, they can always strip or ignore the UI tests themselves.

@adamreichold
Copy link
Member Author

I excluded the UI tests from the package for crates.io and converted the nightly-related UI tests into doc tests which is actually nice since it gives a bit more context. Please have another look.

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

A really nice improvement! Just one comment motivated by our new docs, which we might want to spin off into a separate discussion...

src/marker.rs Outdated Show resolved Hide resolved
Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Looks great, sorry for the delayed approval!

bors r+

@bors
Copy link
Contributor

bors bot commented May 25, 2023

Merge conflict.

Due to checking in error outputs these tests only work reliably on stable and
not on intermediate version between our MSRV (currently 1.48) and the current
stable version.

Hence this simplifies things to run only MSRV-compatible tests for the MSRV
builds, anything else for stable builds except for those tests which require the
nightly feature, i.e. the `Ungil` being distinct from the `Send` trait.

Finally, `not_send3` is disabled when using the nightly feature since while `Rc`
is not send, it also not GIL-bound and hence can be passed into `allow_threads`
as it does not actually spawn a new thread.
…rk reliably using the current stable version Rust, e.g. in our CI.
… the changing error outputs of nightly in any case.
@adamreichold
Copy link
Member Author

bors retry

@bors
Copy link
Contributor

bors bot commented May 25, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 0e50338 into main May 25, 2023
33 checks passed
@bors bors bot deleted the simplify-compile-error-tests branch May 25, 2023 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants