ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/JSR166TestCase.java
(Generate patch)

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.177 by jsr166, Mon Oct 12 23:52:44 2015 UTC vs.
Revision 1.183 by jsr166, Sat Jan 23 20:15:28 2016 UTC

# Line 6 | Line 6
6   * Pat Fisher, Mike Judd.
7   */
8  
9 + /*
10 + * @test
11 + * @summary JSR-166 tck tests
12 + * @build *
13 + * @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true JSR166TestCase
14 + */
15 +
16   import static java.util.concurrent.TimeUnit.MILLISECONDS;
17   import static java.util.concurrent.TimeUnit.MINUTES;
18   import static java.util.concurrent.TimeUnit.NANOSECONDS;
# Line 112 | Line 119 | import junit.framework.TestSuite;
119   * methods as there are exceptions the method can throw. Sometimes
120   * there are multiple tests per JSR166 method when the different
121   * "normal" behaviors differ significantly. And sometimes testcases
122 < * cover multiple methods when they cannot be tested in
116 < * isolation.
122 > * cover multiple methods when they cannot be tested in isolation.
123   *
124   * <li>The documentation style for testcases is to provide as javadoc
125   * a simple sentence or two describing the property that the testcase
# Line 176 | Line 182 | public class JSR166TestCase extends Test
182      private static final int suiteRuns =
183          Integer.getInteger("jsr166.suiteRuns", 1);
184  
185 +    /**
186 +     * The scaling factor to apply to standard delays used in tests.
187 +     */
188 +    private static final int delayFactor =
189 +        Integer.getInteger("jsr166.delay.factor", 1);
190 +
191      public JSR166TestCase() { super(); }
192      public JSR166TestCase(String name) { super(name); }
193  
# Line 273 | Line 285 | public class JSR166TestCase extends Test
285          main(suite(), args);
286      }
287  
288 +    static class PithyResultPrinter extends junit.textui.ResultPrinter {
289 +        PithyResultPrinter(java.io.PrintStream writer) { super(writer); }
290 +        long runTime;
291 +        public void startTest(Test test) {}
292 +        protected void printHeader(long runTime) {
293 +            this.runTime = runTime; // defer printing for later
294 +        }
295 +        protected void printFooter(TestResult result) {
296 +            if (result.wasSuccessful()) {
297 +                getWriter().println("OK (" + result.runCount() + " tests)"
298 +                    + "  Time: " + elapsedTimeAsString(runTime));
299 +            } else {
300 +                getWriter().println("Time: " + elapsedTimeAsString(runTime));
301 +                super.printFooter(result);
302 +            }
303 +        }
304 +    }
305 +
306 +    /**
307 +     * Returns a TestRunner that doesn't bother with unnecessary
308 +     * fluff, like printing a "." for each test case.
309 +     */
310 +    static junit.textui.TestRunner newPithyTestRunner() {
311 +        junit.textui.TestRunner runner = new junit.textui.TestRunner();
312 +        runner.setPrinter(new PithyResultPrinter(System.out));
313 +        return runner;
314 +    }
315 +
316      /**
317       * Runs all unit tests in the given test suite.
318       * Actual behavior influenced by jsr166.* system properties.
# Line 284 | Line 324 | public class JSR166TestCase extends Test
324              System.setSecurityManager(new SecurityManager());
325          }
326          for (int i = 0; i < suiteRuns; i++) {
327 <            TestResult result = junit.textui.TestRunner.run(suite);
327 >            TestResult result = newPithyTestRunner().doRun(suite);
328              if (!result.wasSuccessful())
329                  System.exit(1);
330              System.gc();
# Line 521 | Line 561 | public class JSR166TestCase extends Test
561      public static long LONG_DELAY_MS;
562  
563      /**
564 <     * Returns the shortest timed delay. This could
565 <     * be reimplemented to use for example a Property.
564 >     * Returns the shortest timed delay. This can be scaled up for
565 >     * slow machines using the jsr166.delay.factor system property.
566       */
567      protected long getShortDelay() {
568 <        return 50;
568 >        return 50 * delayFactor;
569      }
570  
571      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines