1 |
commit: 84dc3edc91e0e74fc0725841b7b335fafe641e48 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue May 31 16:58:18 2011 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue May 31 16:59:35 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=84dc3edc |
7 |
|
8 |
Support checking whether the tests have been merged. |
9 |
|
10 |
--- |
11 |
PMSTestSuite/library/case.py | 21 ++++++++++++++++++++- |
12 |
PMSTestSuite/library/test/random_test.py | 1 + |
13 |
PMSTestSuite/testrunner.py | 19 +++++++++++++++++-- |
14 |
3 files changed, 38 insertions(+), 3 deletions(-) |
15 |
|
16 |
diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py |
17 |
index 103d822..f02a5e1 100644 |
18 |
--- a/PMSTestSuite/library/case.py |
19 |
+++ b/PMSTestSuite/library/case.py |
20 |
@@ -46,7 +46,16 @@ class TestCase(object): |
21 |
pass |
22 |
|
23 |
class EbuildTestCase(TestCase): |
24 |
- """ Test case using a single ebuild (per EAPI). """ |
25 |
+ """ |
26 |
+ Test case using a single ebuild (per EAPI). |
27 |
+ |
28 |
+ Properties: |
29 |
+ - expect_failure - if set to False (the default), the test is supposed |
30 |
+ to merge successfully. Otherwise, the test ebuild is supposed to fail |
31 |
+ to merge (die). |
32 |
+ """ |
33 |
+ |
34 |
+ expect_failure = False |
35 |
|
36 |
@classmethod |
37 |
def inst_all(cls, *args, **kwargs): |
38 |
@@ -102,3 +111,13 @@ class EbuildTestCase(TestCase): |
39 |
fn = 'pms-test/%s/%s.ebuild' % (self.pn, self.p) |
40 |
|
41 |
return {fn: EbuildTestCaseEbuildFile(self)} |
42 |
+ |
43 |
+ def check_result(self, merged): |
44 |
+ """ |
45 |
+ Check the correctness of the result of test execution. <merged> should |
46 |
+ indicate whether the ebuild was actually merged. |
47 |
+ |
48 |
+ Returns True if the results indicate that the test succeeded, False |
49 |
+ otherwise. |
50 |
+ """ |
51 |
+ return (merged != self.expect_failure) |
52 |
|
53 |
diff --git a/PMSTestSuite/library/test/random_test.py b/PMSTestSuite/library/test/random_test.py |
54 |
index d60c32d..088bda5 100644 |
55 |
--- a/PMSTestSuite/library/test/random_test.py |
56 |
+++ b/PMSTestSuite/library/test/random_test.py |
57 |
@@ -10,6 +10,7 @@ class RandomExampleTest(EbuildTestCase): |
58 |
""" |
59 |
|
60 |
relevant_eapis = (0, 1, 2, 4) |
61 |
+ expect_failure = True |
62 |
|
63 |
ebuild_vars = { |
64 |
'DESCRIPTION': 'A really random test' |
65 |
|
66 |
diff --git a/PMSTestSuite/testrunner.py b/PMSTestSuite/testrunner.py |
67 |
index 8ac4d6e..f642aaa 100644 |
68 |
--- a/PMSTestSuite/testrunner.py |
69 |
+++ b/PMSTestSuite/testrunner.py |
70 |
@@ -4,8 +4,23 @@ import gobject |
71 |
|
72 |
class TestRunnerCLI(EbuildGenCLI): |
73 |
def merge_done(self, pid, ret): |
74 |
- print(self.pm.lookup_vardb(self.cpvs)) |
75 |
- self.ret = 0 |
76 |
+ failed = [] |
77 |
+ |
78 |
+ cpvs = frozenset(self.pm.lookup_vardb(self.cpvs)) |
79 |
+ for t in self.test_library: |
80 |
+ res = t.check_result(t.p in cpvs) |
81 |
+ if not res: |
82 |
+ failed.append(t) |
83 |
+ |
84 |
+ if not failed: |
85 |
+ print('%d tests completed successfully.' % len(self.cpvs)) |
86 |
+ else: |
87 |
+ print('%d of %d tests completed successfully, %d failed:' |
88 |
+ % (len(self.cpvs) - len(failed), len(self.cpvs), len(failed))) |
89 |
+ for t in failed: |
90 |
+ print('- %s' % t.p) |
91 |
+ |
92 |
+ self.ret = 0 if not failed else 1 |
93 |
self.loop.quit() |
94 |
|
95 |
def main(self, argv): |