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

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

vendor: Add icedtea-web v1.1.2 to current.

File size: 1.6 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.util.ArrayList;
11import java.util.List;
12
13import org.junit.internal.JUnitSystem;
14import org.junit.internal.RealSystem;
15import org.junit.runner.JUnitCore;
16import org.junit.runner.Result;
17import org.junit.runner.notification.Failure;
18import org.junit.runner.notification.RunListener;
19
20public class CommandLine extends JUnitCore {
21
22 public static void main(String... args) {
23 runMainAndExit(new RealSystem(), args);
24 }
25
26 public static void runMainAndExit(JUnitSystem system, String... args) {
27 new CommandLine().runMain(system, args);
28 system.exit(0);
29 }
30
31 @Override
32 public Result runMain(JUnitSystem system, String... args) {
33 List<Class<?>> classes = new ArrayList<Class<?>>();
34 List<Failure> missingClasses = new ArrayList<Failure>();
35 for (String each : args) {
36 try {
37 classes.add(Class.forName(each));
38 } catch (ClassNotFoundException e) {
39 system.out().println("ERROR: Could not find class: " + each);
40 }
41 }
42 RunListener listener = new LessVerboseTextListener(system);
43 addListener(listener);
44 Result result = run(classes.toArray(new Class[0]));
45 for (Failure each : missingClasses) {
46 result.getFailures().add(each);
47 }
48 return result;
49 }
50
51}
Note: See TracBrowser for help on using the repository browser.