[apparmor] [patch] inprove runtests-py*.sh
Christian Boltz
apparmor at cboltz.de
Wed Jul 16 11:39:49 UTC 2014
Hello,
Am Dienstag, 15. Juli 2014 schrieb Steve Beattie:
> 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.
Yes. I want the script to run all tests, even if one of them fails, so
that I get an overview of all tests. (The script still does "exit 1"
if there was a failure.)
I know "all tests succeeded" is the expected result, and we should
always have that. Nevertheless it's useful to be able to run all tests
even if the first one fails ;-) (maybe I'm able to fix the second one?)
> > === 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.
I know, and this is why I avoid it here ;-)
The script name already implies which python version to use, therefore I
don't want strange side effects (using a wrong/unexpected python
version) if someone has set $PYTHON.
"$pb4JbOGwvImxBYoWPG4mhoKpWykzxAd75XIb" would be an even better variable
name to ensure this, but I wanted readable code ;-)
> > === 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?
Well, /bin/bash is just my default script header ;-)
I'll change it to /bin/sh.
Updated patch (only change: bash changed to sh):
=== 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-16 11:29:08 +0000
@@ -1,1 +1,5 @@
-for file in *.py ; do echo "running $file..." ; python $file; echo; done
+#!/bin/sh
+
+RUNTESTS_PY__PYTHON_BINARY=python2
+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-16 11:29:27 +0000
@@ -1,1 +1,31 @@
-for file in *.py ; do echo "running $file..." ; python3 $file; echo; done
+#!/bin/sh
+# ------------------------------------------------------------------
+#
+# 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
+}
+
Regards,
Christian Boltz
--
And I think we'd be much more succesful if we could deliver functional
NetworkManager and updater applets for the first time in years, than
providing some hyped "innovation".
[Martin Schlander in opensuse-project]
More information about the AppArmor
mailing list