Mercurial > hg > truffle
annotate mx/JUnitWrapper.java @ 15831:1ddee372bf62
Make classes extensible
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 20 May 2014 18:55:59 -0700 |
parents | a26be2c9b81b |
children | 151fe6b1e511 |
rev | line source |
---|---|
8406
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
1 /* |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
4 * |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
8 * |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
14 * |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
18 * |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
21 * questions. |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
22 */ |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
23 |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
24 |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
25 /* Execute testcases by reading names from a given file, due to limits of |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
26 * the operating system regarding command line size (windows: 32k, |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
27 * linux [depending on the settings]: ~2097k) |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
28 * see http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
29 */ |
15500 | 30 import com.oracle.graal.test.*; |
8406
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
31 import java.io.*; |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
32 import java.util.*; |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
33 |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
34 public class JUnitWrapper { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
35 |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
36 /** |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
37 * @param args |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
38 * args[0] is the path where to read the names of the testclasses. |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
39 */ |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
40 public static void main(String[] args) { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
41 if (args.length == 0) { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
42 System.err.printf("wrong usage. provide a filename\n"); |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
43 System.exit(1); |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
44 } |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
45 ArrayList<String> tests = new ArrayList<String>(1000); |
15502
a26be2c9b81b
Add command line support for JUnit.
Josef Eisl <josef.eisl@jku.at>
parents:
15500
diff
changeset
|
46 // add JUnit command line arguments |
a26be2c9b81b
Add command line support for JUnit.
Josef Eisl <josef.eisl@jku.at>
parents:
15500
diff
changeset
|
47 for (int i = 1; i < args.length; i++) { |
a26be2c9b81b
Add command line support for JUnit.
Josef Eisl <josef.eisl@jku.at>
parents:
15500
diff
changeset
|
48 tests.add(args[i]); |
a26be2c9b81b
Add command line support for JUnit.
Josef Eisl <josef.eisl@jku.at>
parents:
15500
diff
changeset
|
49 } |
8406
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
50 BufferedReader br = null; |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
51 try { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
52 br = new BufferedReader(new FileReader(args[0])); |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
53 |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
54 String buf; |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
55 while ((buf = br.readLine()) != null) { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
56 tests.add(buf); |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
57 } |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
58 } catch (IOException ioe) { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
59 ioe.printStackTrace(); |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
60 System.exit(2); |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
61 } finally { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
62 try { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
63 if (br != null) { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
64 br.close(); |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
65 } |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
66 } catch (IOException ioe) { |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
67 ioe.printStackTrace(); |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
68 System.exit(3); |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
69 } |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
70 } |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
71 |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
72 String[] strargs = tests.toArray(new String[tests.size()]); |
9637
f38f746f4980
JUnitWrapper: print class name if only one testclass is executed
Bernhard Urban <bernhard.urban@jku.at>
parents:
8435
diff
changeset
|
73 if (strargs.length == 1) { |
f38f746f4980
JUnitWrapper: print class name if only one testclass is executed
Bernhard Urban <bernhard.urban@jku.at>
parents:
8435
diff
changeset
|
74 System.out.printf("executing junit test now... (%s)\n", strargs[0]); |
f38f746f4980
JUnitWrapper: print class name if only one testclass is executed
Bernhard Urban <bernhard.urban@jku.at>
parents:
8435
diff
changeset
|
75 } else { |
f38f746f4980
JUnitWrapper: print class name if only one testclass is executed
Bernhard Urban <bernhard.urban@jku.at>
parents:
8435
diff
changeset
|
76 System.out.printf("executing junit tests now... (%d test classes)\n", strargs.length); |
f38f746f4980
JUnitWrapper: print class name if only one testclass is executed
Bernhard Urban <bernhard.urban@jku.at>
parents:
8435
diff
changeset
|
77 } |
15500 | 78 GraalJUnitCore.main(strargs); |
8406
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
79 } |
2bfb9644dcc2
unittest: call wrapper to avoid long command lines
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff
changeset
|
80 } |