Skip to content

Commit

Permalink
Fix Windows paths on individual rule tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedThree committed Jan 31, 2025
1 parent 2960a7e commit 4fde9c2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fortitude/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ use crate::{
settings::{FixMode, Settings, UnsafeFixes},
};

macro_rules! apply_common_filters {
{} => {
let mut settings = insta::Settings::clone_current();
// Convert windows paths to Unix Paths.
settings.add_filter(r"\\\\?([\w\d.])", "/$1");
let _bound = settings.bind_to_scope();
}
}

pub(crate) fn test_resource_path(path: impl AsRef<Path>) -> std::path::PathBuf {
Path::new("./resources/test/").join(path)
}
Expand All @@ -24,6 +33,7 @@ pub(crate) fn test_path(
rules: &[Rule],
settings: &Settings,
) -> Result<String> {
apply_common_filters!();
let path = test_resource_path("fixtures").join(path);
let source = read_to_string(&path)?;
let filename = path.to_string_lossy();
Expand Down

0 comments on commit 4fde9c2

Please sign in to comment.