[llvm] [unittests] Fix a recent test on Windows with LLVM_WINDOWS_PREFER_FORWARD_SLASH (PR #224963)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 20 13:22:14 PDT 2026


https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/224963

This fixes errors like these:
```
Expected equality of these values:
  Context.Path
    Which is: "D:/a/llvm-mingw/llvm-mingw/llvm-project/build/unittests/Support/LLVMToolSession/./LLVMToolSessionTests.exe"
  ExecutablePath.c_str()
    Which is: "D:\\a\\llvm-mingw\\llvm-mingw\\llvm-project\\build\\unittests\\Support\\LLVMToolSession\\.\\LLVMToolSessionTests.exe"
```


>From c2157d565a8f01b4e013e600b339cdba4a4475fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Sun, 20 Sep 2026 20:13:47 +0000
Subject: [PATCH] [unittests] Fix a recent test on Windows with
 LLVM_WINDOWS_PREFER_FORWARD_SLASH

---
 .../unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp b/llvm/unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp
index d1ef91444c2f74..e0252324ed4037 100644
--- a/llvm/unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp
+++ b/llvm/unittests/Support/LLVMToolSession/LLVMToolSessionTest.cpp
@@ -58,7 +58,9 @@ int resetOptionsMain(int, char **, const ToolContext &) {
 int directMain(int Argc, char **Argv, const ToolContext &Context) {
   EXPECT_EQ(Argc, 1);
   EXPECT_STREQ(Argv[0], ExecutablePath.c_str());
-  EXPECT_STREQ(Context.Path, ExecutablePath.c_str());
+  SmallString<32> ExecutablePathBuf(ExecutablePath);
+  sys::path::make_preferred(ExecutablePathBuf);
+  EXPECT_STREQ(Context.Path, ExecutablePathBuf.c_str());
   EXPECT_FALSE(Context.NeedsPrependArg);
   return 0;
 }



More information about the llvm-commits mailing list