I have a console application. Interaction with this application is via TCP / IP.
I also have a test environment for it, which is basically a collection of BATCH scripts (... not my fault). What this test structure does for each test is basically this:
start /min "myapplication.exe" and wait for confirmation of the launch of the application.- send commands via TCP / IP to this application, receive its responses and check whether the timings and values correspond to what is expected as a result of a particular test.
One of the problems that I am facing right now is that the application crashes due to some internal error. I would like to distinguish between failed tests and application failure. The only sign I have for this is the application exit code.
So, I tried the following:
start /min cmd /c "myapplication.exe || echo %errorLevel% > exitcode.txt"
and then in test cases,
if exist exitcode.txt (
set /p exitcode=<exitcode.txt
echo ERROR: myapplication.exe returned exitcode %exitcode%.
goto error
) else (
goto do_processing
)
but for some strange reason, the text file never appears, although sometimes I get a dialog about the application crashing, and although I force it to do with the known non-zero exit code. The test passes through do_processingand (of course) leads to failure.
EDIT
When I started
start /min cmd /c "nonsense || echo %errorLevel% > test.txt"
I sometimes get a text file containing line 9009, but in other cases this text file contains a line 0or sometimes 1, ... What is ...?!
EDIT2
cmd /k "nonsense || echo %errorLevel%"
( /k), 0 , echo %errorlevel%, 1....
, , ...
, ?