Skip to content

Commit

Permalink
Fix snapshots on Windows?
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Feb 1, 2024
1 parent d467bc6 commit 8f9228b
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions crates/ruff/tests/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ use tempfile::TempDir;
const BIN_NAME: &str = "ruff";
const STDIN_BASE_OPTIONS: &[&str] = &["--no-cache", "--output-format", "concise"];

fn tempdir_filter(tempdir: &TempDir) -> String {
format!(r"{}(\/)", tempdir.path().to_str().unwrap())
}

#[test]
fn top_level_options() -> Result<()> {
let tempdir = TempDir::new()?;
Expand All @@ -28,7 +32,7 @@ inline-quotes = "single"
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
Expand Down Expand Up @@ -72,7 +76,7 @@ inline-quotes = "single"
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
Expand Down Expand Up @@ -112,7 +116,7 @@ inline-quotes = "single"
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
Expand Down Expand Up @@ -158,7 +162,7 @@ inline-quotes = "single"
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
Expand Down Expand Up @@ -237,7 +241,7 @@ OTHER = "OTHER"
fs::write(out_dir.join("a.py"), r#"a = "a""#)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.current_dir(tempdir.path())
Expand Down Expand Up @@ -284,7 +288,7 @@ inline-quotes = "single"
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.current_dir(tempdir.path())
Expand Down Expand Up @@ -332,7 +336,7 @@ max-line-length = 100
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(STDIN_BASE_OPTIONS)
Expand Down Expand Up @@ -377,7 +381,7 @@ inline-quotes = "single"
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.current_dir(tempdir.path())
Expand Down Expand Up @@ -426,7 +430,7 @@ inline-quotes = "single"
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.current_dir(tempdir.path())
Expand Down Expand Up @@ -486,7 +490,7 @@ ignore = ["D203", "D212"]
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.current_dir(sub_dir)
Expand Down Expand Up @@ -559,7 +563,7 @@ include = ["*.ipy"]
)?;

insta::with_settings!({
filters => vec![(tempdir.path().to_str().unwrap(), "[TMP]")]
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.current_dir(tempdir.path())
Expand Down

0 comments on commit 8f9228b

Please sign in to comment.