Skip to content

Commit

Permalink
review and remove ignored tests in rustfix
Browse files Browse the repository at this point in the history
* reduce time in proptest
* delete edition dir
* remove refs to fixmode::EDITION
  • Loading branch information
tompscanlan committed Nov 26, 2023
1 parent 463f307 commit b179cd1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
4 changes: 1 addition & 3 deletions crates/rustfix/src/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize>>(), any::<Vec<u8>>()),
1..1337,
1..100,
)
) {
let mut d = Data::new(data.as_bytes());
Expand Down
2 changes: 0 additions & 2 deletions crates/rustfix/tests/edition/.gitignore

This file was deleted.

30 changes: 9 additions & 21 deletions crates/rustfix/tests/parse_and_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use tracing::{debug, info, warn};

mod fixmode {
pub const EVERYTHING: &str = "yolo";
pub const EDITION: &str = "edition";
}

mod settings {
Expand All @@ -24,10 +23,10 @@ mod settings {
pub const RECORD_FIXED_RUST: &str = "RUSTFIX_TEST_RECORD_FIXED_RUST";
}

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

let mut args: Vec<OsString> = vec![
let args: Vec<OsString> = vec![
file.into(),
"--error-format=json".into(),
"--emit=metadata".into(),
Expand All @@ -36,10 +35,6 @@ fn compile(file: &Path, mode: &str) -> Result<Output, Error> {
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")
Expand All @@ -49,8 +44,8 @@ fn compile(file: &Path, mode: &str) -> Result<Output, Error> {
Ok(res)
}

fn compile_and_get_json_errors(file: &Path, mode: &str) -> Result<String, Error> {
let res = compile(file, mode)?;
fn compile_and_get_json_errors(file: &Path) -> Result<String, Error> {
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");
Expand All @@ -66,8 +61,8 @@ fn compile_and_get_json_errors(file: &Path, mode: &str) -> Result<String, Error>
}
}

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(()),
Expand Down Expand Up @@ -140,8 +135,8 @@ fn test_rustfix_with_file<P: AsRef<Path>>(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")?;
Expand Down Expand Up @@ -191,7 +186,7 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
diff(fixed.trim(), expected_fixed.trim())
);

compiles_without_errors(&fixed_file, mode)?;
compiles_without_errors(&fixed_file)?;

Ok(())
}
Expand Down Expand Up @@ -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);
}

0 comments on commit b179cd1

Please sign in to comment.