Skip to content

Commit 3920bd5

Browse files
committed
Auto merge of #13047 - tompscanlan:rustfix-ignored-tests, r=weihanglo
review and remove ignored tests in rustfix ### What does this PR try to resolve? review ignored tests in rustfix crate per #13034. ### How should we test and review this PR? CI testing ### Additional information * Removed unproductive test in `parse_and_replace` * un-ignore proptests, and reduce runtime from ~2s to ~<.25s
2 parents 35ed69c + b179cd1 commit 3920bd5

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

crates/rustfix/src/replace.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -320,18 +320,16 @@ mod tests {
320320

321321
proptest! {
322322
#[test]
323-
#[ignore]
324323
fn new_to_vec_roundtrip(ref s in "\\PC*") {
325324
assert_eq!(s.as_bytes(), Data::new(s.as_bytes()).to_vec().as_slice());
326325
}
327326

328327
#[test]
329-
#[ignore]
330328
fn replace_random_chunks(
331329
ref data in "\\PC*",
332330
ref replacements in prop::collection::vec(
333331
(any::<::std::ops::Range<usize>>(), any::<Vec<u8>>()),
334-
1..1337,
332+
1..100,
335333
)
336334
) {
337335
let mut d = Data::new(data.as_bytes());

crates/rustfix/tests/edition/.gitignore

-2
This file was deleted.

crates/rustfix/tests/parse_and_replace.rs

+9-21
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use tracing::{debug, info, warn};
1313

1414
mod fixmode {
1515
pub const EVERYTHING: &str = "yolo";
16-
pub const EDITION: &str = "edition";
1716
}
1817

1918
mod settings {
@@ -23,10 +22,10 @@ mod settings {
2322
pub const RECORD_FIXED_RUST: &str = "RUSTFIX_TEST_RECORD_FIXED_RUST";
2423
}
2524

26-
fn compile(file: &Path, mode: &str) -> Result<Output, Error> {
25+
fn compile(file: &Path) -> Result<Output, Error> {
2726
let tmp = tempdir()?;
2827

29-
let mut args: Vec<OsString> = vec![
28+
let args: Vec<OsString> = vec![
3029
file.into(),
3130
"--error-format=json".into(),
3231
"--emit=metadata".into(),
@@ -35,10 +34,6 @@ fn compile(file: &Path, mode: &str) -> Result<Output, Error> {
3534
tmp.path().into(),
3635
];
3736

38-
if mode == fixmode::EDITION {
39-
args.push("--edition=2018".into());
40-
}
41-
4237
let res = Command::new(env::var_os("RUSTC").unwrap_or("rustc".into()))
4338
.args(&args)
4439
.env("CLIPPY_DISABLE_DOCS_LINKS", "true")
@@ -48,8 +43,8 @@ fn compile(file: &Path, mode: &str) -> Result<Output, Error> {
4843
Ok(res)
4944
}
5045

51-
fn compile_and_get_json_errors(file: &Path, mode: &str) -> Result<String, Error> {
52-
let res = compile(file, mode)?;
46+
fn compile_and_get_json_errors(file: &Path) -> Result<String, Error> {
47+
let res = compile(file)?;
5348
let stderr = String::from_utf8(res.stderr)?;
5449
if stderr.contains("is only accepted on the nightly compiler") {
5550
panic!("rustfix tests require a nightly compiler");
@@ -65,8 +60,8 @@ fn compile_and_get_json_errors(file: &Path, mode: &str) -> Result<String, Error>
6560
}
6661
}
6762

68-
fn compiles_without_errors(file: &Path, mode: &str) -> Result<(), Error> {
69-
let res = compile(file, mode)?;
63+
fn compiles_without_errors(file: &Path) -> Result<(), Error> {
64+
let res = compile(file)?;
7065

7166
match res.status.code() {
7267
Some(0) => Ok(()),
@@ -139,8 +134,8 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
139134

140135
debug!("next up: {:?}", file);
141136
let code = read_file(file).context(format!("could not read {}", file.display()))?;
142-
let errors = compile_and_get_json_errors(file, mode)
143-
.context(format!("could compile {}", file.display()))?;
137+
let errors =
138+
compile_and_get_json_errors(file).context(format!("could compile {}", file.display()))?;
144139
let suggestions =
145140
rustfix::get_suggestions_from_json(&errors, &HashSet::new(), filter_suggestions)
146141
.context("could not load suggestions")?;
@@ -190,7 +185,7 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
190185
diff(fixed.trim(), expected_fixed.trim())
191186
);
192187

193-
compiles_without_errors(&fixed_file, mode)?;
188+
compiles_without_errors(&fixed_file)?;
194189

195190
Ok(())
196191
}
@@ -237,10 +232,3 @@ fn everything() {
237232
tracing_subscriber::fmt::init();
238233
assert_fixtures("./tests/everything", fixmode::EVERYTHING);
239234
}
240-
241-
#[test]
242-
#[ignore = "Requires custom rustc build"]
243-
fn edition() {
244-
tracing_subscriber::fmt::init();
245-
assert_fixtures("./tests/edition", fixmode::EDITION);
246-
}

0 commit comments

Comments
 (0)