From e74a1c083bd761ac15fc02e014965977edd12508 Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Mon, 13 May 2024 11:36:30 +0200 Subject: [PATCH] PathFragment: test Windows mixed separator On Windows, if a user were to specify a PathFragment with mixed separator such as ``` bazel build --profile='C:/foo\\bar' //... ``` then the profile file will be written as `bar` and recorded in BuildToolLogs event as so. Provide a test that demonstrates the current behavior to discuss whether this is "correct" or not. --- .../google/devtools/build/lib/vfs/PathFragmentWindowsTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentWindowsTest.java b/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentWindowsTest.java index a8dc24fa1870b5..14ef5c44dfffa5 100644 --- a/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentWindowsTest.java +++ b/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentWindowsTest.java @@ -193,6 +193,9 @@ public void testBasenameWindows() throws Exception { assertThat(create("C:/foo").getBaseName()).isEqualTo("foo"); // Never return the drive name as a basename. assertThat(create("C:/").getBaseName()).isEmpty(); + // Mix usage of Windows and Unix separator is valid + assertThat(create("C:/foo\\bar").getBaseName()).isEqualTo("bar"); + assertThat(create("C:\\foo\\bar/baz").getBaseName()).isEqualTo("baz"); } @Test