mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
parent
6ffdcc0e3e
commit
b03cec6ae9
2 changed files with 25 additions and 2 deletions
1
apps/oxlint/fixtures/linter/fix.js
Normal file
1
apps/oxlint/fixtures/linter/fix.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
debugger
|
||||
|
|
@ -265,8 +265,8 @@ mod test {
|
|||
let args = &["fixtures/linter"];
|
||||
let result = test(args);
|
||||
assert!(result.number_of_rules > 0);
|
||||
assert_eq!(result.number_of_files, 2);
|
||||
assert_eq!(result.number_of_warnings, 2);
|
||||
assert_eq!(result.number_of_files, 3);
|
||||
assert_eq!(result.number_of_warnings, 3);
|
||||
assert_eq!(result.number_of_errors, 0);
|
||||
}
|
||||
|
||||
|
|
@ -564,4 +564,26 @@ mod test {
|
|||
assert_eq!(result.number_of_warnings, 0);
|
||||
assert_eq!(result.number_of_errors, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fix() {
|
||||
use std::fs;
|
||||
let file = "fixtures/linter/fix.js";
|
||||
let args = &["--fix", file];
|
||||
let content = fs::read_to_string(file).unwrap();
|
||||
assert_eq!(&content, "debugger\n");
|
||||
|
||||
// Apply fix to the file.
|
||||
let _ = test(args);
|
||||
assert_eq!(fs::read_to_string(file).unwrap(), "\n");
|
||||
|
||||
// File should not be modified if no fix is applied.
|
||||
let modified_before = fs::metadata(file).unwrap().modified().unwrap();
|
||||
let _ = test(args);
|
||||
let modified_after = fs::metadata(file).unwrap().modified().unwrap();
|
||||
assert_eq!(modified_before, modified_after);
|
||||
|
||||
// Write the file back.
|
||||
fs::write(file, content).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue