Merge "Fix the -l/--list-tests argument for tempest run"
diff --git a/tempest/cmd/run.py b/tempest/cmd/run.py
index 1891827..707a0fa 100644
--- a/tempest/cmd/run.py
+++ b/tempest/cmd/run.py
@@ -161,8 +161,13 @@
else:
pass
- if not (parsed_args.config_file or parsed_args.workspace):
- regex = self._build_regex(parsed_args)
+ regex = self._build_regex(parsed_args)
+ if parsed_args.list_tests:
+ return_code = commands.list_command(
+ filters=regex, whitelist_file=parsed_args.whitelist_file,
+ blacklist_file=parsed_args.blacklist_file)
+
+ elif not (parsed_args.config_file or parsed_args.workspace):
serial = not parsed_args.parallel
return_code = commands.run_command(
filters=regex, subunit_out=parsed_args.subunit,
diff --git a/tempest/tests/cmd/test_run.py b/tempest/tests/cmd/test_run.py
index b2fddc9..d57790d 100644
--- a/tempest/tests/cmd/test_run.py
+++ b/tempest/tests/cmd/test_run.py
@@ -21,6 +21,7 @@
import fixtures
import mock
+import six
from tempest.cmd import run
from tempest.tests import base
@@ -93,6 +94,7 @@
msg = ("Running %s got an unexpected returncode\n"
"Stdout: %s\nStderr: %s" % (' '.join(cmd), out, err))
self.assertEqual(p.returncode, expected, msg)
+ return out, err
def test_tempest_run_passes(self):
self.assertRunExit(['tempest', 'run', '--regex', 'passing'], 0)
@@ -104,6 +106,23 @@
def test_tempest_run_fails(self):
self.assertRunExit(['tempest', 'run'], 1)
+ def test_run_list(self):
+ subprocess.call(['stestr', 'init'])
+ out, err = self.assertRunExit(['tempest', 'run', '-l'], 0)
+ tests = out.split()
+ tests = sorted([six.text_type(x.rstrip()) for x in tests if x])
+ result = [
+ six.text_type('tests.test_failing.FakeTestClass.test_pass'),
+ six.text_type('tests.test_failing.FakeTestClass.test_pass_list'),
+ six.text_type('tests.test_passing.FakeTestClass.test_pass'),
+ six.text_type('tests.test_passing.FakeTestClass.test_pass_list'),
+ ]
+ # NOTE(mtreinish): on python 3 the subprocess prints b'' around
+ # stdout.
+ if six.PY3:
+ result = ["b\'" + x + "\'" for x in result]
+ self.assertEqual(result, tests)
+
class TestTakeAction(base.TestCase):
def test_workspace_not_registered(self):