← Back to team overview

openstack team mailing list archive

run_tests.sh (-x | --stop) is broken, optparse and nosetests

 

Hi Developers,

I have been looking at https://bugs.launchpad.net/nova/+bug/931608,
"run_tests.sh (-x | --stop) is broken."  A fix was committed but it only
stopped "./run_tests.sh -x" from failing, and not restoring the
"./run_tests.sh -x" functionality.

"run_tests.sh (-x | --stop)" is a nosetests parameter which gets passed in
via nova/testing/runner.py:367.  sys.argv for nova/testing/runner.py, takes
two sets of parameters nova parameters and any arbitrary nosetests
parameter.  The nova flags (hide-elapsed etc.) are handled via
'flags.FLAGS.register_cli_opt' and the nosetest parameters are generated
from the args return value from optparse (nova/openstack/common/cfg.py:768:
  "(values, args) = self._oparser.parse_args(self._args)" ).

The problem is when optparse sees an unknown flag (such as '-x') it
terminates the program without throwing an error.  Additionally the 'args'
return value doesn't contain the flags just flag arguments (only 'a' in '-x
a').  So there is no way of passing on just the unknown flags to nosetest.
 Additionally nosetest uses optparse itself so if you pass in sys.argv to
nosetest with a nova argument set will case the tests to break too.<member:jog0>


While I can write a hack to look for 'hide-elapsed' or other nova flags, I
am looking for more elegant solutions.  Should this solution live in the
cfg module?


best,
Joe Gordon


<member:jog0>

Follow ups