From eee2f690daf01fe772d8209b4f7e4a8e29845abf Mon Sep 17 00:00:00 2001 From: Eric Ratliff Date: Wed, 18 Feb 2026 21:00:24 -0600 Subject: [PATCH] Unit tests working on generated projects --- src/commands/doctor.rs | 24 ++++++++++++------------ templates/basic/test/run_tests.bat | 14 +++++++++----- templates/basic/test/run_tests.sh | 4 ++-- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/commands/doctor.rs b/src/commands/doctor.rs index 0e93039..e9eca79 100644 --- a/src/commands/doctor.rs +++ b/src/commands/doctor.rs @@ -161,8 +161,8 @@ fn print_diagnostics(health: &SystemHealth) { } else if !health.avr_core_ok { println!( " {} avr-size {}", - "--".bright_black(), - "included with arduino:avr core (no separate install)".bright_black() + "na".yellow(), + "included with arduino:avr core (no separate install)".yellow() ); } else { // Core is installed but avr-size is not on PATH -- @@ -170,8 +170,8 @@ fn print_diagnostics(health: &SystemHealth) { // inside the Arduino15 packages directory. println!( " {} avr-size {}", - "--".bright_black(), - hint_avr_size_not_on_path().bright_black() + "na".yellow(), + hint_avr_size_not_on_path().yellow() ); } @@ -195,8 +195,8 @@ fn print_diagnostics(health: &SystemHealth) { } else { println!( " {} cmake {}", - "--".bright_black(), - hint_cmake().bright_black() + "na".yellow(), + hint_cmake().yellow() ); } @@ -206,8 +206,8 @@ fn print_diagnostics(health: &SystemHealth) { } else { println!( " {} C++ compiler {}", - "--".bright_black(), - hint_cpp_compiler().bright_black() + "na".yellow(), + hint_cpp_compiler().yellow() ); } @@ -217,8 +217,8 @@ fn print_diagnostics(health: &SystemHealth) { } else { println!( " {} git {}", - "--".bright_black(), - hint_git().bright_black() + "na".yellow(), + hint_git().yellow() ); } @@ -235,8 +235,8 @@ fn print_diagnostics(health: &SystemHealth) { } else { println!( " {} no serial ports {}", - "--".bright_black(), - "(plug in a board to detect)".bright_black() + "na".yellow(), + "(plug in a board to detect)".yellow() ); } } diff --git a/templates/basic/test/run_tests.bat b/templates/basic/test/run_tests.bat index 8790a85..eba2de7 100644 --- a/templates/basic/test/run_tests.bat +++ b/templates/basic/test/run_tests.bat @@ -1,8 +1,10 @@ @echo off setlocal -set SCRIPT_DIR=%~dp0 -set BUILD_DIR=%SCRIPT_DIR%build +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%" ( @@ -12,10 +14,12 @@ if "%1"=="--clean" ( ) if not exist "%BUILD_DIR%\CMakeCache.txt" ( - echo Configuring (first run will fetch Google Test)... + 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 FAIL: cmake configure failed. + echo cmake is required for host-side tests. + echo Run 'anvil doctor' to see install instructions. exit /b 1 ) ) @@ -39,4 +43,4 @@ if errorlevel 1 ( ) echo. -echo PASS: All tests passed. +echo PASS: All tests passed. \ No newline at end of file diff --git a/templates/basic/test/run_tests.sh b/templates/basic/test/run_tests.sh index fc19fe5..cd89953 100644 --- a/templates/basic/test/run_tests.sh +++ b/templates/basic/test/run_tests.sh @@ -50,7 +50,7 @@ if [[ $DO_CLEAN -eq 1 ]] && [[ -d "$BUILD_DIR" ]]; then fi if [[ ! -f "$BUILD_DIR/CMakeCache.txt" ]]; then - info "Configuring (first run will fetch Google Test)..." + info "Configuring test build. First run will fetch Google Test..." cmake -S "$SCRIPT_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Debug fi @@ -70,4 +70,4 @@ if ctest "${CTEST_ARGS[@]}"; then else echo "" die "Some tests failed." -fi +fi \ No newline at end of file