Merge lp:~pwlars/lava-test/test-id-after-run into lp:lava-test/0.0

Proposed by Paul Larson
Status: Merged
Merged at revision: 49
Proposed branch: lp:~pwlars/lava-test/test-id-after-run
Merge into: lp:lava-test/0.0
Diff against target: 95 lines (+55/-0)
3 files modified
abrek/testdef.py (+6/-0)
tests/__init__.py (+1/-0)
tests/test_abrektest.py (+48/-0)
To merge this branch: bzr merge lp:~pwlars/lava-test/test-id-after-run
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+38547@code.launchpad.net

Description of the change

Add output at the end of test runs to let the user know the result id

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'abrek/testdef.py'
--- abrek/testdef.py 2010-10-07 15:44:19 +0000
+++ abrek/testdef.py 2010-10-15 15:12:59 +0000
@@ -75,6 +75,8 @@
75 self.uninstall()75 self.uninstall()
76 raise RuntimeError("An error was detected during",76 raise RuntimeError("An error was detected during",
77 "installation, cleaning up: %s" % strerror)77 "installation, cleaning up: %s" % strerror)
78 finally:
79 os.chdir(self.origdir)
7880
79 def uninstall(self):81 def uninstall(self):
80 """Uninstall the test suite.82 """Uninstall the test suite.
@@ -122,6 +124,9 @@
122 os.chdir(installdir)124 os.chdir(installdir)
123 self.runner.run(self.resultsdir, quiet=quiet)125 self.runner.run(self.resultsdir, quiet=quiet)
124 self._savetestdata()126 self._savetestdata()
127 os.chdir(self.origdir)
128 print("ABREK TEST RUN COMPLETE: Result id is '%s'" %
129 os.path.basename(self.resultsdir))
125130
126 def parse(self, resultname):131 def parse(self, resultname):
127 if not self.parser:132 if not self.parser:
@@ -131,6 +136,7 @@
131 resultsdir = os.path.join(config.resultsdir, resultname)136 resultsdir = os.path.join(config.resultsdir, resultname)
132 os.chdir(resultsdir)137 os.chdir(resultsdir)
133 self.parser.parse()138 self.parser.parse()
139 os.chdir(self.origdir)
134140
135141
136class AbrekTestInstaller(object):142class AbrekTestInstaller(object):
137143
=== modified file 'tests/__init__.py'
--- tests/__init__.py 2010-09-15 20:28:14 +0000
+++ tests/__init__.py 2010-10-15 15:12:59 +0000
@@ -17,6 +17,7 @@
1717
18def test_suite():18def test_suite():
19 module_names = ['tests.test_abrekcmd',19 module_names = ['tests.test_abrekcmd',
20 'tests.test_abrektest',
20 'tests.test_abrektestinstaller',21 'tests.test_abrektestinstaller',
21 'tests.test_abrektestparser',22 'tests.test_abrektestparser',
22 'tests.test_abrektestrunner',23 'tests.test_abrektestrunner',
2324
=== added file 'tests/test_abrektest.py'
--- tests/test_abrektest.py 1970-01-01 00:00:00 +0000
+++ tests/test_abrektest.py 2010-10-15 15:12:59 +0000
@@ -0,0 +1,48 @@
1# Copyright (c) 2010 Linaro
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16import re
17
18from abrek.testdef import AbrekTest, AbrekTestInstaller, AbrekTestRunner
19from imposters import OutputImposter, ConfigImposter
20from fixtures import TestCaseWithFixtures
21
22def maketest(name="foo", version="", installer=None, runner=None, parser=None):
23 if installer is None:
24 installer = makeinstaller()
25 return AbrekTest(name, version, installer, runner, parser)
26
27def makerunner(**kwargs):
28 return AbrekTestRunner(**kwargs)
29
30def makeinstaller(**kwargs):
31 return AbrekTestInstaller(**kwargs)
32
33class AbrekTestConfigOutput(TestCaseWithFixtures):
34 def setUp(self):
35 super(AbrekTestConfigOutput, self).setUp()
36 self.config = self.add_fixture(ConfigImposter())
37 self.out = self.add_fixture(OutputImposter())
38
39 def test_run(self):
40 testrunner = makerunner(steps=["echo foo"])
41 test = maketest(name="foo", runner=testrunner)
42 test.install()
43 test.run()
44 self.assertEqual("foo", self.out.getvalue().splitlines()[0])
45 completion_message = self.out.getvalue().splitlines()[1]
46 completion_pattern = "ABREK TEST RUN COMPLETE: Result id is 'foo\d+\.0'"
47 self.assertTrue(re.match(completion_pattern, completion_message))
48

Subscribers

People subscribed via source and target branches