269 scenarios = Arrays.asList(SCENARIOS.split(",")); 270 } 271 for (int i=0; i<test.getNumScenarios(); i++) { 272 if (scenarios == null || scenarios.contains(Integer.toString(i))) { 273 System.out.println("Scenario #" + i + " -------- "); 274 String[] cmds = InputArguments.getVmInputArgs(); 275 cmds = concat(cmds, test.getVMParameters(i)); 276 cmds = concat(cmds, test.getExtraVMParameters(i)); 277 cmds = concat(cmds, testMainClassName); 278 279 OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds); 280 String output = oa.getOutput(); 281 oa.shouldHaveExitValue(0); 282 System.out.println(output); 283 } else { 284 System.out.println("Scenario #" + i + " is skipped due to -Dscenarios=" + SCENARIOS); 285 } 286 } 287 } 288 289 protected ValueTypeTest() { 290 List<String> list = null; 291 List<String> exclude = null; 292 if (!TESTLIST.isEmpty()) { 293 list = Arrays.asList(TESTLIST.split(",")); 294 } 295 if (!EXCLUDELIST.isEmpty()) { 296 exclude = Arrays.asList(EXCLUDELIST.split(",")); 297 } 298 // Gather all test methods and put them in Hashtable 299 for (Method m : getClass().getDeclaredMethods()) { 300 Test[] annos = m.getAnnotationsByType(Test.class); 301 if (annos.length != 0 && 302 ((list == null || list.contains(m.getName())) && (exclude == null || !exclude.contains(m.getName())))) { 303 tests.put(getClass().getSimpleName() + "::" + m.getName(), m); 304 } 305 } 306 } 307 308 protected void run(String[] args, Class<?>... classes) throws Throwable { 309 if (args.length == 0) { 310 // Spawn a new VM instance 311 execute_vm(); 312 } else { 313 // Execute tests 314 run(classes); 315 } 316 } 317 | 269 scenarios = Arrays.asList(SCENARIOS.split(",")); 270 } 271 for (int i=0; i<test.getNumScenarios(); i++) { 272 if (scenarios == null || scenarios.contains(Integer.toString(i))) { 273 System.out.println("Scenario #" + i + " -------- "); 274 String[] cmds = InputArguments.getVmInputArgs(); 275 cmds = concat(cmds, test.getVMParameters(i)); 276 cmds = concat(cmds, test.getExtraVMParameters(i)); 277 cmds = concat(cmds, testMainClassName); 278 279 OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds); 280 String output = oa.getOutput(); 281 oa.shouldHaveExitValue(0); 282 System.out.println(output); 283 } else { 284 System.out.println("Scenario #" + i + " is skipped due to -Dscenarios=" + SCENARIOS); 285 } 286 } 287 } 288 289 // To exclude test cases, use -DExclude=<case1>,<case2>,... 290 // Each case can be just the method name, or can be <class>.<method>. The latter form is useful 291 // when you are running several tests at the same time. 292 // 293 // jtreg -DExclude=test12 TestArrays.java 294 // jtreg -DExclude=test34 TestLWorld.java 295 // -- or -- 296 // jtreg -DExclude=TestArrays.test12,TestLWorld.test34 TestArrays.java TestLWorld.java 297 // 298 private List<String> buildExcludeList() { 299 List<String> exclude = null; 300 String classPrefix = getClass().getSimpleName() + "."; 301 if (!EXCLUDELIST.isEmpty()) { 302 exclude = new ArrayList(Arrays.asList(EXCLUDELIST.split(","))); 303 for (int i = exclude.size() - 1; i >= 0; i--) { 304 String ex = exclude.get(i); 305 if (ex.indexOf(".") > 0) { 306 if (ex.startsWith(classPrefix)) { 307 ex = ex.substring(classPrefix.length()); 308 exclude.set(i, ex); 309 } else { 310 exclude.remove(i); 311 } 312 } 313 } 314 } 315 return exclude; 316 } 317 318 protected ValueTypeTest() { 319 List<String> list = null; 320 if (!TESTLIST.isEmpty()) { 321 list = Arrays.asList(TESTLIST.split(",")); 322 } 323 List<String> exclude = buildExcludeList(); 324 325 // Gather all test methods and put them in Hashtable 326 for (Method m : getClass().getDeclaredMethods()) { 327 Test[] annos = m.getAnnotationsByType(Test.class); 328 if (annos.length != 0 && 329 ((list == null || list.contains(m.getName())) && (exclude == null || !exclude.contains(m.getName())))) { 330 tests.put(getClass().getSimpleName() + "::" + m.getName(), m); 331 } 332 } 333 } 334 335 protected void run(String[] args, Class<?>... classes) throws Throwable { 336 if (args.length == 0) { 337 // Spawn a new VM instance 338 execute_vm(); 339 } else { 340 // Execute tests 341 run(classes); 342 } 343 } 344 |