File size: 944 Bytes
6851d40 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ## This small script takes as first argument a test indicator
## and the rest of the arguments are a command to run, with its
## command-line arguments.
## The script runs the command and then if the first argument is
## (1) -any -- returns success, ignoring the exit code of the command
## (2) -z -- returns success iff the exit code is non-zero
## (3) some integer literal -- return success iff the exit code
## matches the given integer
## (4) -skip -- does not run the command and just exits with success
import sys
import subprocess
arg = sys.argv[1]
if arg == "-skip":
print( 'Skipping' )
exit(0)
p = subprocess.run( sys.argv[2:] )
if arg == "-any":
exit(0)
if arg == "-z":
if p.returncode == 0 :
print( 'Expected non-zero exit code' )
exit(1)
else:
exit(0)
if p.returncode != int(arg) :
print( 'Expected exit code', arg, ', actual result is', p.returncode )
exit(1)
exit(0)
|