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 3afcc3739..18d7fe0d7 100644 --- a/tests/unit/Compiler/ToolchainTests.cpp +++ b/tests/unit/Compiler/ToolchainTests.cpp @@ -77,9 +77,44 @@ 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 + + #if __cplusplus < 202302L + #error "C++23 required" + #endif + + 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");