[llvm] [Windows][test] Fix "LLVM" test failures when LLVM_WINDOWS_PREFER_FORWARD_SLASH is ON (PR #184556)
Junji Watanabe via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 22:02:16 PDT 2026
https://github.com/Jwata updated https://github.com/llvm/llvm-project/pull/184556
>From af056838c7cd4deeb29e92fd90c1b5d737cca022 Mon Sep 17 00:00:00 2001
From: Junji Watanabe <jwata at google.com>
Date: Wed, 4 Mar 2026 13:22:33 +0900
Subject: [PATCH 1/7] fix llvm tests
---
llvm/test/tools/llvm-cov/directory_coverage.win.test | 8 ++++----
llvm/test/tools/llvm-cov/native_separators.c | 6 +++---
.../X86/source-interleave-prefix-windows.test | 2 +-
llvm/unittests/Support/CommandLineTest.cpp | 4 ++--
llvm/unittests/Support/Path.cpp | 7 ++++++-
5 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/llvm/test/tools/llvm-cov/directory_coverage.win.test b/llvm/test/tools/llvm-cov/directory_coverage.win.test
index f948bdcae3a58..739375a037f48 100644
--- a/llvm/test/tools/llvm-cov/directory_coverage.win.test
+++ b/llvm/test/tools/llvm-cov/directory_coverage.win.test
@@ -23,13 +23,13 @@
-# HTML-TOP: coverage\index.html
+# HTML-TOP: coverage{{[/\\]}}index.html
-# ROOT: a0\a1\a2.cc
-# ROOT: b0\
+# ROOT: a0{{[/\\]}}a1{{[/\\]}}a2.cc
+# ROOT: b0{{[/\\]}}
# ROOT-NOT: b1_1.cc
# ROOT-NOT: b1_2.cc
-# ROOT: c0\c1\
+# ROOT: c0{{[/\\]}}c1{{[/\\]}}
# ROOT-NOT: c2_1.cc
# ROOT-NOT: b2_2.cc
# ROOT: main.cc
diff --git a/llvm/test/tools/llvm-cov/native_separators.c b/llvm/test/tools/llvm-cov/native_separators.c
index 3c768e1014b92..b6ad175aa8f33 100644
--- a/llvm/test/tools/llvm-cov/native_separators.c
+++ b/llvm/test/tools/llvm-cov/native_separators.c
@@ -13,8 +13,8 @@
// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S %s -o %t.dir
// RUN: FileCheck -check-prefixes=HTML -input-file=%t.dir/coverage/tmp/native_separators.c.html %s
-// TEXT-INDEX: \tmp\native_separators.c
-// HTML-INDEX: >tmp\native_separators.c</a>
-// HTML: <pre>\tmp\native_separators.c</pre>
+// TEXT-INDEX: {{[/\\]}}tmp{{[/\\]}}native_separators.c
+// HTML-INDEX: >tmp{{[/\\]}}native_separators.c</a>
+// HTML: <pre>{{[/\\]}}tmp{{[/\\]}}native_separators.c</pre>
int main() {}
diff --git a/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix-windows.test b/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix-windows.test
index 0f8952daec42e..db5265b26d5a3 100644
--- a/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix-windows.test
+++ b/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix-windows.test
@@ -7,5 +7,5 @@
; RUN: sed -e "s,SRC_COMPDIR,/Inputs,g" %p/Inputs/source-interleave.ll > %t.ll
; RUN: llc -o %t.o -filetype=obj -mtriple=x86_64-pc-linux %t.ll
; RUN: llvm-objdump --prefix 'myprefix/\' --source %t.o 2>&1 | FileCheck %s -DFILE=%t.o -DPREFIX='myprefix'
-; CHECK: warning: '[[FILE]]': failed to find source [[PREFIX]]/Inputs\source-interleave-x86_64.c
+; CHECK: warning: '[[FILE]]': failed to find source [[PREFIX]]{{[/\\]}}Inputs{{[/\\]}}source-interleave-x86_64.c
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index fca2d298c460e..f2effbdddfbbf 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -1015,7 +1015,7 @@ TEST(CommandLineTest, ResponseFiles) {
TEST(CommandLineTest, RecursiveResponseFiles) {
vfs::InMemoryFileSystem FS;
#ifdef _WIN32
- const char *TestRoot = "C:\\";
+ const char *TestRoot = LLVM_WINDOWS_PREFER_FORWARD_SLASH ? "C:/" : "C:\\";
#else
const char *TestRoot = "/";
#endif
@@ -1085,7 +1085,7 @@ TEST(CommandLineTest, RecursiveResponseFiles) {
TEST(CommandLineTest, ResponseFilesAtArguments) {
vfs::InMemoryFileSystem FS;
#ifdef _WIN32
- const char *TestRoot = "C:\\";
+ const char *TestRoot = LLVM_WINDOWS_PREFER_FORWARD_SLASH ? "C:/" : "C:\\";
#else
const char *TestRoot = "/";
#endif
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index b196dc1d5452b..bb825a1b1e65c 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -11,6 +11,7 @@
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Config/config.h"
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ConvertUTF.h"
@@ -2792,7 +2793,9 @@ TEST_F(FileSystemTest, makeLongFormPath) {
// Setup: A test directory longer than 8 characters for which a distinct
// short 8.3 form name will be created on Windows. Typically, 123456~1.
- constexpr const char *OneDir = "\\123456789"; // >8 chars
+ const char *OneDir = LLVM_WINDOWS_PREFER_FORWARD_SLASH
+ ? "/123456789"
+ : "\\123456789"; // >8 chars
// Setup: Create a path where even if all components were reduced to short 8.3
// form names, the total length would exceed MAX_PATH.
@@ -2825,6 +2828,8 @@ TEST_F(FileSystemTest, makeLongFormPath) {
ASSERT_FALSE(DotAndDotDot.empty())
<< "Expected short 8.3 form path for test directory.";
auto ContainsDotAndDotDot = [](llvm::StringRef S) {
+ if (LLVM_WINDOWS_PREFER_FORWARD_SLASH)
+ return S.contains("/./") && S.contains("/../");
return S.contains("\\.\\") && S.contains("\\..\\");
};
ASSERT_TRUE(ContainsDotAndDotDot(DotAndDotDot))
>From 9215dd91fd5e5add3d015840bf167b28814fec61 Mon Sep 17 00:00:00 2001
From: Junji Watanabe <jwata at google.com>
Date: Fri, 6 Mar 2026 11:11:53 +0900
Subject: [PATCH 2/7] Disable llvm-cov/native_separators test
---
llvm/test/lit.site.cfg.py.in | 3 +++
llvm/test/tools/llvm-cov/native_separators.c | 8 ++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in
index 6fe48f21cc685..88ca6f0dad3f0 100644
--- a/llvm/test/lit.site.cfg.py.in
+++ b/llvm/test/lit.site.cfg.py.in
@@ -70,6 +70,9 @@ config.has_logf128 = @LLVM_HAS_LOGF128@
config.have_ondisk_cas = @LLVM_ENABLE_ONDISK_CAS@
import lit.llvm
+if lit.util.pythonize_bool("@LLVM_WINDOWS_PREFER_FORWARD_SLASH@"):
+ config.available_features.add("windows-prefer-forward-slash")
+
lit.llvm.initialize(lit_config, config)
# Let the main config do the real work.
diff --git a/llvm/test/tools/llvm-cov/native_separators.c b/llvm/test/tools/llvm-cov/native_separators.c
index b6ad175aa8f33..0f81b8bdcb5fb 100644
--- a/llvm/test/tools/llvm-cov/native_separators.c
+++ b/llvm/test/tools/llvm-cov/native_separators.c
@@ -3,7 +3,7 @@
// This test is Windows-only. It checks that all paths, which are generated
// in the index and source coverage reports, are native path. For example,
// on Windows all '/' are converted to '\'.
-// REQUIRES: system-windows
+// REQUIRES: system-windows, !windows-prefer-forward-slash
// RUN: llvm-profdata merge %S/Inputs/double_dots.proftext -o %t.profdata
// RUN: llvm-cov show %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -o %t.dir
@@ -13,8 +13,8 @@
// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S %s -o %t.dir
// RUN: FileCheck -check-prefixes=HTML -input-file=%t.dir/coverage/tmp/native_separators.c.html %s
-// TEXT-INDEX: {{[/\\]}}tmp{{[/\\]}}native_separators.c
-// HTML-INDEX: >tmp{{[/\\]}}native_separators.c</a>
-// HTML: <pre>{{[/\\]}}tmp{{[/\\]}}native_separators.c</pre>
+// TEXT-INDEX: \tmp\native_separators.c
+// HTML-INDEX: >tmp\native_separators.c</a>
+// HTML: <pre>\tmp\native_separators.c</pre>
int main() {}
>From dc7b7acd66139f0ea80cdfe5a63d538ac86125ee Mon Sep 17 00:00:00 2001
From: Junji Watanabe <jwata at google.com>
Date: Fri, 6 Mar 2026 14:33:19 +0900
Subject: [PATCH 3/7] skip directory_coverage.win.test
---
llvm/test/tools/llvm-cov/directory_coverage.win.test | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/llvm/test/tools/llvm-cov/directory_coverage.win.test b/llvm/test/tools/llvm-cov/directory_coverage.win.test
index 739375a037f48..5551cac0270cb 100644
--- a/llvm/test/tools/llvm-cov/directory_coverage.win.test
+++ b/llvm/test/tools/llvm-cov/directory_coverage.win.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-windows
+# REQUIRES: system-windows, !windows-prefer-forward-slash
# RUN: mkdir -p %t
# RUN: llvm-cov show %S/Inputs/directory_coverage/main.covmapping \
@@ -23,13 +23,13 @@
-# HTML-TOP: coverage{{[/\\]}}index.html
+# HTML-TOP: coverage\index.html
-# ROOT: a0{{[/\\]}}a1{{[/\\]}}a2.cc
-# ROOT: b0{{[/\\]}}
+# ROOT: a0\a1\a2.cc
+# ROOT: b0\
# ROOT-NOT: b1_1.cc
# ROOT-NOT: b1_2.cc
-# ROOT: c0{{[/\\]}}c1{{[/\\]}}
+# ROOT: c0\c1\
# ROOT-NOT: c2_1.cc
# ROOT-NOT: b2_2.cc
# ROOT: main.cc
>From b9adb11593ef34ed8cbed2aa22960f9186a62939 Mon Sep 17 00:00:00 2001
From: Junji Watanabe <jwata at google.com>
Date: Wed, 4 Mar 2026 13:22:33 +0900
Subject: [PATCH 4/7] fix llvm tests
---
llvm/test/tools/llvm-cov/directory_coverage.win.test | 8 ++++----
llvm/test/tools/llvm-cov/native_separators.c | 6 +++---
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/llvm/test/tools/llvm-cov/directory_coverage.win.test b/llvm/test/tools/llvm-cov/directory_coverage.win.test
index 5551cac0270cb..b2953ab70417b 100644
--- a/llvm/test/tools/llvm-cov/directory_coverage.win.test
+++ b/llvm/test/tools/llvm-cov/directory_coverage.win.test
@@ -23,13 +23,13 @@
-# HTML-TOP: coverage\index.html
+# HTML-TOP: coverage{{[/\\]}}index.html
-# ROOT: a0\a1\a2.cc
-# ROOT: b0\
+# ROOT: a0{{[/\\]}}a1{{[/\\]}}a2.cc
+# ROOT: b0{{[/\\]}}
# ROOT-NOT: b1_1.cc
# ROOT-NOT: b1_2.cc
-# ROOT: c0\c1\
+# ROOT: c0{{[/\\]}}c1{{[/\\]}}
# ROOT-NOT: c2_1.cc
# ROOT-NOT: b2_2.cc
# ROOT: main.cc
diff --git a/llvm/test/tools/llvm-cov/native_separators.c b/llvm/test/tools/llvm-cov/native_separators.c
index 0f81b8bdcb5fb..f55a28b586e14 100644
--- a/llvm/test/tools/llvm-cov/native_separators.c
+++ b/llvm/test/tools/llvm-cov/native_separators.c
@@ -13,8 +13,8 @@
// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S %s -o %t.dir
// RUN: FileCheck -check-prefixes=HTML -input-file=%t.dir/coverage/tmp/native_separators.c.html %s
-// TEXT-INDEX: \tmp\native_separators.c
-// HTML-INDEX: >tmp\native_separators.c</a>
-// HTML: <pre>\tmp\native_separators.c</pre>
+// TEXT-INDEX: {{[/\\]}}tmp{{[/\\]}}native_separators.c
+// HTML-INDEX: >tmp{{[/\\]}}native_separators.c</a>
+// HTML: <pre>{{[/\\]}}tmp{{[/\\]}}native_separators.c</pre>
int main() {}
>From ace8ab69effe4df010abc3ad3728723cbdc95a9e Mon Sep 17 00:00:00 2001
From: Junji Watanabe <jwata at google.com>
Date: Fri, 6 Mar 2026 11:11:53 +0900
Subject: [PATCH 5/7] Disable llvm-cov/native_separators test
---
llvm/test/tools/llvm-cov/native_separators.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/test/tools/llvm-cov/native_separators.c b/llvm/test/tools/llvm-cov/native_separators.c
index f55a28b586e14..0f81b8bdcb5fb 100644
--- a/llvm/test/tools/llvm-cov/native_separators.c
+++ b/llvm/test/tools/llvm-cov/native_separators.c
@@ -13,8 +13,8 @@
// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S %s -o %t.dir
// RUN: FileCheck -check-prefixes=HTML -input-file=%t.dir/coverage/tmp/native_separators.c.html %s
-// TEXT-INDEX: {{[/\\]}}tmp{{[/\\]}}native_separators.c
-// HTML-INDEX: >tmp{{[/\\]}}native_separators.c</a>
-// HTML: <pre>{{[/\\]}}tmp{{[/\\]}}native_separators.c</pre>
+// TEXT-INDEX: \tmp\native_separators.c
+// HTML-INDEX: >tmp\native_separators.c</a>
+// HTML: <pre>\tmp\native_separators.c</pre>
int main() {}
>From c36c37310641950ef9fca85da03f95365705ad31 Mon Sep 17 00:00:00 2001
From: Junji Watanabe <jwata at google.com>
Date: Fri, 6 Mar 2026 14:33:19 +0900
Subject: [PATCH 6/7] skip directory_coverage.win.test
---
llvm/test/tools/llvm-cov/directory_coverage.win.test | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/test/tools/llvm-cov/directory_coverage.win.test b/llvm/test/tools/llvm-cov/directory_coverage.win.test
index b2953ab70417b..5551cac0270cb 100644
--- a/llvm/test/tools/llvm-cov/directory_coverage.win.test
+++ b/llvm/test/tools/llvm-cov/directory_coverage.win.test
@@ -23,13 +23,13 @@
-# HTML-TOP: coverage{{[/\\]}}index.html
+# HTML-TOP: coverage\index.html
-# ROOT: a0{{[/\\]}}a1{{[/\\]}}a2.cc
-# ROOT: b0{{[/\\]}}
+# ROOT: a0\a1\a2.cc
+# ROOT: b0\
# ROOT-NOT: b1_1.cc
# ROOT-NOT: b1_2.cc
-# ROOT: c0{{[/\\]}}c1{{[/\\]}}
+# ROOT: c0\c1\
# ROOT-NOT: c2_1.cc
# ROOT-NOT: b2_2.cc
# ROOT: main.cc
>From 984831fd20ebe1570a531a1357cb200d33f245db Mon Sep 17 00:00:00 2001
From: Junji Watanabe <jwata at google.com>
Date: Tue, 28 Apr 2026 13:54:39 +0900
Subject: [PATCH 7/7] [llvm-cov] Fix Windows path separator issues in tests
---
.../llvm-cov/directory_coverage.win.test | 26 +++++++++----------
llvm/test/tools/llvm-cov/native_separators.c | 14 +++++-----
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/llvm/test/tools/llvm-cov/directory_coverage.win.test b/llvm/test/tools/llvm-cov/directory_coverage.win.test
index 5551cac0270cb..572836cdb6033 100644
--- a/llvm/test/tools/llvm-cov/directory_coverage.win.test
+++ b/llvm/test/tools/llvm-cov/directory_coverage.win.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-windows, !windows-prefer-forward-slash
+# REQUIRES: system-windows
# RUN: mkdir -p %t
# RUN: llvm-cov show %S/Inputs/directory_coverage/main.covmapping \
@@ -11,25 +11,25 @@
# RUN: --path-equivalence=/tmp/directory_coverage,%S/Inputs/directory_coverage \
# RUN: --format=html --show-directory-coverage -o %t/report-html
-# RUN: FileCheck --input-file %t/report-text/index.txt %s --check-prefix=ROOT
-# RUN: FileCheck --input-file %t/report-text/coverage/tmp/directory_coverage/index.txt %s --check-prefix=ROOT
-# RUN: FileCheck --input-file %t/report-text/coverage/tmp/directory_coverage/b0/index.txt %s --check-prefix=B0
-# RUN: FileCheck --input-file %t/report-text/coverage/tmp/directory_coverage/c0/c1/index.txt %s --check-prefix=C1
+# RUN: FileCheck --input-file %t/report-text/index.txt %s --check-prefix=ROOT -DSEP=%{fs-sep}
+# RUN: FileCheck --input-file %t/report-text/coverage/tmp/directory_coverage/index.txt %s --check-prefix=ROOT -DSEP=%{fs-sep}
+# RUN: FileCheck --input-file %t/report-text/coverage/tmp/directory_coverage/b0/index.txt %s --check-prefix=B0 -DSEP=%{fs-sep}
+# RUN: FileCheck --input-file %t/report-text/coverage/tmp/directory_coverage/c0/c1/index.txt %s --check-prefix=C1 -DSEP=%{fs-sep}
-# RUN: FileCheck --input-file %t/report-html/index.html %s --check-prefix=HTML-TOP --allow-empty
-# RUN: FileCheck --input-file %t/report-html/coverage/tmp/directory_coverage/index.html %s --check-prefix=ROOT
-# RUN: FileCheck --input-file %t/report-html/coverage/tmp/directory_coverage/b0/index.html %s --check-prefix=B0
-# RUN: FileCheck --input-file %t/report-html/coverage/tmp/directory_coverage/c0/c1/index.html %s --check-prefix=C1
+# RUN: FileCheck --input-file %t/report-html/index.html %s --check-prefix=HTML-TOP --allow-empty -DSEP=%{fs-sep}
+# RUN: FileCheck --input-file %t/report-html/coverage/tmp/directory_coverage/index.html %s --check-prefix=ROOT -DSEP=%{fs-sep}
+# RUN: FileCheck --input-file %t/report-html/coverage/tmp/directory_coverage/b0/index.html %s --check-prefix=B0 -DSEP=%{fs-sep}
+# RUN: FileCheck --input-file %t/report-html/coverage/tmp/directory_coverage/c0/c1/index.html %s --check-prefix=C1 -DSEP=%{fs-sep}
-# HTML-TOP: coverage\index.html
+# HTML-TOP: coverage[[SEP]]index.html
-# ROOT: a0\a1\a2.cc
-# ROOT: b0\
+# ROOT: a0[[SEP]]a1[[SEP]]a2.cc
+# ROOT: b0[[SEP]]
# ROOT-NOT: b1_1.cc
# ROOT-NOT: b1_2.cc
-# ROOT: c0\c1\
+# ROOT: c0[[SEP]]c1[[SEP]]
# ROOT-NOT: c2_1.cc
# ROOT-NOT: b2_2.cc
# ROOT: main.cc
diff --git a/llvm/test/tools/llvm-cov/native_separators.c b/llvm/test/tools/llvm-cov/native_separators.c
index 0f81b8bdcb5fb..018cf0a66fe44 100644
--- a/llvm/test/tools/llvm-cov/native_separators.c
+++ b/llvm/test/tools/llvm-cov/native_separators.c
@@ -3,18 +3,18 @@
// This test is Windows-only. It checks that all paths, which are generated
// in the index and source coverage reports, are native path. For example,
// on Windows all '/' are converted to '\'.
-// REQUIRES: system-windows, !windows-prefer-forward-slash
+// REQUIRES: system-windows
// RUN: llvm-profdata merge %S/Inputs/double_dots.proftext -o %t.profdata
// RUN: llvm-cov show %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -o %t.dir
-// RUN: FileCheck -check-prefixes=TEXT-INDEX -input-file=%t.dir/index.txt %s
+// RUN: FileCheck -check-prefixes=TEXT-INDEX -input-file=%t.dir/index.txt -DSEP=%{fs-sep} %s
// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S %S/../llvm-"config"/../llvm-"cov"/native_separators.c -o %t.dir
-// RUN: FileCheck -check-prefixes=HTML-INDEX -input-file=%t.dir/index.html %s
+// RUN: FileCheck -check-prefixes=HTML-INDEX -input-file=%t.dir/index.html -DSEP=%{fs-sep} %s
// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S %s -o %t.dir
-// RUN: FileCheck -check-prefixes=HTML -input-file=%t.dir/coverage/tmp/native_separators.c.html %s
+// RUN: FileCheck -check-prefixes=HTML -input-file=%t.dir/coverage/tmp/native_separators.c.html -DSEP=%{fs-sep} %s
-// TEXT-INDEX: \tmp\native_separators.c
-// HTML-INDEX: >tmp\native_separators.c</a>
-// HTML: <pre>\tmp\native_separators.c</pre>
+// TEXT-INDEX: [[SEP]]tmp[[SEP]]native_separators.c
+// HTML-INDEX: >tmp[[SEP]]native_separators.c</a>
+// HTML: <pre>[[SEP]]tmp[[SEP]]native_separators.c</pre>
int main() {}
More information about the llvm-commits
mailing list