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.60 by jsr166, Wed Oct 6 07:49:22 2010 UTC vs.
Revision 1.62 by jsr166, Mon Oct 11 05:40:41 2010 UTC

# Line 96 | Line 96 | public class JSR166TestCase extends Test
96      private static final boolean useSecurityManager =
97          Boolean.getBoolean("jsr166.useSecurityManager");
98  
99 +    protected static final boolean expensiveTests =
100 +        Boolean.getBoolean("jsr166.expensiveTests");
101 +
102 +    /**
103 +     * If true, report on stdout all "slow" tests, that is, ones that
104 +     * take more than profileThreshold milliseconds to execute.
105 +     */
106 +    private static final boolean profileTests =
107 +        Boolean.getBoolean("jsr166.profileTests");
108 +
109 +    /**
110 +     * The number of milliseconds that tests are permitted for
111 +     * execution without being reported, when profileTests is set.
112 +     */
113 +    private static final long profileThreshold =
114 +        Long.getLong("jsr166.profileThreshold", 100);
115 +
116 +    protected void runTest() throws Throwable {
117 +        if (profileTests)
118 +            runTestProfiled();
119 +        else
120 +            super.runTest();
121 +    }
122 +
123 +    protected void runTestProfiled() throws Throwable {
124 +        long t0 = System.nanoTime();
125 +        try {
126 +            super.runTest();
127 +        } finally {
128 +            long elapsedMillis =
129 +                (System.nanoTime() - t0) / (1000L * 1000L);
130 +            if (elapsedMillis >= profileThreshold)
131 +                System.out.printf("%n%s: %d%n", toString(), elapsedMillis);
132 +        }
133 +    }
134 +    
135      /**
136       * Runs all JSR166 unit tests using junit.textui.TestRunner
137       */
# Line 796 | Line 832 | public class JSR166TestCase extends Test
832          }
833      }
834  
835 +    public interface TrackedRunnable extends Runnable {
836 +        boolean isDone();
837 +    }
838 +
839 +    public static TrackedRunnable trackedRunnable(final long timeoutMillis) {
840 +        return new TrackedRunnable() {
841 +                private volatile boolean done = false;
842 +                public boolean isDone() { return done; }
843 +                public void run() {
844 +                    try {
845 +                        Thread.sleep(timeoutMillis);
846 +                        done = true;
847 +                    } catch (InterruptedException ok) {}
848 +                }
849 +            };
850 +    }
851 +
852      public static class TrackedShortRunnable implements Runnable {
853          public volatile boolean done = false;
854          public void run() {
855              try {
856 +                Thread.sleep(SHORT_DELAY_MS);
857 +                done = true;
858 +            } catch (InterruptedException ok) {}
859 +        }
860 +    }
861 +
862 +    public static class TrackedSmallRunnable implements Runnable {
863 +        public volatile boolean done = false;
864 +        public void run() {
865 +            try {
866                  Thread.sleep(SMALL_DELAY_MS);
867                  done = true;
868              } catch (InterruptedException ok) {}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines