Command line execution: script return code on script abort (FindFailed)

Asked by Phreag

Version: SikuliX 2.0.4 on Windows 10, Running Java 1.8.0_191

Setup:
I use Sikulix for GUI-testing.
I have a batch-script which calls different scripts in a loop. Every script is started in a clean enviroment and should be independent from the exit status of previous executions. The whole thing should run unattended and write a log file where it says which scripts have done a complete run.

Part of my Batch script: (%%d is the current script in the loop)

call java -jar Sikulix.jar -f logs/sikulix/%%d_%date%.log -r Tests/%%d
REM ERRORLEVEL 42 = Success because abort due to an error also returns Errorlevel 0
IF ERRORLEVEL 42 (
 echo [%DATE% %TIME%]: %%d passed. >> logs/%DATE%_success.log
 echo %%d passed
) ELSE (
 echo [%DATE% %TIME%]: %%d failed with return code %errorlevel% >> logs/%DATE%_failed.log
 echo %%d failed.
)

Problem:
When a SikuliX script gets aborted (FindFailed for example) the return code is always 0. That is not what i would expect. I expect a return code 0 only when everything went well. Therefore i need this ugly workaround that every script has an exit(42) at the end because that is the only case where everything went well.
try:/excerpt block is not practical for me because i want a different return code whenever anything unforeseen happens.

Is this a feature by design or a bug?
And if it is a bug it would be nice to have it fixed.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#2

To set the script return code with special script situations is not a feature of SikuliX.

Generally the value of exit(value) is returned.
If no exit() is executed, 0 is returned.

It is totally up to the user, to define and use return codes, that can be evaluated in the outer world.

What I do not understand:
Since you are testing something, why don't you use the powerful unittest feature of Python?
Nice reporting could be done using the bundled HTMLTestRunner.

If you stay with your basic concept, you should've a deeper look into the docs about FindFailed handling and the options.

Can you help with this problem?

Provide an answer of your own, or ask Phreag for more information if necessary.

To post a message you must log in.