diff --git a/compiler/crates/graphql-test-helpers/src/project_fixture.rs b/compiler/crates/graphql-test-helpers/src/project_fixture.rs index 5c8ae68c3acbe..1f5544413469d 100644 --- a/compiler/crates/graphql-test-helpers/src/project_fixture.rs +++ b/compiler/crates/graphql-test-helpers/src/project_fixture.rs @@ -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; @@ -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'); } @@ -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, "/") +}