50 |
|
import junit.framework.AssertionFailedError; |
51 |
|
import junit.framework.Test; |
52 |
|
import junit.framework.TestCase; |
53 |
+ |
import junit.framework.TestResult; |
54 |
|
import junit.framework.TestSuite; |
55 |
|
|
56 |
|
/** |
161 |
|
Integer.getInteger("jsr166.runsPerTest", 1); |
162 |
|
|
163 |
|
/** |
164 |
+ |
* The number of repetitions of the test suite (for finding leaks?). |
165 |
+ |
*/ |
166 |
+ |
private static final int suiteRuns = |
167 |
+ |
Integer.getInteger("jsr166.suiteRuns", 1); |
168 |
+ |
|
169 |
+ |
/** |
170 |
|
* A filter for tests to run, matching strings of the form |
171 |
|
* methodName(className), e.g. "testInvokeAll5(ForkJoinPoolTest)" |
172 |
|
* Usefully combined with jsr166.runsPerTest. |
205 |
|
|
206 |
|
/** |
207 |
|
* Runs all JSR166 unit tests using junit.textui.TestRunner. |
201 |
– |
* Optional command line arg provides the number of iterations to |
202 |
– |
* repeat running the tests. |
208 |
|
*/ |
209 |
|
public static void main(String[] args) { |
210 |
+ |
main(suite(), args); |
211 |
+ |
} |
212 |
+ |
|
213 |
+ |
/** |
214 |
+ |
* Runs all unit tests in the given test suite. |
215 |
+ |
* Actual behavior influenced by system properties jsr166.* |
216 |
+ |
*/ |
217 |
+ |
static void main(Test suite, String[] args) { |
218 |
|
if (useSecurityManager) { |
219 |
|
System.err.println("Setting a permissive security manager"); |
220 |
|
Policy.setPolicy(permissivePolicy()); |
221 |
|
System.setSecurityManager(new SecurityManager()); |
222 |
|
} |
223 |
< |
int iters = (args.length == 0) ? 1 : Integer.parseInt(args[0]); |
224 |
< |
|
225 |
< |
Test s = suite(); |
226 |
< |
for (int i = 0; i < iters; ++i) { |
214 |
< |
junit.textui.TestRunner.run(s); |
223 |
> |
for (int i = 0; i < suiteRuns; i++) { |
224 |
> |
TestResult result = junit.textui.TestRunner.run(suite); |
225 |
> |
if (!result.wasSuccessful()) |
226 |
> |
System.exit(1); |
227 |
|
System.gc(); |
228 |
|
System.runFinalization(); |
229 |
|
} |
218 |
– |
System.exit(0); |
230 |
|
} |
231 |
|
|
232 |
|
public static TestSuite newTestSuite(Object... suiteOrClasses) { |