]>
wolfpit.net Git - tool/Arch-pacman/.git/blob - test/pacman/pmenv.py
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/>.
35 def __init__(self
, root
= "root"):
36 self
.root
= os
.path
.abspath(root
)
46 return "root = %s\n" \
48 % (self
.root
, self
.pacman
)
50 def addtest(self
, testcase
):
53 if not os
.path
.isfile(testcase
):
54 raise IOError("test file %s not found" % testcase
)
55 test
= pmtest
.pmtest(testcase
, self
.root
)
56 self
.testcases
.append(test
)
62 for t
in self
.testcases
:
64 print "Running '%s'" % t
.testname
75 print "==> Test result"
76 if t
.result
["fail"] == 0:
89 for test
in self
.testcases
:
90 fail
= test
.result
["fail"]
91 if fail
== 0 and not test
.expectfailure
:
94 elif fail
!= 0 and test
.expectfailure
:
95 self
.expectedfail
+= 1
96 texpectedfail
.append(test
)
97 elif fail
== 0: # and not test.expectfail
98 self
.unexpectedpass
+= 1
99 tunexpectedpass
.append(test
)
105 success
= test
.result
["success"]
106 fail
= test
.result
["fail"]
107 rules
= len(test
.rules
)
113 print "%s Rules: OK = %2u FAIL = %2u SKIP = %2u" \
114 % (test
.testname
.ljust(34), success
, fail
, \
115 rules
- (success
+ fail
))
117 # print test description if test failed
118 print " ", test
.description
124 for test
in tpassed
: _printtest(test
)
126 print " Expected Failures:"
127 for test
in texpectedfail
: _printtest(test
)
129 print " Unexpected Passes:"
130 for test
in tunexpectedpass
: _printtest(test
)
133 for test
in tfailed
: _printtest(test
)
136 total
= len(self
.testcases
)
137 print "Total = %3u" % total
139 print "Pass = %3u (%6.2f%%)" % (self
.passed
, float(self
.passed
) * 100 / total
)
140 print "Expected Fail = %3u (%6.2f%%)" % (self
.expectedfail
, float(self
.expectedfail
) * 100 / total
)
141 print "Unexpected Pass = %3u (%6.2f%%)" % (self
.unexpectedpass
, float(self
.unexpectedpass
) * 100 / total
)
142 print "Fail = %3u (%6.2f%%)" % (self
.failed
, float(self
.failed
) * 100 / total
)
145 if __name__
== "__main__":
148 # vim: set ts=4 sw=4 et: