Add mock Arduino for x86_64 host-side testing
Complete Arduino API mock (mock_arduino.h/cpp) enabling application code to compile and run on PC without hardware. Includes MockSerial, String class, GPIO/analog/timing/interrupt mocks with state tracking and test control API. - Arduino.h, Wire.h, SPI.h shims intercept includes in test builds - System test template (test_system.cpp) using SimHal - CMakeLists.txt builds mock_arduino as static lib, links both suites - Root test.sh/test.bat with --unit/--system/--clean/--verbose flags - test.bat auto-detects MSVC via vswhere + vcvarsall.bat - Doctor reports nuanced compiler status (on PATH vs installed) - Refresh pulls mock infrastructure into existing projects - 15 tests passing: 7 unit (MockHal) + 8 system (SimHal)
This commit is contained in:
@@ -1,11 +1,37 @@
|
||||
@echo off
|
||||
setlocal
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
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"
|
||||
|
||||
:: -- Compiler detection (with vswhere fallback for MSVC) --------------------
|
||||
|
||||
set "HAS_COMPILER=0"
|
||||
where g++ >nul 2>&1 && set "HAS_COMPILER=1"
|
||||
where clang++ >nul 2>&1 && set "HAS_COMPILER=1"
|
||||
where cl >nul 2>&1 && set "HAS_COMPILER=1"
|
||||
if "%HAS_COMPILER%"=="1" goto :compiler_ok
|
||||
|
||||
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
if not exist "%VSWHERE%" goto :compiler_ok
|
||||
|
||||
for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -property installationPath`) do (
|
||||
set "VS_PATH=%%i"
|
||||
)
|
||||
if not defined VS_PATH goto :compiler_ok
|
||||
|
||||
set "VCVARS=!VS_PATH!\VC\Auxiliary\Build\vcvarsall.bat"
|
||||
if not exist "!VCVARS!" goto :compiler_ok
|
||||
|
||||
echo Setting up MSVC environment...
|
||||
call "!VCVARS!" x64 >nul 2>&1
|
||||
|
||||
:compiler_ok
|
||||
|
||||
:: -- Build and test ---------------------------------------------------------
|
||||
|
||||
if "%1"=="--clean" (
|
||||
if exist "%BUILD_DIR%" (
|
||||
echo Cleaning build directory...
|
||||
@@ -18,7 +44,7 @@ if not exist "%BUILD_DIR%\CMakeCache.txt" (
|
||||
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 cmake and a C++ compiler are required for host-side tests.
|
||||
echo Run 'anvil doctor' to see install instructions.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user