test-release.sh, tooltest.py, tooltest2.py: minor changes, exception handling
This commit is contained in:
parent
558fa58f91
commit
26ba8baa97
3 changed files with 49 additions and 35 deletions
|
|
@ -2,6 +2,8 @@
|
|||
# Tested on Linux, MinGW-64
|
||||
# MinGW's bash 3.1.17 doesn't do ${var^^}
|
||||
|
||||
trap 'echo -e "${GREEN}Exiting at user request$RESET"; exit' INT
|
||||
|
||||
umask 0022
|
||||
|
||||
export MMGEN_TEST_SUITE=1
|
||||
|
|
@ -10,6 +12,7 @@ export PYTHONPATH=.
|
|||
test_py='test/test.py -n'
|
||||
objtest_py='test/objtest.py'
|
||||
tooltest_py='test/tooltest.py'
|
||||
tooltest2_py='test/tooltest2.py --names'
|
||||
gentest_py='test/gentest.py'
|
||||
scrambletest_py='test/scrambletest.py'
|
||||
mmgen_tool='cmds/mmgen-tool'
|
||||
|
|
@ -63,6 +66,7 @@ do
|
|||
touch 'test/trace.acc'
|
||||
test_py+=" --coverage"
|
||||
tooltest_py+=" --coverage"
|
||||
tooltest2_py+=" --fork --coverage"
|
||||
scrambletest_py+=" --coverage"
|
||||
python="python3 -m trace --count --file=test/trace.acc --coverdir=test/trace"
|
||||
objtest_py="$python $objtest_py"
|
||||
|
|
@ -81,7 +85,7 @@ do
|
|||
t) TESTING=1 ;;
|
||||
v) EXACT_OUTPUT=1 test_py+=" --exact-output" ;&
|
||||
V) VERBOSE=1 [ "$EXACT_OUTPUT" ] || test_py+=" --verbose"
|
||||
tooltest_py+=" --verbose" gentest_py+=" --verbose" mmgen_tool+=" --verbose"
|
||||
tooltest_py+=" --verbose" tooltest2_py+=" --verbose" gentest_py+=" --verbose" mmgen_tool+=" --verbose"
|
||||
scrambletest_py+=" --verbose" ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
|
@ -134,7 +138,10 @@ do_test() {
|
|||
[ "$TESTING" ] && LS=''
|
||||
echo $i | grep -q 'gentest' && LS=''
|
||||
echo -e "$LS${GREEN}Running:$RESET $YELLOW$i$RESET"
|
||||
[ "$TESTING" ] || eval "$i" || { echo -e $RED"Test $CUR_TEST failed at command '$i'"$RESET; exit; }
|
||||
[ "$TESTING" ] || eval "$i" || {
|
||||
echo -e $RED"Test '$CUR_TEST' failed at command '$i'"$RESET
|
||||
exit
|
||||
}
|
||||
done
|
||||
}
|
||||
i_obj='Data object'
|
||||
|
|
@ -329,6 +336,7 @@ f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
|
|||
i_tool='Tooltest'
|
||||
s_tool="The following tests will run '$tooltest_py' for all supported coins"
|
||||
t_tool=(
|
||||
"$tooltest2_py"
|
||||
"$tooltest_py --coin=btc util"
|
||||
"$tooltest_py --coin=btc cryptocoin"
|
||||
"$tooltest_py --coin=btc mnemonic"
|
||||
|
|
|
|||
|
|
@ -496,24 +496,27 @@ def do_cmds(cmd_group):
|
|||
cmdline = [cmd] + [os.path.join(cfg['tmpdir'],fn) for fn in fns]
|
||||
getattr(tc,cmd)(*cmdline)
|
||||
|
||||
if cmd_args:
|
||||
if len(cmd_args) != 1:
|
||||
die(1,'Only one command may be specified')
|
||||
cmd = cmd_args[0]
|
||||
if cmd in cmd_data:
|
||||
msg('Running tests for {}:'.format(cmd_data[cmd]['desc']))
|
||||
do_cmds(cmd)
|
||||
elif cmd == 'clean':
|
||||
cleandir(cfg['tmpdir'])
|
||||
sys.exit(0)
|
||||
try:
|
||||
if cmd_args:
|
||||
if len(cmd_args) != 1:
|
||||
die(1,'Only one command may be specified')
|
||||
cmd = cmd_args[0]
|
||||
if cmd in cmd_data:
|
||||
msg('Running tests for {}:'.format(cmd_data[cmd]['desc']))
|
||||
do_cmds(cmd)
|
||||
elif cmd == 'clean':
|
||||
cleandir(cfg['tmpdir'])
|
||||
sys.exit(0)
|
||||
else:
|
||||
die(1,"'{}': unrecognized command".format(cmd))
|
||||
else:
|
||||
die(1,"'{}': unrecognized command".format(cmd))
|
||||
else:
|
||||
cleandir(cfg['tmpdir'])
|
||||
for cmd in cmd_data:
|
||||
msg('Running tests for {}:'.format(cmd_data[cmd]['desc']))
|
||||
do_cmds(cmd)
|
||||
if cmd is not list(cmd_data.keys())[-1]: msg('')
|
||||
cleandir(cfg['tmpdir'])
|
||||
for cmd in cmd_data:
|
||||
msg('Running tests for {}:'.format(cmd_data[cmd]['desc']))
|
||||
do_cmds(cmd)
|
||||
if cmd is not list(cmd_data.keys())[-1]: msg('')
|
||||
except KeyboardInterrupt:
|
||||
die(1,green('\nExiting at user request'))
|
||||
|
||||
t = int(time.time()) - start_time
|
||||
gmsg('All requested tests finished OK, elapsed time: {:02}:{:02}'.format(t//60,t%60))
|
||||
|
|
|
|||
|
|
@ -122,12 +122,12 @@ tests = (
|
|||
|
||||
def do_cmd(cdata):
|
||||
cmd_name,desc,data = cdata
|
||||
m = cmd_name if opt.names else desc
|
||||
msg_r(blue(m)+'\n' if opt.verbose else m)
|
||||
m = 'Testing {}'.format(cmd_name if opt.names else desc)
|
||||
msg_r(green(m)+'\n' if opt.verbose else m)
|
||||
for args,out in data:
|
||||
if opt.fork:
|
||||
cmd = list(tool_cmd) + [cmd_name] + args
|
||||
vmsg('{}: {}'.format(purple('Running'),' '.join(cmd)))
|
||||
vmsg('{} {}'.format(green('Executing'),cyan(' '.join(cmd))))
|
||||
p = Popen(cmd,stdout=PIPE,stderr=PIPE)
|
||||
cmd_out = p.stdout.read()
|
||||
cmd_err = p.stderr.read()
|
||||
|
|
@ -152,7 +152,7 @@ def do_cmd(cdata):
|
|||
|
||||
def do_group(garg):
|
||||
gid,gdesc,gdata = garg
|
||||
gmsg('Testing {}'.format(gid if opt.names else gdesc))
|
||||
msg(blue("Testing {}".format("command group '{}'".format(gid) if opt.names else gdesc)))
|
||||
for cdata in gdata:
|
||||
do_cmd(cdata)
|
||||
|
||||
|
|
@ -208,19 +208,22 @@ else:
|
|||
|
||||
start_time = int(time.time())
|
||||
|
||||
if cmd_args:
|
||||
if len(cmd_args) != 1:
|
||||
die(1,'Only one command may be specified')
|
||||
cmd = cmd_args[0]
|
||||
group = [e for e in tests if e[0] == cmd]
|
||||
if group:
|
||||
do_group(group[0])
|
||||
try:
|
||||
if cmd_args:
|
||||
if len(cmd_args) != 1:
|
||||
die(1,'Only one command may be specified')
|
||||
cmd = cmd_args[0]
|
||||
group = [e for e in tests if e[0] == cmd]
|
||||
if group:
|
||||
do_group(group[0])
|
||||
else:
|
||||
if not do_cmd_in_group(cmd):
|
||||
die(1,"'{}': not a recognized test or test group".format(cmd))
|
||||
else:
|
||||
if not do_cmd_in_group(cmd):
|
||||
die(1,"'{}': not a recognized test or test group".format(cmd))
|
||||
else:
|
||||
for garg in tests:
|
||||
do_group(garg)
|
||||
for garg in tests:
|
||||
do_group(garg)
|
||||
except KeyboardInterrupt:
|
||||
die(1,green('\nExiting at user request'))
|
||||
|
||||
t = int(time.time()) - start_time
|
||||
gmsg('All requested tests finished OK, elapsed time: {:02}:{:02}'.format(t//60,t%60))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue