Skip to content

Commit

Permalink
Stabalize printing paths in fixture tests
Browse files Browse the repository at this point in the history
Reviewed By: alunyov

Differential Revision: D50176059

fbshipit-source-id: d6d8c54e79e20e338f10d63cdb58e8bcf206f7ed
  • Loading branch information
captbaritone authored and facebook-github-bot committed Oct 11, 2023
1 parent 780987a commit 51fca35
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion compiler/crates/graphql-test-helpers/src/project_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::path::MAIN_SEPARATOR;

use fnv::FnvHashMap;
use walkdir::WalkDir;
Expand Down Expand Up @@ -57,7 +58,7 @@ impl ProjectFixture {
let mut output: String = Default::default();

for (file_name, content) in sorted {
output.push_str(&format!("//- {}\n", file_name.to_string_lossy()));
output.push_str(&format!("//- {}\n", format_normalized_path(&file_name)));
output.push_str(&content);
output.push('\n');
}
Expand Down Expand Up @@ -104,3 +105,10 @@ impl ProjectFixture {
}
}
}

// Stringify a path such that it's stable across operating systems.
fn format_normalized_path(path: &Path) -> String {
path.to_string_lossy()
.to_string()
.replace(MAIN_SEPARATOR, "/")
}

0 comments on commit 51fca35

Please sign in to comment.