source: trunk/icedtea-web/tests/junit-runner/CommandLine.java@ 418

Last change on this file since 418 was 418, checked in by dmik, 13 years ago

Merge icedtea-web v1.3 to trunk.

File size: 1.8 KB
Line 
1/*
2 * Copyright 2011 Red Hat, Inc.
3 * Based on code from JUnit
4 *
5 * This file is made available under the terms of the Common Public License
6 * v1.0 which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/cpl-v10.html
8 */
9
10import java.io.File;
11import java.util.ArrayList;
12import java.util.List;
13
14import org.junit.internal.JUnitSystem;
15import org.junit.internal.RealSystem;
16import org.junit.runner.JUnitCore;
17import org.junit.runner.Result;
18import org.junit.runner.notification.Failure;
19import org.junit.runner.notification.RunListener;
20
21public class CommandLine extends JUnitCore {
22
23 public static void main(String... args) {
24 runMainAndExit(new RealSystem(), args);
25 }
26
27 public static void runMainAndExit(JUnitSystem system, String... args) {
28 new CommandLine().runMain(system, args);
29 system.exit(0);
30 }
31
32 @Override
33 public Result runMain(JUnitSystem system, String... args) {
34 List<Class<?>> classes = new ArrayList<Class<?>>();
35 List<Failure> missingClasses = new ArrayList<Failure>();
36 for (String each : args) {
37 try {
38 if (each.contains("$")) continue;
39 if (each.toLowerCase().endsWith(".jnlp")) continue;
40 classes.add(Class.forName(each));
41 } catch (ClassNotFoundException e) {
42 system.out().println("ERROR: Could not find class: " + each);
43 }
44 }
45 RunListener jXmlOutput = new JunitLikeXmlOutputListener(system, new File("tests-output.xml"));
46 addListener(jXmlOutput);
47 RunListener listener = new LessVerboseTextListener(system);
48 addListener(listener);
49 Result result = run(classes.toArray(new Class[0]));
50 for (Failure each : missingClasses) {
51 result.getFailures().add(each);
52 }
53 return result;
54 }
55
56}
Note: See TracBrowser for help on using the repository browser.