bundle testng 5.11
[fedora-idea.git] / plugins / testng_rt / src / org / testng / RemoteTestNGStarter.java
blob0ca02ef331ae3a121c39c41c69c7ab015aef5b36
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * User: anna
19 * Date: 01-Jul-2009
21 package org.testng;
23 import org.testng.remote.RemoteTestNG;
25 import java.io.BufferedReader;
26 import java.io.File;
27 import java.io.FileReader;
28 import java.util.Map;
29 import java.util.Vector;
31 public class RemoteTestNGStarter {
32 public static void main(String[] args) throws Exception {
33 int i = 0;
34 Vector resultArgs = new Vector();
35 for (; i < args.length; i++) {
36 String arg = args[i];
37 if (arg.equals("-temp")) {
38 break;
40 resultArgs.add(arg);
43 File temp = new File(args[++i]);
45 while (temp.length() == 0){
46 //wait for test classes
49 BufferedReader reader = new BufferedReader(new FileReader(temp));
51 try {
52 final String cantRunMessage = "CantRunException";
53 while (true) {
54 String line = reader.readLine();
55 while (line == null) {
56 Thread.sleep(100);
57 line = reader.readLine();
60 if (line.startsWith(cantRunMessage) && !new File(line).exists()){
61 System.err.println(line.substring(cantRunMessage.length()));
62 System.exit(1);
63 return;
65 if (line.equals("end")) break;
66 resultArgs.add(line);
69 finally {
70 reader.close();
74 Map commandLineArgs= TestNGCommandLineArgs.parseCommandLine((String[])resultArgs.toArray(new String[resultArgs.size()]));
76 RemoteTestNG testNG= new RemoteTestNG();
77 testNG.configure(commandLineArgs);
78 testNG.initializeSuitesAndJarFile();
79 testNG.run();