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

Ensure all tests in the workspace are run and that const extern fn is always enabled #4151

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

tgross35
Copy link
Contributor

@tgross35 tgross35 commented Nov 26, 2024

In 1 this conditional was dropped in favor of a Cargo feature, which was turned on by default in 2. However, this did not help the case where --no-default-features is passed.

Unfortunately we still can't drop this config entirely since ctest cannot parse the syntax, so change back to useing a cfg to control constness rather than a Cargo feature.

Fixes: #4149

Specifically, this should ensure that unit tests in the `libc` crate
don't get missed.
@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2024

r? @JohnTitor

rustbot has assigned @JohnTitor.
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

@tgross35
Copy link
Contributor Author

@tamird could you check this resolves #4149 for you?

@tgross35 tgross35 force-pushed the tests-and-const-extern branch 3 times, most recently from 369a795 to b346c41 Compare November 26, 2024 21:00
@tgross35 tgross35 marked this pull request as ready for review November 26, 2024 21:01
@tgross35 tgross35 changed the title tests: Ensure all tests in the workspace are run Ensure all tests in the workspace are run and that const extern fn is always enabled Nov 26, 2024
@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Nov 26, 2024
@@ -199,7 +199,7 @@ macro_rules! e {
// cfg completely.
// FIXME(ctest): ctest can't handle `$(,)?` so we use `$(,)*` which isn't quite correct.
cfg_if! {
if #[cfg(feature = "const-extern-fn")] {
Copy link
Contributor

Choose a reason for hiding this comment

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

consider removing the feature from the default features (in this commit, so it is backported) and also updating the comment in src/macros.rs in this commit (so it no longer mentions this feature, also so it is backported).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reasonable 👍 changed, thanks for taking a look.

@tamird
Copy link
Contributor

tamird commented Nov 26, 2024

@tamird could you check this resolves #4149 for you?

The test failures before the fix are pretty convincing.

In [1] this conditional was dropped in favor of a Cargo feature, which
was turned on by default in [2]. However, this did not help the case
where `--no-default-features` is passed.

Unfortunately we still can't drop this config entirely since `ctest`
cannot parse the syntax, so change back to useing a `cfg` to control
constness rather than a Cargo feature.

Additionally, remove a portion of the macro's comment that is no longer
relevant.

Fixes: rust-lang#4149

[1]: rust-lang#4105
[2]: rust-lang#4134
Since moving from a feature to a `cfg`, this feature is unneeded. Remove
it in 1.0.

Not intended for backport.
@tgross35 tgross35 force-pushed the tests-and-const-extern branch from b346c41 to e6d7b51 Compare November 26, 2024 21:34
@tgross35 tgross35 enabled auto-merge November 26, 2024 21:36
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 26, 2024
Specifically, this should ensure that unit tests in the `libc` crate
don't get missed.

(backport <rust-lang#4151>)
(cherry picked from commit f553033)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 26, 2024
In [1] this conditional was dropped in favor of a Cargo feature, which
was turned on by default in [2]. However, this did not help the case
where `--no-default-features` is passed.

Unfortunately we still can't drop this config entirely since `ctest`
cannot parse the syntax, so change back to useing a `cfg` to control
constness rather than a Cargo feature.

Additionally, remove a portion of the macro's comment that is no longer
relevant.

Fixes: rust-lang#4149

[1]: rust-lang#4105
[2]: rust-lang#4134

(backport <rust-lang#4151>)
(cherry picked from commit e18ee8c)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 26, 2024
Specifically, this should ensure that unit tests in the `libc` crate
don't get missed.

(backport <rust-lang#4151>)
(cherry picked from commit f553033)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 26, 2024
In [1] this conditional was dropped in favor of a Cargo feature, which
was turned on by default in [2]. However, this did not help the case
where `--no-default-features` is passed.

Unfortunately we still can't drop this config entirely since `ctest`
cannot parse the syntax, so change back to useing a `cfg` to control
constness rather than a Cargo feature.

Additionally, remove a portion of the macro's comment that is no longer
relevant.

Fixes: rust-lang#4149

[1]: rust-lang#4105
[2]: rust-lang#4134

(backport <rust-lang#4151>)
(cherry picked from commit e18ee8c)
@tgross35
Copy link
Contributor Author

Backport in #4152

// Specifically, moving the 'cfg_if' into the macro body will *not* work. Doing so would cause the
// '#[cfg(libc_const_extern_fn)]' to be emitted into user code. The 'cfg' gate will not stop Rust
// from trying to parse the 'pub const unsafe extern fn', so users would get a compiler error even
// when the 'libc_const_extern_fn' feature is disabled.
Copy link
Contributor

Choose a reason for hiding this comment

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

as i mentioned in the backport PR, this is no longer a feature. i'm noticing now that this is also an inconsistent use of quotes vs ticks below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for noticing, but I'm not worried about it - this comment is preexisting and will hopefully go away in the near future once ctest gets fixed.

@tgross35 tgross35 added this pull request to the merge queue Nov 26, 2024
Merged via the queue into rust-lang:main with commit 3cce47f Nov 26, 2024
45 checks passed
@tgross35 tgross35 deleted the tests-and-const-extern branch November 26, 2024 22:07
@tamird
Copy link
Contributor

tamird commented Nov 26, 2024

Thanks for fixing. Please remember to yank the broken releases.

@tgross35
Copy link
Contributor Author

There was some other unintentional breakage in the huge cleanup refactoring, it's already yanked.

@tamird
Copy link
Contributor

tamird commented Nov 26, 2024

0.2.164 remains unyanked.

@tgross35
Copy link
Contributor Author

That version didn't update this feature 0.2.163...0.2.164

@tamird
Copy link
Contributor

tamird commented Nov 26, 2024

Ah, thanks for clarifying. I thought the regression was first noticed after release but it was before.

@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review stable-applied This PR has been cherry-picked to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

libc crate tests do not run (or even compile) on linux targets in CI
4 participants