3 # Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
36 def __init__(self
, root
= "root"):
37 self
.root
= os
.path
.abspath(root
)
47 return "root = %s\n" \
49 % (self
.root
, self
.pacman
)
51 def addtest(self
, testcase
):
54 if not os
.path
.isfile(testcase
):
55 raise IOError("test file %s not found" % testcase
)
56 test
= pmtest
.pmtest(testcase
, self
.root
)
57 self
.testcases
.append(test
)
63 for t
in self
.testcases
:
65 print "Running '%s'" % t
.testname
72 # Hack for mtimes consistency
74 if i
.rule
.find("FILE_MODIFIED") != -1:
75 [test
, arg
] = i
.rule
.split("=")
83 print "==> Test result"
84 if t
.result
["fail"] == 0:
97 for test
in self
.testcases
:
98 fail
= test
.result
["fail"]
99 if fail
== 0 and not test
.expectfailure
:
102 elif fail
!= 0 and test
.expectfailure
:
103 self
.expectedfail
+= 1
104 texpectedfail
.append(test
)
105 elif fail
== 0: # and not test.expectfail
106 self
.unexpectedpass
+= 1
107 tunexpectedpass
.append(test
)
113 success
= test
.result
["success"]
114 fail
= test
.result
["fail"]
115 rules
= len(test
.rules
)
121 print "%s Rules: OK = %2u FAIL = %2u SKIP = %2u" \
122 % (test
.testname
.ljust(34), success
, fail
, \
123 rules
- (success
+ fail
))
125 # print test description if test failed
126 print " ", test
.description
132 for test
in tpassed
: _printtest(test
)
134 print " Expected Failures:"
135 for test
in texpectedfail
: _printtest(test
)
137 print " Unexpected Passes:"
138 for test
in tunexpectedpass
: _printtest(test
)
141 for test
in tfailed
: _printtest(test
)
144 total
= len(self
.testcases
)
145 print "Total = %3u" % total
147 print "Pass = %3u (%6.2f%%)" % (self
.passed
, float(self
.passed
) * 100 / total
)
148 print "Expected Fail = %3u (%6.2f%%)" % (self
.expectedfail
, float(self
.expectedfail
) * 100 / total
)
149 print "Unexpected Pass = %3u (%6.2f%%)" % (self
.unexpectedpass
, float(self
.unexpectedpass
) * 100 / total
)
150 print "Fail = %3u (%6.2f%%)" % (self
.failed
, float(self
.failed
) * 100 / total
)
153 if __name__
== "__main__":
156 # vim: set ts=4 sw=4 et: