-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Enable --check-cfg
by default in UI tests
#124345
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1028,12 +1028,31 @@ impl<'test> TestCx<'test> { | |
} | ||
|
||
fn set_revision_flags(&self, cmd: &mut Command) { | ||
// Normalize revisions to be lowercase and replace `-`s with `_`s. | ||
// Otherwise the `--cfg` flag is not valid. | ||
let normalize_revision = |revision: &str| revision.to_lowercase().replace("-", "_"); | ||
Urgau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if let Some(revision) = self.revision { | ||
// Normalize revisions to be lowercase and replace `-`s with `_`s. | ||
// Otherwise the `--cfg` flag is not valid. | ||
let normalized_revision = revision.to_lowercase().replace("-", "_"); | ||
let normalized_revision = normalize_revision(revision); | ||
cmd.args(&["--cfg", &normalized_revision]); | ||
} | ||
|
||
if !self.props.no_auto_check_cfg { | ||
let mut check_cfg = String::with_capacity(25); | ||
|
||
// Generate `cfg(FALSE, REV1, ..., REVN)` (for all possible revisions) | ||
// | ||
// For compatibility reason we consider the `FALSE` cfg to be expected | ||
// since it is extensively used in the testsuite. | ||
check_cfg.push_str("cfg(FALSE"); | ||
Comment on lines
+1043
to
+1047
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any documentation for this special case? If not, could you please document this behavior in the dev-guide so that the knowledge of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not aware, nor was I able to find any documentation regarding
Sure, I will send a PR for that. EDIT: forget to send it, sorry There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rustc-dev-guide PR is up rust-lang/rustc-dev-guide#1966 |
||
for revision in &self.props.revisions { | ||
check_cfg.push_str(","); | ||
check_cfg.push_str(&normalize_revision(&revision)); | ||
} | ||
check_cfg.push_str(")"); | ||
|
||
cmd.args(&["--check-cfg", &check_cfg]); | ||
} | ||
} | ||
|
||
fn typecheck_source(&self, src: String) -> ProcRes { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// Check to see if we can get parameters from an @argsfile file | ||
// | ||
//@ check-pass | ||
//@ compile-flags: --cfg cmdline_set @{{src-base}}/argfile/commandline-argfile.args | ||
//@ compile-flags: --cfg cmdline_set --check-cfg=cfg(cmdline_set,unbroken) | ||
//@ compile-flags: @{{src-base}}/argfile/commandline-argfile.args | ||
|
||
#[cfg(not(cmdline_set))] | ||
compile_error!("cmdline_set not set"); | ||
|
||
#[cfg(not(unbroken))] | ||
compile_error!("unbroken not set"); | ||
|
||
fn main() { | ||
} | ||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// Check to see if we can get parameters from an @argsfile file | ||
// | ||
//@ build-pass | ||
//@ compile-flags: --cfg cmdline_set @{{src-base}}/argfile/commandline-argfile.args | ||
//@ compile-flags: --cfg cmdline_set --check-cfg=cfg(cmdline_set,unbroken) | ||
//@ compile-flags: @{{src-base}}/argfile/commandline-argfile.args | ||
|
||
#[cfg(not(cmdline_set))] | ||
compile_error!("cmdline_set not set"); | ||
|
||
#[cfg(not(unbroken))] | ||
compile_error!("unbroken not set"); | ||
|
||
fn main() { | ||
} | ||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
//@ run-pass | ||
//@ compile-flags: --cfg bar -D warnings | ||
//@ compile-flags: --cfg bar --check-cfg=cfg(bar) -D warnings | ||
|
||
#![cfg(bar)] | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
//@ check-pass | ||
|
||
#![allow(unexpected_cfgs)] // since we different cfgs | ||
|
||
macro_rules! mac { | ||
{} => { | ||
#[cfg(attr)] | ||
|
Uh oh!
There was an error while loading. Please reload this page.