[clang] [llvm] [clang][unittests] Build the libclang unit tests on Windows (PR #232809)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 17 08:03:41 PDT 2026
https://github.com/UebelAndre updated https://github.com/llvm/llvm-project/pull/232809
>From 240a83b45b7b462dd74d843bd6416948eb608575 Mon Sep 17 00:00:00 2001
From: UebelAndre <github at uebelandre.com>
Date: Fri, 16 Oct 2026 07:49:26 -0700
Subject: [PATCH 1/2] [clang][unittests] Build the libclang unit tests on
Windows
The remaining Windows failures are the VirtualFileOverlay tests, which
assume POSIX paths; those are skipped at runtime in a follow-up.
---
clang/unittests/CMakeLists.txt | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index b2fee01649abc6..91e1890e6b427b 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -97,9 +97,7 @@ add_subdirectory(CodeGen)
if(HAVE_CLANG_REPL_SUPPORT)
add_subdirectory(Interpreter)
endif()
-# FIXME: libclang unit tests are disabled on Windows due
-# to failures, mostly in libclang.VirtualFileOverlay_*.
-if(NOT WIN32 AND CLANG_TOOL_LIBCLANG_BUILD)
+if(CLANG_TOOL_LIBCLANG_BUILD)
add_subdirectory(libclang)
endif()
add_subdirectory(DirectoryWatcher)
>From 9f763a0f484ebfdb235c62acd9aba797aeeecd5a Mon Sep 17 00:00:00 2001
From: UebelAndre <github at uebelandre.com>
Date: Fri, 16 Oct 2026 07:49:27 -0700
Subject: [PATCH 2/2] [libclang][test] Skip the VirtualFileOverlay tests on
Windows
They assume POSIX paths. Move them to a fixture that skips on Windows
and drop the equivalent gtest filter from the Bazel target.
---
clang/unittests/libclang/LibclangTest.cpp | 27 ++++++++++++-------
.../clang/unittests/BUILD.bazel | 8 ------
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/clang/unittests/libclang/LibclangTest.cpp b/clang/unittests/libclang/LibclangTest.cpp
index 7ca90547379d9f..981a37fe3f22e2 100644
--- a/clang/unittests/libclang/LibclangTest.cpp
+++ b/clang/unittests/libclang/LibclangTest.cpp
@@ -78,9 +78,18 @@ struct TestVFO {
clang_VirtualFileOverlay_dispose(VFO);
}
};
+
+class VirtualFileOverlayTest : public ::testing::Test {
+protected:
+ void SetUp() override {
+#ifdef _WIN32
+ GTEST_SKIP() << "VirtualFileOverlay tests assume POSIX paths";
+#endif
+ }
+};
}
-TEST(libclang, VirtualFileOverlay_Basic) {
+TEST_F(VirtualFileOverlayTest, Basic) {
const char *contents =
"{\n"
" 'version': 0,\n"
@@ -102,7 +111,7 @@ TEST(libclang, VirtualFileOverlay_Basic) {
T.map("/path/virtual/foo.h", "/real/foo.h");
}
-TEST(libclang, VirtualFileOverlay_Unicode) {
+TEST_F(VirtualFileOverlayTest, Unicode) {
const char *contents =
"{\n"
" 'version': 0,\n"
@@ -124,13 +133,13 @@ TEST(libclang, VirtualFileOverlay_Unicode) {
T.map("/path/♫/☂.h", "/real/☂.h");
}
-TEST(libclang, VirtualFileOverlay_InvalidArgs) {
+TEST_F(VirtualFileOverlayTest, InvalidArgs) {
TestVFO T(nullptr);
T.mapError("/path/./virtual/../foo.h", "/real/foo.h",
CXError_InvalidArguments);
}
-TEST(libclang, VirtualFileOverlay_RemapDirectories) {
+TEST_F(VirtualFileOverlayTest, RemapDirectories) {
const char *contents =
"{\n"
" 'version': 0,\n"
@@ -182,7 +191,7 @@ TEST(libclang, VirtualFileOverlay_RemapDirectories) {
T.map("/path/virtual/dir/in/subdir/foo4.h", "/real/foo4.h");
}
-TEST(libclang, VirtualFileOverlay_CaseInsensitive) {
+TEST_F(VirtualFileOverlayTest, CaseInsensitive) {
const char *contents =
"{\n"
" 'version': 0,\n"
@@ -206,7 +215,7 @@ TEST(libclang, VirtualFileOverlay_CaseInsensitive) {
clang_VirtualFileOverlay_setCaseSensitivity(T.VFO, false);
}
-TEST(libclang, VirtualFileOverlay_SharedPrefix) {
+TEST_F(VirtualFileOverlayTest, SharedPrefix) {
const char *contents =
"{\n"
" 'version': 0,\n"
@@ -258,7 +267,7 @@ TEST(libclang, VirtualFileOverlay_SharedPrefix) {
T.map("/path/foobarbaz.h", "/real/foobarbaz.h");
}
-TEST(libclang, VirtualFileOverlay_AdjacentDirectory) {
+TEST_F(VirtualFileOverlayTest, AdjacentDirectory) {
const char *contents =
"{\n"
" 'version': 0,\n"
@@ -304,7 +313,7 @@ TEST(libclang, VirtualFileOverlay_AdjacentDirectory) {
T.map("/path/dir2/baz.h", "/real/baz.h");
}
-TEST(libclang, VirtualFileOverlay_TopLevel) {
+TEST_F(VirtualFileOverlayTest, TopLevel) {
const char *contents =
"{\n"
" 'version': 0,\n"
@@ -326,7 +335,7 @@ TEST(libclang, VirtualFileOverlay_TopLevel) {
T.map("/foo.h", "/real/foo.h");
}
-TEST(libclang, VirtualFileOverlay_Empty) {
+TEST_F(VirtualFileOverlayTest, Empty) {
const char *contents =
"{\n"
" 'version': 0,\n"
diff --git a/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel
index e5a749e160f02d..8fb365ee025801 100644
--- a/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel
@@ -580,14 +580,6 @@ cc_test(
) + [
"libclang/TestUtils.h",
],
- args = select({
- "@platforms//os:windows": [
- # Need to disable the VFS tests that don't use Windows friendly
- # paths. These are also disabled on Windows in the CMake build.
- "--gtest_filter=-*VirtualFileOverlay*",
- ],
- "//conditions:default": [],
- }),
deps = [
"//clang:libclang",
"//llvm:Support",
More information about the cfe-commits
mailing list