[apparmor] [patch] inprove runtests-py*.sh

Steve Beattie steve at nxnw.org
Tue Jul 15 23:46:13 UTC 2014


On Mon, Jul 14, 2014 at 10:37:52PM +0200, Christian Boltz wrote:
> this patch changes runtests-py*.sh (scripts for manually running the 
> utils/test/*.py testcases) to
> - sleep 10 seconds after each failed test to make failures more annoying
>   ^W^W^W^Wgive people a chance to read failure details

Is there a reason to do it this way and not just add 'set -e' to the
script such that it will abort with a non-zero exit status if one
of the commands in the script fails? For the record, that is what
happens if 'make check' is invoked and one of the tests fails.

> - print a list of failed tests at the end

> Also avoid duplicate code by letting runtests-py2.sh call runtests-py3.sh.

That part, I like.

> === modified file 'utils/test/runtests-py2.sh'
> --- utils/test/runtests-py2.sh  2014-02-13 00:59:27 +0000
> +++ utils/test/runtests-py2.sh  2014-07-14 20:29:55 +0000
> @@ -1,1 +1,5 @@
> -for file in *.py ; do echo "running $file..." ; python $file; echo; done
> +#!/bin/bash
> +
> +RUNTESTS_PY__PYTHON_BINARY=python2

Generally, we've just used the environment variable PYTHON to specify
which python interpreter to use.

> +source runtests-py3.sh
> +
> 
> === modified file 'utils/test/runtests-py3.sh'
> --- utils/test/runtests-py3.sh  2014-02-13 00:59:27 +0000
> +++ utils/test/runtests-py3.sh  2014-07-14 20:33:20 +0000
> @@ -1,1 +1,31 @@
> -for file in *.py ; do echo "running $file..." ; python3 $file; echo; done
> +#!/bin/bash

Is there a reason to specify bash? I don't see any specific bashisms
in either script?

Thanks.

> +# ------------------------------------------------------------------
> +#
> +#    Copyright (C) 2014 Christian Boltz
> +#
> +#    This program is free software; you can redistribute it and/or
> +#    modify it under the terms of version 2 of the GNU General Public
> +#    License published by the Free Software Foundation.
> +#
> +# ------------------------------------------------------------------
> +
> +test -z "$RUNTESTS_PY__PYTHON_BINARY" && RUNTESTS_PY__PYTHON_BINARY=python3
> +
> +failed=""
> +for file in *.py ; do 
> +       echo "running $file..." 
> +       "$RUNTESTS_PY__PYTHON_BINARY" $file || { 
> +               failed="$failed $file"
> +               echo "*** test $file failed - giving you some time to read the output... ***"
> +               sleep 10
> +       }
> +       echo
> +done
> +
> +test -n "$failed" && {
> +       echo
> +       echo "*** The following tests failed:"
> +       echo "***   $failed"
> +       exit 1
> +}
> +

-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140715/63c173fd/attachment.pgp>


More information about the AppArmor mailing list