Skip to content

Commit

Permalink
Added integration test for argfile cli expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
njgrisafi committed Sep 4, 2023
1 parent 6690646 commit 900fdd5
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions crates/ruff_cli/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,45 @@ fn unreadable_dir() -> Result<()> {
);
Ok(())
}

/// Read input using argfile
#[cfg(unix)]
#[test]
fn check_input_from_argfile() -> Result<()> {
let tempdir = TempDir::new()?;

// Create python files
let file_a_path = tempdir.path().join("a.py");
let file_b_path = tempdir.path().join("b.py");
fs::write(&file_a_path, b"import os")?;
fs::write(&file_b_path, b"print('hello, world!')")?;

// Create a the input file for argfile to expand
let input_file_path = tempdir.path().join("file_paths.txt");
let input_file_path_string = &input_file_path.display();
fs::write(
&input_file_path,
format!("{}\n{}", file_a_path.display(), file_b_path.display()),
)?;

// Generate the args with the argfile notation
let args = vec![
"check".to_string(),
"--no-cache".to_string(),
format!("@{}", input_file_path_string),
];

let mut cmd = Command::cargo_bin(BIN_NAME)?;
let output = cmd.args(args).write_stdin("").assert().failure();
assert_eq!(
str::from_utf8(&output.get_output().stdout)?,
format!(
"{}:1:8: F401 [*] `os` imported but unused
Found 1 error.
[*] 1 potentially fixable with the --fix option.
",
file_a_path.display()
)
);
Ok(())
}

0 comments on commit 900fdd5

Please sign in to comment.