Skip to content

Commit 8bfa91b

Browse files
weihangloepage
authored andcommitted
test(rustfix): run some tests only on nightly
1 parent c99b2e5 commit 8bfa91b

6 files changed

+35
-2
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rustfix/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustfix"
3-
version = "0.8.3"
3+
version = "0.8.4"
44
authors = [
55
"Pascal Hertleif <[email protected]>",
66
"Oliver Schneider <[email protected]>",

crates/rustfix/tests/parse_and_replace.rs

+33
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ mod settings {
4545
pub const BLESS: &str = "RUSTFIX_TEST_BLESS";
4646
}
4747

48+
static mut VERSION: (u32, bool) = (0, false);
49+
50+
// Temporarily copy from `cargo_test_macro::version`.
51+
fn version() -> (u32, bool) {
52+
static INIT: std::sync::Once = std::sync::Once::new();
53+
INIT.call_once(|| {
54+
let output = Command::new("rustc")
55+
.arg("-V")
56+
.output()
57+
.expect("cargo should run");
58+
let stdout = std::str::from_utf8(&output.stdout).expect("utf8");
59+
let vers = stdout.split_whitespace().skip(1).next().unwrap();
60+
let is_nightly = option_env!("CARGO_TEST_DISABLE_NIGHTLY").is_none()
61+
&& (vers.contains("-nightly") || vers.contains("-dev"));
62+
let minor = vers.split('.').skip(1).next().unwrap().parse().unwrap();
63+
unsafe { VERSION = (minor, is_nightly) }
64+
});
65+
unsafe { VERSION }
66+
}
67+
4868
fn compile(file: &Path) -> Result<Output, Error> {
4969
let tmp = tempdir()?;
5070

@@ -220,7 +240,20 @@ fn assert_fixtures(dir: &str, mode: &str) {
220240
.unwrap();
221241
let mut failures = 0;
222242

243+
let is_not_nightly = !version().1;
244+
223245
for file in &files {
246+
if file
247+
.file_stem()
248+
.unwrap()
249+
.to_str()
250+
.unwrap()
251+
.ends_with(".nightly")
252+
&& is_not_nightly
253+
{
254+
info!("skipped: {file:?}");
255+
continue;
256+
}
224257
if let Err(err) = test_rustfix_with_file(file, mode) {
225258
println!("failed: {}", file.display());
226259
warn!("{:?}", err);

0 commit comments

Comments
 (0)