+ fixing EXITCODE handling

This commit is contained in:
Rainer Kottenhoff 2017-10-10 15:24:46 +02:00
parent 2944a4bc40
commit e613e97b5d
2 changed files with 27 additions and 19 deletions

View File

@ -18,6 +18,7 @@ v_NP3TestDir = %A_WorkingDir%\_TESTDIR
v_NP3IniFile = %v_NP3Name%.ini
stdout := FileOpen("*", "w")
v_ExitCode := 0
; =============================================================================
@ -26,6 +27,7 @@ v_ErrLevel = %ErrorLevel%
if (v_ErrLevel != 0)
{
stdout.WriteLine("*** ERROR: " . v_NP3Name . "could not be launched.")
v_ExitCode := 1
Goto LABEL_END
}
; -----------------------------------------------------------------------------
@ -45,6 +47,7 @@ v_ErrLevel = %ErrorLevel%
if (v_ErrLevel != 0)
{
stdout.WriteLine("*** ERROR: " . v_NP3Name . "'s seems not to start in time ???")
v_ExitCode := 2
Goto LABEL_END
}
Return
@ -57,25 +60,25 @@ WinGetTitle, v_NP3Title, ahk_pid %v_Notepad3_PID%
IfNotInString, v_NP3Title, %v_NP3Name%
{
v_ErrLevel = 1
v_ExitCode := 3
stdout.WriteLine("*** ERROR: " . v_NP3Name . " missing in Title: " . v_NP3Title)
}
IfNotInString, v_NP3Title, %v_NP3IniFile%
{
v_ErrLevel = 1
v_ExitCode := 3
stdout.WriteLine("*** ERROR: " . v_NP3IniFile . " missing in Title: " . v_NP3Title)
}
IfNotInString, v_NP3Title, %v_NP3TestDir%
{
v_ErrLevel = 1
v_ExitCode := 3
stdout.WriteLine("*** ERROR: " . v_NP3TestDir . " missing in Title: " . v_NP3Title)
}
IfNotInString, v_NP3Title, "XXX ERROR XXX"
{
v_ErrLevel = 1
v_ExitCode := 3
stdout.WriteLine("*** ERROR: XXX ERROR XXX missing in Title: " . v_NP3Title)
}
If (v_ErrLevel != 0)
If (v_ExitCode != 0)
{
Goto LABEL_END
}
@ -91,8 +94,9 @@ WinWait, About %v_NP3Name%, , 1
v_ErrLevel = %ErrorLevel%
if (v_ErrLevel != 0)
{
v_ExitCode := 4
stdout.WriteLine("*** ERROR: " . v_NP3Name . "'s About Box is not displayed!")
Return
Goto LABEL_END
}
WinActivate ; About Box
;ControlFocus, OK, About %v_NP3Name%
@ -102,6 +106,7 @@ WinWaitClose, About %v_NP3Name%, , 1
v_ErrLevel = %ErrorLevel%
if (v_ErrLevel != 0)
{
v_ExitCode := 5
stdout.WriteLine("*** ERROR: " . v_NP3Name . "'s About Box can not be closed!")
Goto LABEL_END
}
@ -114,6 +119,7 @@ WinClose ahk_pid %v_Notepad3_PID%, , 1
v_ErrLevel = %ErrorLevel%
if (v_ErrLevel != 0)
{
v_ExitCode := 99
stdout.WriteLine("*** ERROR: " . v_NP3Name . "can not be closed!")
}
; -------------------------------------
@ -121,13 +127,15 @@ WinWaitClose ahk_pid %v_Notepad3_PID%
v_ErrLevel = %ErrorLevel%
if (v_ErrLevel != 0)
{
v_ExitCode := 111
; FORCED Kill / HANGUP
}
; -------------------------------------
if (v_ErrLevel != 0)
if (v_ExitCode != 0)
{
stdout.WriteLine("*** ERROR: Testing " . v_NP3Name . " exits with error level: " . v_ErrLevel)
Exit, %v_ErrLevel%
stdout.WriteLine("*** ERROR: Testing " . v_NP3Name . " exit with: " . v_ExitCode)
ExitApp, %v_ExitCode%
}
Exit, 0
stdout.WriteLine("Testing " . v_NP3Name . ": All tests PASSED.")
ExitApp, 0
; =============================================================================

View File

@ -1,5 +1,5 @@
@echo off
setlocal enableextensions enabledelayedexpansion
setlocal enableextensions
set SCRIPTDRV=%~d0
set SCRIPTDIR=%~dp0
set CWD=%CD%
@ -25,29 +25,29 @@ rem for /r %%i in (*.ahk) do (
rem echo ** Running %%~nxi **
rem start "testing" /B /wait "%AHK_EXE%" /ErrorStdOut %%~nxi > %TEST_LOG% 2>&1
rem if errorlevel 1 (
rem set err_level=%ERRORLEVEL%
rem echo *** Test file %%~nxi failed ***
rem set err_level=1
rem )
rem type testoutput.txt
rem echo.
rem )
:: START Testing
"%AHK_EXE%" /ErrorStdOut "%~dpn0.ahk" > %TEST_LOG% 2>&1
start "Testing" /B /Wait "%AHK_EXE%" /ErrorStdOut "%~dpn0.ahk" > "%TEST_LOG%" 2>&1
if errorlevel 1 (
echo *** Test failed *** >> %TEST_LOG%
set EXITCODE=1
set EXITCODE=%ERRORLEVEL%
echo *** Test failed *** >> "%TEST_LOG%"
)
:: --------------------------------------------------------------------------------------------------------------------
:END
type %TEST_LOG%
type "%TEST_LOG%"
:: - make EXITCODE survive 'endlocal'
endlocal & set EXITCODE=%EXITCODE%
::echo.EXITCODE=%EXITCODE%
::pause
if [%EXITCODE%] NEQ [0] exit /B %EXITCODE%
exit /b %EXITCODE%
:: ====================================================================================================================
:: --------------------------------------------------------------------------------------------------------------------
:: ====================================================================================================================