summaryrefslogtreecommitdiff
path: root/testrepository
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2013-07-17 15:17:17 +1200
committerRobert Collins <robertc@robertcollins.net>2013-07-17 15:17:17 +1200
commitfcb7b94b063cc0d7e14d8ea5b89f5727ad7e713f (patch)
tree034d9cd07dc6921bf6e8d6ab1f841e28aa30defb /testrepository
parent5418052029a47afa9b4c326e8342c02b00486e7e (diff)
downloadtestrepository-fcb7b94b063cc0d7e14d8ea5b89f5727ad7e713f.tar.gz
* When test listing fails, testr will now report an error rather than
incorrectly trying to run zero tests. A test listing failure is detected by the returncode of the test listing process. (Robert Collins, #1185231)
Diffstat (limited to 'testrepository')
-rw-r--r--testrepository/testcommand.py5
-rw-r--r--testrepository/tests/test_testcommand.py9
2 files changed, 13 insertions, 1 deletions
diff --git a/testrepository/testcommand.py b/testrepository/testcommand.py
index 2cb4d50..267f4ef 100644
--- a/testrepository/testcommand.py
+++ b/testrepository/testcommand.py
@@ -293,7 +293,10 @@ class TestListingFixture(Fixture):
run_proc = self.ui.subprocess_Popen(list_cmd, shell=True,
stdout=subprocess.PIPE, stdin=subprocess.PIPE)
out, err = run_proc.communicate()
- # Should we raise on non-zero exit?
+ if run_proc.returncode != 0:
+ raise ValueError(
+ "Non-zero exit code (%d) from test listing."
+ " stdout=%r, stderr=%r" % (run_proc.returncode, out, err))
ids = parse_enumeration(out)
return ids
finally:
diff --git a/testrepository/tests/test_testcommand.py b/testrepository/tests/test_testcommand.py
index 605d490..cdaeaa8 100644
--- a/testrepository/tests/test_testcommand.py
+++ b/testrepository/tests/test_testcommand.py
@@ -321,6 +321,15 @@ class TestTestCommand(ResourcedTestCase):
fixture = self.useFixture(command.get_run_command())
self.assertEqual(set(['returned', 'ids']), set(fixture.list_tests()))
+ def test_list_tests_nonzero_exit(self):
+ ui, command = self.get_test_ui_and_cmd()
+ ui.proc_results = [1]
+ self.set_config(
+ '[DEFAULT]\ntest_command=foo $LISTOPT $IDLIST\ntest_id_list_default=whoo yea\n'
+ 'test_list_option=--list\n')
+ fixture = self.useFixture(command.get_run_command())
+ self.assertThat(lambda:fixture.list_tests(), raises(ValueError))
+
def test_partition_tests_smoke(self):
repo = memory.RepositoryFactory().initialise('memory:')
# Seed with 1 slow and 2 tests making up 2/3 the time.