From b179cd175ab873047423193010de1463ed1eb0be Mon Sep 17 00:00:00 2001 From: Tom Scanlan Date: Sat, 25 Nov 2023 17:20:51 -0500 Subject: [PATCH] review and remove ignored tests in rustfix * reduce time in proptest * delete edition dir * remove refs to fixmode::EDITION --- crates/rustfix/src/replace.rs | 4 +-- crates/rustfix/tests/edition/.gitignore | 2 -- crates/rustfix/tests/parse_and_replace.rs | 30 +++++++---------------- 3 files changed, 10 insertions(+), 26 deletions(-) delete mode 100644 crates/rustfix/tests/edition/.gitignore diff --git a/crates/rustfix/src/replace.rs b/crates/rustfix/src/replace.rs index 01a781f7c09..897506dc1d7 100644 --- a/crates/rustfix/src/replace.rs +++ b/crates/rustfix/src/replace.rs @@ -312,18 +312,16 @@ mod tests { proptest! { #[test] - #[ignore] fn new_to_vec_roundtrip(ref s in "\\PC*") { assert_eq!(s.as_bytes(), Data::new(s.as_bytes()).to_vec().as_slice()); } #[test] - #[ignore] fn replace_random_chunks( ref data in "\\PC*", ref replacements in prop::collection::vec( (any::<::std::ops::Range>(), any::>()), - 1..1337, + 1..100, ) ) { let mut d = Data::new(data.as_bytes()); diff --git a/crates/rustfix/tests/edition/.gitignore b/crates/rustfix/tests/edition/.gitignore deleted file mode 100644 index bfb599db14c..00000000000 --- a/crates/rustfix/tests/edition/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.recorded.json -*.recorded.rs diff --git a/crates/rustfix/tests/parse_and_replace.rs b/crates/rustfix/tests/parse_and_replace.rs index 8d7a2561f1f..0ff99a93b6d 100644 --- a/crates/rustfix/tests/parse_and_replace.rs +++ b/crates/rustfix/tests/parse_and_replace.rs @@ -14,7 +14,6 @@ use tracing::{debug, info, warn}; mod fixmode { pub const EVERYTHING: &str = "yolo"; - pub const EDITION: &str = "edition"; } mod settings { @@ -24,10 +23,10 @@ mod settings { pub const RECORD_FIXED_RUST: &str = "RUSTFIX_TEST_RECORD_FIXED_RUST"; } -fn compile(file: &Path, mode: &str) -> Result { +fn compile(file: &Path) -> Result { let tmp = tempdir()?; - let mut args: Vec = vec![ + let args: Vec = vec![ file.into(), "--error-format=json".into(), "--emit=metadata".into(), @@ -36,10 +35,6 @@ fn compile(file: &Path, mode: &str) -> Result { tmp.path().into(), ]; - if mode == fixmode::EDITION { - args.push("--edition=2018".into()); - } - let res = Command::new(env::var_os("RUSTC").unwrap_or("rustc".into())) .args(&args) .env("CLIPPY_DISABLE_DOCS_LINKS", "true") @@ -49,8 +44,8 @@ fn compile(file: &Path, mode: &str) -> Result { Ok(res) } -fn compile_and_get_json_errors(file: &Path, mode: &str) -> Result { - let res = compile(file, mode)?; +fn compile_and_get_json_errors(file: &Path) -> Result { + let res = compile(file)?; let stderr = String::from_utf8(res.stderr)?; if stderr.contains("is only accepted on the nightly compiler") { panic!("rustfix tests require a nightly compiler"); @@ -66,8 +61,8 @@ fn compile_and_get_json_errors(file: &Path, mode: &str) -> Result } } -fn compiles_without_errors(file: &Path, mode: &str) -> Result<(), Error> { - let res = compile(file, mode)?; +fn compiles_without_errors(file: &Path) -> Result<(), Error> { + let res = compile(file)?; match res.status.code() { Some(0) => Ok(()), @@ -140,8 +135,8 @@ fn test_rustfix_with_file>(file: P, mode: &str) -> Result<(), Err debug!("next up: {:?}", file); let code = read_file(file).context(format!("could not read {}", file.display()))?; - let errors = compile_and_get_json_errors(file, mode) - .context(format!("could compile {}", file.display()))?; + let errors = + compile_and_get_json_errors(file).context(format!("could compile {}", file.display()))?; let suggestions = rustfix::get_suggestions_from_json(&errors, &HashSet::new(), filter_suggestions) .context("could not load suggestions")?; @@ -191,7 +186,7 @@ fn test_rustfix_with_file>(file: P, mode: &str) -> Result<(), Err diff(fixed.trim(), expected_fixed.trim()) ); - compiles_without_errors(&fixed_file, mode)?; + compiles_without_errors(&fixed_file)?; Ok(()) } @@ -238,10 +233,3 @@ fn everything() { tracing_subscriber::fmt::init(); assert_fixtures("./tests/everything", fixmode::EVERYTHING); } - -#[test] -#[ignore = "Requires custom rustc build"] -fn edition() { - tracing_subscriber::fmt::init(); - assert_fixtures("./tests/edition", fixmode::EDITION); -}