Skip to content

Commit

Permalink
Attempt to fix Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Nov 20, 2023
1 parent 1260157 commit db2e157
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions crates/ruff_cli/tests/resolve_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ use std::str;
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
const BIN_NAME: &str = "ruff";

#[cfg(not(target_os = "windows"))]
const TEST_FILTERS: &[(&str, &str)] = &[(".*/resources/test/fixtures/", "[BASEPATH]/")];
#[cfg(target_os = "windows")]
const TEST_FILTERS: &[(&str, &str)] = &[
(".*\\resources\\test\\fixtures\\", "[BASEPATH]\\"),
("\\", "/"),
];

#[test]
fn check_project_include_defaults() {
// Defaults to checking the current working directory
Expand All @@ -18,7 +26,7 @@ fn check_project_include_defaults() {
// The nested project should all be checked instead of respecting the parent includes

insta::with_settings!({
filters => vec![(".*/resources/test/fixtures/", "[BASEPATH]/")]
filters => TEST_FILTERS.to_vec()
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--show-files"]).current_dir(Path::new("./resources/test/fixtures/include-test")), @r###"
Expand All @@ -40,7 +48,7 @@ fn check_project_respects_direct_paths() {
// Given a direct path not included in the project `includes`, it should be checked

insta::with_settings!({
filters => vec![(".*/resources/test/fixtures/", "[BASEPATH]/")]
filters => TEST_FILTERS.to_vec()
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--show-files", "b.py"]).current_dir(Path::new("./resources/test/fixtures/include-test")), @r###"
Expand All @@ -59,7 +67,7 @@ fn check_project_respects_subdirectory_includes() {
// Given a direct path to a subdirectory, the include should be respected

insta::with_settings!({
filters => vec![(".*/resources/test/fixtures/", "[BASEPATH]/")]
filters => TEST_FILTERS.to_vec()
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--show-files", "subdirectory"]).current_dir(Path::new("./resources/test/fixtures/include-test")), @r###"
Expand All @@ -78,7 +86,7 @@ fn check_project_from_project_subdirectory_respects_includes() {
// Run from a project subdirectory, the include specified in the parent directory should be respected

insta::with_settings!({
filters => vec![(".*/resources/test/fixtures/", "[BASEPATH]/")]
filters => TEST_FILTERS.to_vec()
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--show-files"]).current_dir(Path::new("./resources/test/fixtures/include-test/subdirectory")), @r###"
Expand Down

0 comments on commit db2e157

Please sign in to comment.