Source code: org/eclipse/pde/internal/junit/runtime/CoreTestApplication.java
1 /*
2 * (c) Copyright IBM Corp. 2000, 2001.
3 * All Rights Reserved.
4 */
5 package org.eclipse.pde.internal.junit.runtime;
6
7 import org.eclipse.core.boot.IPlatformRunnable;
8
9 /**
10 * A an application that launches tests once it is started.
11 */
12 public class CoreTestApplication implements IPlatformRunnable {
13
14 /**
15 * Should workspace tests log their deltas?
16 */
17 private static boolean deltas= false;
18
19 /**
20 * Runs a set of tests as defined by the given command line args.
21 * This is the platform application entry point.
22 * @see IPlatformRunnable
23 */
24 public Object run(Object arguments) throws Exception {
25 String[] args= processCommandLine((String[]) arguments);
26 RemotePluginTestRunner.main(args);
27 return null;
28 }
29
30 public static boolean deltasEnabled() {
31 return deltas;
32 }
33
34 protected String[] processCommandLine(String[] args) {
35 int[] configArgs = new int[100];
36 configArgs[0] = -1; // need to initialize the first element to something that could not be an index.
37 int configArgIndex = 0;
38 for (int i = 0; i < args.length; i++) {
39 boolean found = false;
40 // check for args without parameters (i.e., a flag arg)
41 // see if we should be logging deltas
42 if (args[i].equalsIgnoreCase("-deltas")) { //$NON-NLS-1$
43 found = true;
44 deltas = true;
45 }
46 if (found) {
47 configArgs[configArgIndex++] = i;
48 continue;
49 }
50
51 // check for args with parameters
52 if (i == args.length - 1 || args[i + 1].startsWith("-")) { //$NON-NLS-1$
53 continue;
54 }
55 // done checking for args. Remember where an arg was found
56 if (found) {
57 configArgs[configArgIndex++] = i - 1;
58 configArgs[configArgIndex++] = i;
59 }
60 }
61
62 //remove all the arguments consumed by this argument parsing
63 if (configArgIndex == 0)
64 return args;
65 String[] passThruArgs = new String[args.length - configArgIndex];
66 configArgIndex = 0;
67 int j = 0;
68 for (int i = 0; i < args.length; i++) {
69 if (i == configArgs[configArgIndex])
70 configArgIndex++;
71 else
72 passThruArgs[j++] = args[i];
73 }
74 return passThruArgs;
75 }
76 }