equal
deleted
inserted
replaced
50 * default is to stdout |
50 * default is to stdout |
51 * -title string specify a title, only applies to HTML output |
51 * -title string specify a title, only applies to HTML output |
52 */ |
52 */ |
53 public class RunExamples { |
53 public class RunExamples { |
54 public static void main(String... args) throws Exception { |
54 public static void main(String... args) throws Exception { |
55 boolean jtreg = (System.getProperty("test.src") != null); |
55 jtreg = (System.getProperty("test.src") != null); |
56 File tmpDir; |
56 File tmpDir; |
57 if (jtreg) { |
57 if (jtreg) { |
58 // use standard jtreg scratch directory: the current directory |
58 // use standard jtreg scratch directory: the current directory |
59 tmpDir = new File(System.getProperty("user.dir")); |
59 tmpDir = new File(System.getProperty("user.dir")); |
60 } else { |
60 } else { |
164 * Get the complete set of examples to be checked. |
164 * Get the complete set of examples to be checked. |
165 */ |
165 */ |
166 Set<Example> getExamples(File examplesDir) { |
166 Set<Example> getExamples(File examplesDir) { |
167 Set<Example> results = new TreeSet<Example>(); |
167 Set<Example> results = new TreeSet<Example>(); |
168 for (File f: examplesDir.listFiles()) { |
168 for (File f: examplesDir.listFiles()) { |
169 if (f.isDirectory() || f.isFile() && f.getName().endsWith(".java")) |
169 if (isValidExample(f)) |
170 results.add(new Example(f)); |
170 results.add(new Example(f)); |
171 } |
171 } |
172 return results; |
172 return results; |
|
173 } |
|
174 |
|
175 boolean isValidExample(File f) { |
|
176 return (f.isDirectory() && (!jtreg || f.list().length > 0)) || |
|
177 (f.isFile() && f.getName().endsWith(".java")); |
173 } |
178 } |
174 |
179 |
175 /** |
180 /** |
176 * Report an error. |
181 * Report an error. |
177 */ |
182 */ |
178 void error(String msg) { |
183 void error(String msg) { |
179 System.err.println("Error: " + msg); |
184 System.err.println("Error: " + msg); |
180 errors++; |
185 errors++; |
181 } |
186 } |
|
187 |
|
188 static boolean jtreg; |
182 |
189 |
183 int errors; |
190 int errors; |
184 |
191 |
185 /** |
192 /** |
186 * Clean the contents of a directory. |
193 * Clean the contents of a directory. |