Files
anvil/templates/basic/test/run_tests.bat
2026-02-18 21:00:24 -06:00

46 lines
1.0 KiB
Batchfile

@echo off
setlocal
set "SCRIPT_DIR=%~dp0"
:: %~dp0 always ends with \ which breaks cmake quoting ("path\" escapes the quote)
set "SCRIPT_DIR=%SCRIPT_DIR:~0,-1%"
set "BUILD_DIR=%SCRIPT_DIR%\build"
if "%1"=="--clean" (
if exist "%BUILD_DIR%" (
echo Cleaning build directory...
rmdir /s /q "%BUILD_DIR%"
)
)
if not exist "%BUILD_DIR%\CMakeCache.txt" (
echo Configuring test build. First run will fetch Google Test...
cmake -S "%SCRIPT_DIR%" -B "%BUILD_DIR%" -DCMAKE_BUILD_TYPE=Debug
if errorlevel 1 (
echo FAIL: cmake configure failed.
echo cmake is required for host-side tests.
echo Run 'anvil doctor' to see install instructions.
exit /b 1
)
)
echo Building tests...
cmake --build "%BUILD_DIR%" --parallel
if errorlevel 1 (
echo FAIL: build failed
exit /b 1
)
echo.
echo Running tests...
echo.
ctest --test-dir "%BUILD_DIR%" --output-on-failure
if errorlevel 1 (
echo.
echo FAIL: Some tests failed.
exit /b 1
)
echo.
echo PASS: All tests passed.