author | Brock Pytlik <bpytlik@sun.com> |
Fri, 07 Nov 2008 10:51:51 -0800 | |
changeset 683 | 5e5d509f00e3 |
parent 616 | 6d307b088d92 |
child 1002 | 56ab3be9a8b7 |
permissions | -rw-r--r-- |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.4 |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
2 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
4 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
8 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
13 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
19 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
21 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
22 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
23 |
# Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
24 |
# Use is subject to license terms. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
25 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
26 |
import baseline |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
27 |
import copy |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
28 |
import string |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
29 |
import sys |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
30 |
import time |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
31 |
import unittest |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
571
diff
changeset
|
32 |
import gettext |
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
571
diff
changeset
|
33 |
|
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
571
diff
changeset
|
34 |
gettext.install("pkg", "/usr/lib/locale") |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
35 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
36 |
OUTPUT_DOTS=0 # Dots ... |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
37 |
OUTPUT_VERBOSE=1 # Verbose |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
38 |
OUTPUT_PARSEABLE=2 # Machine readable |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
39 |
|
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
40 |
class EarlyTearDownException(Exception): |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
41 |
"""An exception for inidicating early teardown of the testcase is |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
42 |
desired. This exception is only useful for testing depot startup and |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
43 |
whatnot from the test case setUp() functions, and shouldn't be used or |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
44 |
inherited from for other purposes. |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
45 |
""" |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
46 |
pass |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
47 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
48 |
class Pkg5TestCase(unittest.TestCase): |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
49 |
|
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
50 |
# Needed for compatability |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
51 |
failureException = AssertionError |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
52 |
|
683
5e5d509f00e3
4422 t_pkg_authority pinging extant node accidentally
Brock Pytlik <bpytlik@sun.com>
parents:
616
diff
changeset
|
53 |
bogus_url = "test.invalid" |
5e5d509f00e3
4422 t_pkg_authority pinging extant node accidentally
Brock Pytlik <bpytlik@sun.com>
parents:
616
diff
changeset
|
54 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
55 |
def __init__(self, methodName='runTest'): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
56 |
super(Pkg5TestCase, self).__init__(methodName) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
57 |
self.__testMethodName = methodName |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
58 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
59 |
def __str__(self): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
60 |
return "%s.py %s.%s" % (self.__class__.__module__, |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
61 |
self.__class__.__name__, self.__testMethodName) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
62 |
|
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
63 |
def getTeardownFunc(self): |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
64 |
return (self, self.tearDown) |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
65 |
|
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
66 |
def run(self, result=None): |
436 | 67 |
if result is None: |
68 |
result = self.defaultTestResult() |
|
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
69 |
result.startTest(self) |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
70 |
testMethod = getattr(self, self.__testMethodName) |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
71 |
try: |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
72 |
try: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
73 |
self.setUp() |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
74 |
except KeyboardInterrupt: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
75 |
raise |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
76 |
except EarlyTearDownException: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
77 |
self.tearDown() |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
78 |
result.addSuccess(self) |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
79 |
return |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
80 |
except: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
81 |
result.addError(self, sys.exc_info()) |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
82 |
return |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
83 |
|
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
84 |
ok = False |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
85 |
try: |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
86 |
testMethod() |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
87 |
ok = True |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
88 |
except self.failureException: |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
89 |
result.addFailure(self, sys.exc_info()) |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
90 |
except KeyboardInterrupt: |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
91 |
raise |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
92 |
except: |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
93 |
result.addError(self, sys.exc_info()) |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
94 |
|
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
95 |
try: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
96 |
self.tearDown() |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
97 |
except KeyboardInterrupt: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
98 |
raise |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
99 |
except: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
100 |
result.addError(self, sys.exc_info()) |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
101 |
ok = False |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
102 |
|
436 | 103 |
if ok: |
104 |
result.addSuccess(self) |
|
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
105 |
finally: |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
106 |
result.stopTest(self) |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
107 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
108 |
class _Pkg5TestResult(unittest._TextTestResult): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
109 |
baseline = None |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
110 |
machsep = "|" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
111 |
def __init__(self, stream, output, baseline): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
112 |
unittest.TestResult.__init__(self) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
113 |
self.stream = stream |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
114 |
self.output = output |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
115 |
self.baseline = baseline |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
116 |
self.success = [] |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
117 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
118 |
def addSuccess(self, test): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
119 |
unittest.TestResult.addSuccess(self, test) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
120 |
bresult = self.baseline.handleresult(str(test), "pass") |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
121 |
if self.output == OUTPUT_VERBOSE or \ |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
122 |
self.output == OUTPUT_PARSEABLE: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
123 |
res = "" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
124 |
if bresult == True: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
125 |
res = "pass" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
126 |
else: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
127 |
res = "pass (FAIL)" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
128 |
self.stream.writeln(res) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
129 |
elif self.output == OUTPUT_DOTS: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
130 |
self.stream.write('.') |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
131 |
self.success.append(test) |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
132 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
133 |
def addError(self, test, err): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
134 |
unittest.TestResult.addError(self, test, err) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
135 |
if self.output == OUTPUT_VERBOSE or \ |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
136 |
self.output == OUTPUT_PARSEABLE: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
137 |
self.stream.writeln("ERROR") |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
138 |
elif self.output == OUTPUT_DOTS: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
139 |
self.stream.write('E') |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
140 |
bresult = self.baseline.handleresult(str(test), "error") |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
141 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
142 |
def addFailure(self, test, err): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
143 |
unittest.TestResult.addFailure(self, test, err) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
144 |
bresult = self.baseline.handleresult(str(test), "fail") |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
145 |
if self.output == OUTPUT_VERBOSE or \ |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
146 |
self.output == OUTPUT_PARSEABLE: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
147 |
res = "" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
148 |
if bresult == True: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
149 |
res = "FAIL (pass)" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
150 |
else: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
151 |
res = "FAIL" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
152 |
self.stream.writeln(res) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
153 |
elif self.output == OUTPUT_DOTS: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
154 |
self.stream.write('F') |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
155 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
156 |
def getDescription(self, test): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
157 |
return str(test) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
158 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
159 |
def startTest(self, test): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
160 |
unittest.TestResult.startTest(self, test) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
161 |
if not self.output == OUTPUT_DOTS: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
162 |
self.stream.write( |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
163 |
string.ljust(self.getDescription(test), 60)) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
164 |
if self.output == OUTPUT_VERBOSE: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
165 |
self.stream.write(" ") |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
166 |
if self.output == OUTPUT_PARSEABLE: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
167 |
self.stream.write(" | ") |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
168 |
self.stream.flush() |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
169 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
170 |
def printErrors(self): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
171 |
self.stream.writeln() |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
172 |
self.printErrorList('ERROR', self.errors) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
173 |
self.printErrorList('FAIL', self.failures) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
174 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
175 |
def printErrorList(self, flavour, errors): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
176 |
for test, err in errors: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
177 |
self.stream.writeln(self.separator1) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
178 |
self.stream.writeln("%s: %s" % |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
179 |
(flavour, self.getDescription(test))) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
180 |
self.stream.writeln(self.separator2) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
181 |
self.stream.writeln("%s" % err) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
182 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
183 |
class Pkg5TestRunner(unittest.TextTestRunner): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
184 |
"""TestRunner for test suites that we want to be able to compare |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
185 |
against a result baseline.""" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
186 |
baseline = None |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
187 |
sep1 = '=' * 70 |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
188 |
sep2 = '-' * 70 |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
189 |
|
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
190 |
def __init__(self, baseline, stream=sys.stderr, output=OUTPUT_DOTS): |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
191 |
"""Set up the runner, creating a baseline object that has |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
192 |
a name of 'suite'_baseline.pkl, where suite is 'cli', 'api', |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
193 |
etc.""" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
194 |
# output is one of "dots", "verbose", "machine" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
195 |
super(Pkg5TestRunner, self).__init__(stream) |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
196 |
self.baseline = baseline |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
197 |
self.output = output |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
198 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
199 |
def _makeResult(self): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
200 |
return _Pkg5TestResult(self.stream, self.output, self.baseline) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
201 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
202 |
def run(self, test): |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
203 |
"Run the given test case or test suite." |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
204 |
result = self._makeResult() |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
205 |
startTime = time.time() |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
206 |
test(result) |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
207 |
stopTime = time.time() |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
208 |
timeTaken = stopTime - startTime |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
209 |
result.printErrors() |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
210 |
self.stream.writeln(result.separator2) |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
211 |
run = result.testsRun |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
212 |
self.stream.writeln("Ran %d test%s in %.3fs" % |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
213 |
(run, run != 1 and "s" or "", timeTaken)) |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
214 |
self.stream.writeln() |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
215 |
if not result.wasSuccessful(): |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
216 |
self.stream.write("FAILED (") |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
217 |
success, failed, errored, mismatches = map(len, |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
218 |
(result.success, result.failures, result.errors, |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
219 |
self.baseline.getfailures())) |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
220 |
self.stream.write("successes=%d, " % success) |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
221 |
self.stream.write("failures=%d, " % failed) |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
222 |
self.stream.write("errors=%d, " % errored) |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
223 |
self.stream.write("mismatches=%d" % mismatches) |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
224 |
self.stream.writeln(")") |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
225 |
else: |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
226 |
self.stream.writeln("OK") |
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
227 |
return result |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
228 |
|
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
229 |
class Pkg5TestSuite(unittest.TestSuite): |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
230 |
"""Test suite that handles persistent depot tests. Persistent depot |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
231 |
tests are ones that are able to only call their setUp/tearDown |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
232 |
functions once per class, instead of before and after every test case. |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
233 |
Aside from actually running the test it defers the majority of its |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
234 |
work to unittest.TestSuite. |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
235 |
|
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
236 |
To make a test class into a persistent depot one, add this class |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
237 |
variable declaration: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
238 |
persistent_depot = True |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
239 |
""" |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
240 |
|
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
241 |
def run(self, result): |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
242 |
inst = None |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
243 |
tdf = None |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
244 |
try: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
245 |
persistent_depot = getattr(self._tests[0], |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
246 |
"persistent_depot", False) |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
247 |
except IndexError: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
248 |
# No tests, thats ok. |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
249 |
return |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
250 |
|
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
251 |
if persistent_depot: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
252 |
inst, tdf = self._tests[0].getTeardownFunc() |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
253 |
try: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
254 |
inst.setUp() |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
255 |
except KeyboardInterrupt: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
256 |
raise |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
257 |
except: |
516
53da6297fb65
3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents:
502
diff
changeset
|
258 |
result.addError(inst, sys.exc_info()) |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
259 |
def donothing(): |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
260 |
pass |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
261 |
for test in self._tests: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
262 |
if result.shouldStop: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
263 |
break |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
264 |
# Populate test with the data from the instance |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
265 |
# already constructed, but update the method name. |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
266 |
# We need to do this so that we have all the state |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
267 |
# that the object is populated with when setUp() is |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
268 |
# called (depot controller list, etc). |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
269 |
if persistent_depot: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
270 |
name = test._Pkg5TestCase__testMethodName |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
271 |
test = copy.copy(inst) |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
272 |
test._Pkg5TestCase__testMethodName = name |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
273 |
# For test classes with persistent_depot set, |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
274 |
# make their setup/teardown methods do nothing |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
275 |
# since we are calling them here. |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
276 |
test.setUp = donothing |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
277 |
test.tearDown = donothing |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
278 |
test(result) |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
279 |
if persistent_depot: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
280 |
try: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
281 |
tdf() |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
282 |
except KeyboardInterrupt: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
283 |
raise |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
284 |
except: |
516
53da6297fb65
3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents:
502
diff
changeset
|
285 |
result.addError(inst, sys.exc_info()) |