mirror of
https://github.com/ankitects/anki.git
synced 2026-09-10 08:39:22 -04:00
Closes #5162 Pass `nextest` to `cargo-llvm-cov` so Rust coverage tests run with `cargo-nextest`. --------- Co-authored-by: Fernando Lins <1887601+fernandolins@users.noreply.github.com>
42 lines
1.4 KiB
Batchfile
42 lines
1.4 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
rem cargo-llvm-cov's llvm-profdata uses the host toolchain, which is incompatible
|
|
rem with the profraw files produced when running on Windows ARM64.
|
|
if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
|
|
echo Rust coverage is not supported on Windows ARM64 ^(llvm-profdata format mismatch^).
|
|
echo Run on Linux or let CI enforce coverage.
|
|
exit /b 0
|
|
)
|
|
|
|
set "outdir=out\coverage\rust"
|
|
set "LLVMCOVPATH=out\bin"
|
|
|
|
if not exist %outdir% mkdir %outdir%
|
|
|
|
if "%CARGO_TARGET_DIR%"=="" set "CARGO_TARGET_DIR=out\rust"
|
|
|
|
if "%CI%"=="true" (
|
|
rem prebuilt binary shouldve been installed earlier
|
|
set "CARGO_CMD=cargo"
|
|
) else (
|
|
if not exist %LLVMCOVPATH% mkdir %LLVMCOVPATH%
|
|
if not exist %LLVMCOVPATH%\cargo-llvm-cov.exe (
|
|
cargo install cargo-llvm-cov --version 0.8.4 --locked --root out || exit /b 1
|
|
)
|
|
if not exist %LLVMCOVPATH%\cargo-nextest.exe (
|
|
cargo install cargo-nextest --version 0.9.99 --locked --no-default-features --features default-no-update --root out || exit /b 1
|
|
)
|
|
set "CARGO_CMD=%LLVMCOVPATH%\cargo-llvm-cov.exe"
|
|
)
|
|
|
|
set "PATH=%LLVMCOVPATH%;%PATH%"
|
|
set "ANKI_TEST_MODE=1"
|
|
"%CARGO_CMD%" llvm-cov nextest --workspace --locked --json --summary-only ^
|
|
--output-path %outdir%\coverage-summary.json --fail-under-lines 64 || exit /b 1
|
|
|
|
if "%1"=="--html" (
|
|
"%CARGO_CMD%" llvm-cov report --html --output-dir %outdir% || exit /b 1
|
|
echo Rust coverage report: %outdir%\html\index.html
|
|
)
|