diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 4beae00e..47cc477d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -90,11 +90,12 @@ jobs: - name: Run tests if: matrix.os == 'windows-2025' run: | - ./build/bin/unit_tests.exe --test-dir="./tests/data" --resource-dir="./.llvm/lib/clang/20" + ./build/bin/unit_tests.exe --test-dir="./tests/data" uv run pytest -s --log-cli-level=INFO tests/integration --executable=./build/bin/clice.exe + shell: bash - name: Run tests if: matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-15' run: | - ./build/bin/unit_tests --test-dir="./tests/data" --resource-dir="./.llvm/lib/clang/20" + ./build/bin/unit_tests --test-dir="./tests/data" uv run pytest -s --log-cli-level=INFO tests/integration --executable=./build/bin/clice diff --git a/.github/workflows/xmake.yml b/.github/workflows/xmake.yml index 12461151..feb417f9 100644 --- a/.github/workflows/xmake.yml +++ b/.github/workflows/xmake.yml @@ -20,6 +20,42 @@ on: - "xmake.lua" jobs: + windows: + strategy: + matrix: + os: [windows-2025] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup xmake + uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: branch@master + actions-cache-folder: ".xmake-cache" + actions-cache-key: ${{ matrix.os }} + package-cache: true + package-cache-key: ${{ matrix.os }} + build-cache: true + build-cache-key: ${{ matrix.os }}-${{ matrix.build_type }} + + - name: Xmake configure + run: | + xmake config --yes --ci=y --toolchain=clang + + - name: Build clice + run: | + xmake build --verbose --diagnosis --all + + - name: Install uv for integration tests + uses: astral-sh/setup-uv@v6 + + - name: Run tests + run: xmake test --verbose + linux: strategy: matrix: @@ -60,43 +96,7 @@ jobs: - name: Xmake configure run: | - xmake config --yes --mode=${{ matrix.build_type }} --toolchain=clang-20 - - - name: Build clice - run: | - xmake build --verbose --diagnosis --all - - - name: Install uv for integration tests - uses: astral-sh/setup-uv@v6 - - - name: Run tests - run: xmake test --verbose - - windows: - strategy: - matrix: - os: [windows-2025] - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup xmake - uses: xmake-io/github-action-setup-xmake@v1 - with: - xmake-version: branch@master - actions-cache-folder: ".xmake-cache" - actions-cache-key: ${{ matrix.os }} - package-cache: true - package-cache-key: ${{ matrix.os }} - build-cache: true - build-cache-key: ${{ matrix.os }}-${{ matrix.build_type }} - - - name: Xmake configure - run: | - xmake config --yes --toolchain=clang + xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang-20 - name: Build clice run: | diff --git a/include/Compiler/Command.h b/include/Compiler/Command.h index 3735e022..39a03de4 100644 --- a/include/Compiler/Command.h +++ b/include/Compiler/Command.h @@ -205,10 +205,10 @@ struct DenseMapInfo> { template <> struct std::formatter : - std::formatter { + std::formatter { template - auto format(clice::CompilationDatabase::QueryDriverError& e, FormatContext& ctx) const { + auto format(const clice::CompilationDatabase::QueryDriverError& e, FormatContext& ctx) const { return std::format_to(ctx.out(), "{} {}", e.kind.name(), e.detail); } }; diff --git a/include/Test/Test.h b/include/Test/Test.h index 64e9bdc0..3339e23d 100644 --- a/include/Test/Test.h +++ b/include/Test/Test.h @@ -103,6 +103,7 @@ constexpr inline struct { std::source_location location = std::source_location::current()) const { bool failed = false; std::string expression = "false"; + std::string message; if constexpr(is_expr_v) { auto result = expr(); @@ -115,10 +116,20 @@ constexpr inline struct { } else { if(!static_cast(expr)) { failed = true; + + if constexpr(requires { expr.error(); }) { + message = std::format("{}", expr.error()); + } } } - return may_failure{failed, false, expression, location}; + return may_failure{ + failed, + false, + std::move(expression), + location, + std::move(message), + }; } } expect; diff --git a/src/Compiler/Command.cpp b/src/Compiler/Command.cpp index a8077339..3d0d6929 100644 --- a/src/Compiler/Command.cpp +++ b/src/Compiler/Command.cpp @@ -250,6 +250,7 @@ auto CompilationDatabase::query_driver(this Self& self, llvm::StringRef driver) } auto driver_name = path::filename(driver); + driver.consume_back(".exe"); llvm::SmallString<128> output_path; if(auto error = llvm::sys::fs::createTemporaryFile("system-includes", "clice", output_path)) { @@ -282,8 +283,8 @@ auto CompilationDatabase::query_driver(this Self& self, llvm::StringRef driver) constexpr auto env = std::nullopt; #ifdef _WIN32 - llvm::SmallVector argv; - if(driver_name.starts_with("cl") || driver_name.starts_with("clang-cl")) { + llvm::SmallVector argv; + if(driver_name.ends_with("cl") || driver_name.starts_with("clang-cl")) { /// FIXME: MSVC command:` cl /Bv`, should we support it? return unexpected(ErrorKind::InvokeDriverFail, std::format("Unsupported driver: {}", driver)); @@ -517,9 +518,10 @@ auto CompilationDatabase::update_command(this Self& self, llvm::SmallVector arguments; auto [driver, _] = command.split(' '); driver = path::filename(driver); + driver.consume_back(".exe"); /// FIXME: Use a better to handle this. - if(driver.starts_with("cl") || driver.starts_with("clang-cl")) { + if(driver.ends_with("cl") || driver.starts_with("clang-cl")) { llvm::cl::TokenizeWindowsCommandLineFull(command, saver, arguments); } else { llvm::cl::TokenizeGNUCommandLine(command, saver, arguments); diff --git a/tests/unit/Support/StructedText.cpp b/tests/unit/Support/StructedText.cpp index ad103c61..1427b8cd 100644 --- a/tests/unit/Support/StructedText.cpp +++ b/tests/unit/Support/StructedText.cpp @@ -47,7 +47,7 @@ char *longestPalindrome_solv2(const char *s) { st.add_code_block(cb, "c"); auto& para = st.add_paragraph(); para.append_text("para1").append_newline_char(); - std::println("{}", st.as_markdown()); + /// std::println("{}", st.as_markdown()); }; test("BulletList") = [&] { @@ -60,7 +60,7 @@ char *longestPalindrome_solv2(const char *s) { Paragraph::Kind::Italic); st.add_bullet_list().add_item().add_paragraph().append_text("Item5", Paragraph::Kind::Strikethough); - std::println("{}", st.as_markdown()); + /// std::println("{}", st.as_markdown()); }; test("FullText") = [&] { @@ -112,7 +112,7 @@ This is *Italic* **Bold** ~~Striketough~~, `InlineCode` warnings.add_item().add_paragraph().append_text("warnings3: blah blah..."); st.add_ruler(); st.add_code_block("int test_bar(int foo, char **bar, char **baz);\n", "cpp"); - std::println("{}", st.as_markdown()); + /// std::println("{}", st.as_markdown()); }; };