View | Details | Raw Unified | Return to bug 414653 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java (-2 / +4 lines)
Lines 1084-1090 Link Here
1084
				expectedSuccessOutputString,
1084
				expectedSuccessOutputString,
1085
				this.classpaths,
1085
				this.classpaths,
1086
				null,
1086
				null,
1087
				vmArguments);
1087
				vmArguments,
1088
				getClass().getName()+'_'+getName());
1088
		assertTrue(this.verifier.failureReason, // computed by verifyClassFiles(...) action
1089
		assertTrue(this.verifier.failureReason, // computed by verifyClassFiles(...) action
1089
				passed);
1090
				passed);
1090
		if (vmArguments != null) {
1091
		if (vmArguments != null) {
Lines 2519-2525 Link Here
2519
					expectedErrorString,
2520
					expectedErrorString,
2520
					this.classpaths,
2521
					this.classpaths,
2521
					null,
2522
					null,
2522
					vmArguments);
2523
					vmArguments,
2524
					getClass().getName()+'.'+getName());
2523
			if (!passed) {
2525
			if (!passed) {
2524
				System.out.println(getClass().getName() + '#' + getName());
2526
				System.out.println(getClass().getName() + '#' + getName());
2525
				String execErrorString = this.verifier.getExecutionError();
2527
				String execErrorString = this.verifier.getExecutionError();
(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java (-15 / +40 lines)
Lines 146-152 Link Here
146
private String getVerifyTestsCode() {
146
private String getVerifyTestsCode() {
147
	return
147
	return
148
		"/*******************************************************************************\n" + 
148
		"/*******************************************************************************\n" + 
149
		" * Copyright (c) 2000, 2011 IBM Corporation and others.\n" + 
149
		" * Copyright (c) 2000, 2012 IBM Corporation and others.\n" + 
150
		" * All rights reserved. This program and the accompanying materials\n" + 
150
		" * All rights reserved. This program and the accompanying materials\n" + 
151
		" * are made available under the terms of the Eclipse Public License v1.0\n" + 
151
		" * are made available under the terms of the Eclipse Public License v1.0\n" + 
152
		" * which accompanies this distribution, and is available at\n" + 
152
		" * which accompanies this distribution, and is available at\n" + 
Lines 162-174 Link Here
162
		"import java.io.File;\n" + 
162
		"import java.io.File;\n" + 
163
		"import java.io.FileInputStream;\n" + 
163
		"import java.io.FileInputStream;\n" + 
164
		"import java.io.FileNotFoundException;\n" + 
164
		"import java.io.FileNotFoundException;\n" + 
165
		"import java.io.FileWriter;\n" + 
165
		"import java.io.IOException;\n" + 
166
		"import java.io.IOException;\n" + 
166
		"import java.io.InputStream;\n" + 
167
		"import java.io.InputStream;\n" + 
168
		"import java.io.OutputStream;\n" + 
169
		"import java.io.Writer;\n" + 
167
		"import java.lang.reflect.InvocationTargetException;\n" + 
170
		"import java.lang.reflect.InvocationTargetException;\n" + 
168
		"import java.lang.reflect.Method;\n" + 
171
		"import java.lang.reflect.Method;\n" + 
169
		"import java.net.ServerSocket;\n" + 
172
		"import java.net.ServerSocket;\n" + 
170
		"import java.net.Socket;\n" + 
173
		"import java.net.Socket;\n" + 
171
		"import java.util.StringTokenizer;\n" + 
174
		"import java.util.StringTokenizer;\n" + 
175
		"\n" + 
172
		"\n" + 
176
		"\n" + 
173
		"/******************************************************\n" + 
177
		"/******************************************************\n" + 
174
		" *\n" + 
178
		" *\n" + 
Lines 181-186 Link Here
181
		"	int portNumber;\n" + 
185
		"	int portNumber;\n" + 
182
		"	Socket socket;\n" + 
186
		"	Socket socket;\n" + 
183
		"\n" + 
187
		"\n" + 
188
		"	Writer logFile;\n" + 
184
		"/**\n" + 
189
		"/**\n" + 
185
		" * NOTE: Code copied from junit.util.TestCaseClassLoader.\n" + 
190
		" * NOTE: Code copied from junit.util.TestCaseClassLoader.\n" + 
186
		" *\n" + 
191
		" *\n" + 
Lines 230-236 Link Here
230
		"		while (st.hasMoreTokens()) {\n" + 
235
		"		while (st.hasMoreTokens()) {\n" + 
231
		"			this.pathItems[i++]= st.nextToken();\n" + 
236
		"			this.pathItems[i++]= st.nextToken();\n" + 
232
		"		}\n" + 
237
		"		}\n" + 
233
		"\n" + 
234
		"	}\n" + 
238
		"	}\n" + 
235
		"	public java.net.URL getResource(String name) {\n" + 
239
		"	public java.net.URL getResource(String name) {\n" + 
236
		"		return ClassLoader.getSystemResource(name);\n" + 
240
		"		return ClassLoader.getSystemResource(name);\n" + 
Lines 339-346 Link Here
339
		"		throw e.getTargetException();\n" + 
343
		"		throw e.getTargetException();\n" + 
340
		"	}\n" + 
344
		"	}\n" + 
341
		"}\n" + 
345
		"}\n" + 
346
		"\n" + 
347
		"VerifyTests(String testName) {\n" + 
348
		"	try {\n" + 
349
		"		logFile = new FileWriter(new File(\"/tmp/test\"+testName+\".log\"));\n" + 
350
		"	} catch (IOException e) {\n" + 
351
		"	}\n" + 
352
		"}\n" + 
342
		"public static void main(String[] args) throws IOException {\n" + 
353
		"public static void main(String[] args) throws IOException {\n" + 
343
		"	VerifyTests verify = new VerifyTests();\n" + 
354
		"	VerifyTests verify = new VerifyTests(args[1]);\n" + 
344
		"	verify.portNumber = Integer.parseInt(args[0]);\n" + 
355
		"	verify.portNumber = Integer.parseInt(args[0]);\n" + 
345
		"	verify.run();\n" + 
356
		"	verify.run();\n" + 
346
		"}\n" + 
357
		"}\n" + 
Lines 351-367 Link Here
351
		"	server.close();\n" + 
362
		"	server.close();\n" + 
352
		"\n" + 
363
		"\n" + 
353
		"	DataInputStream in = new DataInputStream(this.socket.getInputStream());\n" + 
364
		"	DataInputStream in = new DataInputStream(this.socket.getInputStream());\n" + 
354
		"	final DataOutputStream out = new DataOutputStream(this.socket.getOutputStream());\n" + 
365
		"	final OutputStream outputStream = this.socket.getOutputStream();\n" + 
366
		"	final DataOutputStream out = new DataOutputStream(outputStream);\n" + 
355
		"	while (true) {\n" + 
367
		"	while (true) {\n" + 
356
		"		final String className = in.readUTF();\n" + 
368
		"		final String className = in.readUTF();\n" + 
357
		"		Thread thread = new Thread() {\n" + 
369
		"		Thread thread = new Thread() {\n" + 
358
		"			public void run() {\n" + 
370
		"			public void run() {\n" + 
359
		"				try {\n" + 
371
		"				try {\n" + 
372
		"					logFile.write(className+\" \"+socket.isClosed()+\"\\n\");\n" + 
373
		"					logFile.flush();\n" + 
360
		"					loadAndRun(className);\n" + 
374
		"					loadAndRun(className);\n" + 
375
		"					VerifyTests.this.logFile.write(\"\\t \\t-> \"+socket.isClosed()+\"\\n\");\n" + 
376
		"					logFile.flush();\n" + 
361
		"					out.writeBoolean(true);\n" + 
377
		"					out.writeBoolean(true);\n" + 
378
		"					VerifyTests.this.logFile.write(\"\\t true\\t->\"+socket.isClosed()+\"\\n\");\n" + 
379
		"					logFile.flush();\n" + 
362
		"					System.err.println(VerifyTests.class.getName());\n" + 
380
		"					System.err.println(VerifyTests.class.getName());\n" + 
363
		"					System.out.println(VerifyTests.class.getName());\n" + 
381
		"					System.out.println(VerifyTests.class.getName());\n" + 
364
		"				} catch (Throwable e) {\n" + 
382
		"				} catch (Throwable e) {\n" + 
383
		"					try {\n" + 
384
		"						logFile.write(\"Exception: \"+e);\n" + 
385
		"						logFile.flush();\n" + 
386
		"					} catch (IOException e2) {\n" + 
387
		"						// nop\n" + 
388
		"					}\n" + 
365
		"					e.printStackTrace();\n" + 
389
		"					e.printStackTrace();\n" + 
366
		"					try {\n" + 
390
		"					try {\n" + 
367
		"						System.err.println(VerifyTests.class.getName());\n" + 
391
		"						System.err.println(VerifyTests.class.getName());\n" + 
Lines 373-378 Link Here
373
		"				}\n" + 
397
		"				}\n" + 
374
		"				try {\n" + 
398
		"				try {\n" + 
375
		"					out.flush();\n" + 
399
		"					out.flush();\n" + 
400
		"					logFile.flush();\n" + 
376
		"				} catch (IOException e) {\n" + 
401
		"				} catch (IOException e) {\n" + 
377
		"					e.printStackTrace();\n" + 
402
		"					e.printStackTrace();\n" + 
378
		"				}\n" + 
403
		"				}\n" + 
Lines 381-387 Link Here
381
		"		thread.start();\n" + 
406
		"		thread.start();\n" + 
382
		"	}\n" + 
407
		"	}\n" + 
383
		"}\n" + 
408
		"}\n" + 
384
		"}";
409
		"}\n";
385
}
410
}
386
private void launchAndRun(String className, String[] classpaths, String[] programArguments, String[] vmArguments) {
411
private void launchAndRun(String className, String[] classpaths, String[] programArguments, String[] vmArguments) {
387
	// we won't reuse the vm, shut the existing one if running
412
	// we won't reuse the vm, shut the existing one if running
Lines 450-456 Link Here
450
	} catch (InterruptedException e) {
475
	} catch (InterruptedException e) {
451
	}
476
	}
452
}
477
}
453
private void launchVerifyTestsIfNeeded(String[] classpaths, String[] vmArguments) {
478
private void launchVerifyTestsIfNeeded(String[] classpaths, String[] vmArguments, String testName) {
454
	// determine if we can reuse the vm
479
	// determine if we can reuse the vm
455
	if (this.vm != null && this.vm.isRunning() && this.classpathCache != null) {
480
	if (this.vm != null && this.vm.isRunning() && this.classpathCache != null) {
456
		if (classpaths.length == this.classpathCache.length) {
481
		if (classpaths.length == this.classpathCache.length) {
Lines 497-503 Link Here
497
	}
522
	}
498
	launcher.setProgramClass(VerifyTests.class.getName());
523
	launcher.setProgramClass(VerifyTests.class.getName());
499
	int portNumber = Util.getFreePort();
524
	int portNumber = Util.getFreePort();
500
	launcher.setProgramArguments(new String[] {Integer.toString(portNumber)});
525
	launcher.setProgramArguments(new String[] {Integer.toString(portNumber), testName});
501
	try {
526
	try {
502
		this.vm = launcher.launch();
527
		this.vm = launcher.launch();
503
		final InputStream input = this.vm.getInputStream();
528
		final InputStream input = this.vm.getInputStream();
Lines 608-629 Link Here
608
 * Verify that the class files created for the given test file can be loaded by
633
 * Verify that the class files created for the given test file can be loaded by
609
 * a virtual machine.
634
 * a virtual machine.
610
 */
635
 */
611
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths) {
636
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String testName) {
612
	return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, "", classpaths, null, null);
637
	return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, "", classpaths, null, null, testName);
613
}
638
}
614
/**
639
/**
615
 * Verify that the class files created for the given test file can be loaded by
640
 * Verify that the class files created for the given test file can be loaded by
616
 * a virtual machine.
641
 * a virtual machine.
617
 */
642
 */
618
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String[] programArguments, String[] vmArguments) {
643
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String[] programArguments, String[] vmArguments, String testName) {
619
	return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, "", classpaths, programArguments, vmArguments);
644
	return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, "", classpaths, programArguments, vmArguments, testName);
620
}
645
}
621
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedOutputString,
646
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedOutputString,
622
		String expectedErrorStringStart, String[] classpaths, String[] programArguments, String[] vmArguments) {
647
		String expectedErrorStringStart, String[] classpaths, String[] programArguments, String[] vmArguments, String testName) {
623
	this.outputBuffer = new StringBuffer();
648
	this.outputBuffer = new StringBuffer();
624
	this.errorBuffer = new StringBuffer();
649
	this.errorBuffer = new StringBuffer();
625
	if (this.reuseVM && programArguments == null) {
650
	if (this.reuseVM && programArguments == null) {
626
		launchVerifyTestsIfNeeded(classpaths, vmArguments);
651
		launchVerifyTestsIfNeeded(classpaths, vmArguments, testName);
627
		loadAndRun(className);
652
		loadAndRun(className);
628
	} else {
653
	} else {
629
		launchAndRun(className, classpaths, programArguments, vmArguments);
654
		launchAndRun(className, classpaths, programArguments, vmArguments);
Lines 637-647 Link Here
637
 * Verify that the class files created for the given test file can be loaded and run with an expected error contained
662
 * Verify that the class files created for the given test file can be loaded and run with an expected error contained
638
 * in the expectedSuccessOutputString string.
663
 * in the expectedSuccessOutputString string.
639
 */
664
 */
640
public boolean verifyClassFilesThrowingError(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String[] programArguments, String[] vmArguments) {
665
public boolean verifyClassFilesThrowingError(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String[] programArguments, String[] vmArguments, String testName) {
641
	this.outputBuffer = new StringBuffer();
666
	this.outputBuffer = new StringBuffer();
642
	this.errorBuffer = new StringBuffer();
667
	this.errorBuffer = new StringBuffer();
643
	if (this.reuseVM && programArguments == null) {
668
	if (this.reuseVM && programArguments == null) {
644
		launchVerifyTestsIfNeeded(classpaths, vmArguments);
669
		launchVerifyTestsIfNeeded(classpaths, vmArguments, testName);
645
		loadAndRun(className);
670
		loadAndRun(className);
646
	} else {
671
	} else {
647
		launchAndRun(className, classpaths, programArguments, vmArguments);
672
		launchAndRun(className, classpaths, programArguments, vmArguments);
(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/VerifyTests.java (-3 / +28 lines)
Lines 15-27 Link Here
15
import java.io.File;
15
import java.io.File;
16
import java.io.FileInputStream;
16
import java.io.FileInputStream;
17
import java.io.FileNotFoundException;
17
import java.io.FileNotFoundException;
18
import java.io.FileWriter;
18
import java.io.IOException;
19
import java.io.IOException;
19
import java.io.InputStream;
20
import java.io.InputStream;
21
import java.io.OutputStream;
22
import java.io.Writer;
20
import java.lang.reflect.InvocationTargetException;
23
import java.lang.reflect.InvocationTargetException;
21
import java.lang.reflect.Method;
24
import java.lang.reflect.Method;
22
import java.net.ServerSocket;
25
import java.net.ServerSocket;
23
import java.net.Socket;
26
import java.net.Socket;
24
import java.util.StringTokenizer;
27
import java.util.StringTokenizer;
28
25
29
26
/******************************************************
30
/******************************************************
27
 *
31
 *
Lines 34-39 Link Here
34
	int portNumber;
38
	int portNumber;
35
	Socket socket;
39
	Socket socket;
36
40
41
	Writer logFile;
37
/**
42
/**
38
 * NOTE: Code copied from junit.util.TestCaseClassLoader.
43
 * NOTE: Code copied from junit.util.TestCaseClassLoader.
39
 *
44
 *
Lines 83-89 Link Here
83
		while (st.hasMoreTokens()) {
88
		while (st.hasMoreTokens()) {
84
			this.pathItems[i++]= st.nextToken();
89
			this.pathItems[i++]= st.nextToken();
85
		}
90
		}
86
87
	}
91
	}
88
	public java.net.URL getResource(String name) {
92
	public java.net.URL getResource(String name) {
89
		return ClassLoader.getSystemResource(name);
93
		return ClassLoader.getSystemResource(name);
Lines 192-199 Link Here
192
		throw e.getTargetException();
196
		throw e.getTargetException();
193
	}
197
	}
194
}
198
}
199
200
VerifyTests(String testName) {
201
	try {
202
		logFile = new FileWriter(new File("/tmp/test"+testName+".log"));
203
	} catch (IOException e) {
204
	}
205
}
195
public static void main(String[] args) throws IOException {
206
public static void main(String[] args) throws IOException {
196
	VerifyTests verify = new VerifyTests();
207
	VerifyTests verify = new VerifyTests(args[1]);
197
	verify.portNumber = Integer.parseInt(args[0]);
208
	verify.portNumber = Integer.parseInt(args[0]);
198
	verify.run();
209
	verify.run();
199
}
210
}
Lines 204-220 Link Here
204
	server.close();
215
	server.close();
205
216
206
	DataInputStream in = new DataInputStream(this.socket.getInputStream());
217
	DataInputStream in = new DataInputStream(this.socket.getInputStream());
207
	final DataOutputStream out = new DataOutputStream(this.socket.getOutputStream());
218
	final OutputStream outputStream = this.socket.getOutputStream();
219
	final DataOutputStream out = new DataOutputStream(outputStream);
208
	while (true) {
220
	while (true) {
209
		final String className = in.readUTF();
221
		final String className = in.readUTF();
210
		Thread thread = new Thread() {
222
		Thread thread = new Thread() {
211
			public void run() {
223
			public void run() {
212
				try {
224
				try {
225
					logFile.write(className+" "+socket.isClosed()+"\n");
226
					logFile.flush();
213
					loadAndRun(className);
227
					loadAndRun(className);
228
					VerifyTests.this.logFile.write("\t \t-> "+socket.isClosed()+"\n");
229
					logFile.flush();
214
					out.writeBoolean(true);
230
					out.writeBoolean(true);
231
					VerifyTests.this.logFile.write("\t true\t->"+socket.isClosed()+"\n");
232
					logFile.flush();
215
					System.err.println(VerifyTests.class.getName());
233
					System.err.println(VerifyTests.class.getName());
216
					System.out.println(VerifyTests.class.getName());
234
					System.out.println(VerifyTests.class.getName());
217
				} catch (Throwable e) {
235
				} catch (Throwable e) {
236
					try {
237
						logFile.write("Exception: "+e);
238
						logFile.flush();
239
					} catch (IOException e2) {
240
						// nop
241
					}
218
					e.printStackTrace();
242
					e.printStackTrace();
219
					try {
243
					try {
220
						System.err.println(VerifyTests.class.getName());
244
						System.err.println(VerifyTests.class.getName());
Lines 226-231 Link Here
226
				}
250
				}
227
				try {
251
				try {
228
					out.flush();
252
					out.flush();
253
					logFile.flush();
229
				} catch (IOException e) {
254
				} catch (IOException e) {
230
					e.printStackTrace();
255
					e.printStackTrace();
231
				}
256
				}

Return to bug 414653