From 8a2f445c82c290dad11b7e707cd5a6687a969920 Mon Sep 17 00:00:00 2001 From: Yizhou Date: Thu, 22 Jan 2026 14:17:43 +0800 Subject: [PATCH 1/2] test: add MSCV case of compiler toolchain test --- tests/unit/Compiler/ToolchainTests.cpp | 36 +++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/unit/Compiler/ToolchainTests.cpp b/tests/unit/Compiler/ToolchainTests.cpp index 3afcc3739..a638bb50a 100644 --- a/tests/unit/Compiler/ToolchainTests.cpp +++ b/tests/unit/Compiler/ToolchainTests.cpp @@ -77,9 +77,39 @@ TEST_CASE(GCC, {.skip = !(CIEnvironment && (Windows || Linux))}) { ASSERT_TRUE(unit.diagnostics().empty()); }; -TEST_CASE(MSVC, {.skip = !CIEnvironment}) { - // TODO: add MSVC toolchain test when CI provides toolchain. -} +TEST_CASE(MSVC, {.skip = !CIEnvironment || !Windows}) { + auto file = fs::createTemporaryFile("clice", "cpp"); + if(!file) { + LOG_ERROR_RET(void(), "{}", file.error()); + } + + llvm::BumpPtrAllocator a; + llvm::StringSaver s(a); + auto arguments = toolchain::query_toolchain({ + .arguments = {"cl.exe", + "-std:c++23", + "/EHsc", + file->c_str()}, + .callback = [&](const char* str) { return s.save(str).data(); } + }); + + ASSERT_TRUE(arguments.size() > 1); + + CompilationParams params; + params.arguments_from_database = true; + params.arguments = arguments; + params.add_remapped_file(file->c_str(), R"( + #include + int main() { + std::cout << "Hello world!" << std::endl; + return 0; + } + )"); + + auto unit = compile(params); + ASSERT_TRUE(unit.completed()); + ASSERT_TRUE(unit.diagnostics().empty()); +}; TEST_CASE(Clang, {.skip = !CIEnvironment}) { auto file = fs::createTemporaryFile("clice", "cpp"); From 78741beae8b113499e1f00d437605b02f3e335b0 Mon Sep 17 00:00:00 2001 From: Yizhou Date: Thu, 22 Jan 2026 14:45:47 +0800 Subject: [PATCH 2/2] ci: activate MSVC environment --- .github/workflows/test-cmake.yml | 7 +++++++ tests/unit/Compiler/ToolchainTests.cpp | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/test-cmake.yml b/.github/workflows/test-cmake.yml index 928774029..f95dd33f1 100644 --- a/.github/workflows/test-cmake.yml +++ b/.github/workflows/test-cmake.yml @@ -16,10 +16,17 @@ jobs: - os: macos-15 build_type: Debug runs-on: ${{ matrix.os }} + defaults: + run: + shell: pwsh steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Setup MSVC Developer Environment (Windows) + if: matrix.os == 'windows-2025' + uses: ilammy/msvc-dev-cmd@v1 + - uses: ./.github/actions/setup-pixi - name: Build diff --git a/tests/unit/Compiler/ToolchainTests.cpp b/tests/unit/Compiler/ToolchainTests.cpp index a638bb50a..18d7fe0d7 100644 --- a/tests/unit/Compiler/ToolchainTests.cpp +++ b/tests/unit/Compiler/ToolchainTests.cpp @@ -100,6 +100,11 @@ TEST_CASE(MSVC, {.skip = !CIEnvironment || !Windows}) { params.arguments = arguments; params.add_remapped_file(file->c_str(), R"( #include + + #if __cplusplus < 202302L + #error "C++23 required" + #endif + int main() { std::cout << "Hello world!" << std::endl; return 0;