Skip to content

Commit

Permalink
Normalize paths in diagnostics CLI output (#4709)
Browse files Browse the repository at this point in the history
Summary:
This should fix the current breakage of our windows tests. One thing I'm not sure about is if this will cause any problems with things like clickable file paths in the terminal on Windows.

Pull Request resolved: #4709

Test Plan: rust tests pass on Windows GitHub CI https://github.com/facebook/relay/actions/runs/9420850672/job/25953760675?pr=4709

Reviewed By: tyao1

Differential Revision: D58296386

Pulled By: captbaritone

fbshipit-source-id: 0b2c731127f1063731a51ea23fe9898d0b46cfa2
  • Loading branch information
captbaritone authored and facebook-github-bot committed Jun 7, 2024
1 parent 4bf4703 commit 7b65101
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions compiler/crates/graphql-cli/src/diagnostic_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<TSources: Sources> DiagnosticPrinter<TSources> {
writeln!(
writer,
" {}{}",
location.source_location().path().underline(),
normalize_path(location.source_location().path()).underline(),
format!(":{}:{}", range.start.line + 1, range.start.character + 1).dimmed()
)?;
source_printer.write_span_with_highlight_style(
Expand All @@ -99,7 +99,7 @@ impl<TSources: Sources> DiagnosticPrinter<TSources> {
writeln!(
writer,
"{}: <missing source>",
location.source_location().path()
normalize_path(location.source_location().path())
)?;
}
Ok(())
Expand All @@ -118,3 +118,9 @@ where
self(source_location)
}
}

/// Normalize Windows paths to Unix style. This is important for stable test
/// output across Mac/Windows/Linux.
fn normalize_path(path: &str) -> String {
path.replace("\\", "/")
}

0 comments on commit 7b65101

Please sign in to comment.