diff --git a/exercises/practice/hello-world/HelloWorldTest.bat b/exercises/practice/hello-world/HelloWorldTest.bat index 0235927..f7276be 100644 --- a/exercises/practice/hello-world/HelloWorldTest.bat +++ b/exercises/practice/hello-world/HelloWorldTest.bat @@ -1,41 +1,88 @@ @echo off REM --------------------------------------------------- -REM testThatGreeterReturnsTheCorrectGreeting +REM Hello World Unit Test REM --------------------------------------------------- -REM Initalize result variable -set "slug=HelloWorld" -set "result=" -set "expected=Hello, World!" +:Main + REM Initalize result variable + set "slug=HelloWorld" -REM Run the program and store the output in the result variable -if exist %~dp0%slug%.bat ( - REM If the file exists in the full path, run it from there - for /f "delims=" %%a in ('%~dp0%slug%.bat') do set result=%%a + CALL :Initialize -) else ( - if exist %slug%.bat ( - REM If the file exists in the wildcard search path, run it from there - for /f "delims=" %%a in ('%slug%.bat') do set result=%%a + REM -------------------- + REM Test Case Start \/\/ + REM -------------------- + set "expected=Hello, World!" + set "if_success=Test passed" + set "if_failed=Test failed: Your output have to be 'Hello, World!'" + CALL :Assert - ) else ( - REM Errorlevel = 2: The system cannot find the file specified. - REM Indicates that the file cannot be found in specified location. - echo Could not find "%~dp0%slug%.bat" or "%slug%.bat" - exit /b 2 + REM -------------------- + REM Test Case End /\/\/\ + REM -------------------- - ) -) + CALL :ResolveStatus + exit /b %errorlevel% +REM End of Main + +REM --------------------------------------------------- +REM Assert [..Parameters(up to 9)] +REM --------------------------------------------------- +GOTO :End REM Prevents the code below from being executed +:Assert +set "stdout=" + +REM Run the program and capture the output then delete the file +CALL %slug%.bat %~1 %~2 %~3 %~4 %~5 %~6 %~7 %~8 %~9 > stdout.bin 2>&1 +set /p stdout=