|
@@ -1,7 +1,7 @@ |
|
|
/* |
|
|
/* |
|
|
* The Apache Software License, Version 1.1 |
|
|
* The Apache Software License, Version 1.1 |
|
|
* |
|
|
* |
|
|
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights |
|
|
|
|
|
|
|
|
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights |
|
|
* reserved. |
|
|
* reserved. |
|
|
* |
|
|
* |
|
|
* Redistribution and use in source and binary forms, with or without |
|
|
* Redistribution and use in source and binary forms, with or without |
|
@@ -180,6 +180,9 @@ public class JUnitTestRunner implements TestListener { |
|
|
/** Error output during the test */ |
|
|
/** Error output during the test */ |
|
|
private PrintStream systemOut; |
|
|
private PrintStream systemOut; |
|
|
|
|
|
|
|
|
|
|
|
/** is this runner running in forked mode? */ |
|
|
|
|
|
private boolean forked = false; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor for fork=true or when the user hasn't specified a |
|
|
* Constructor for fork=true or when the user hasn't specified a |
|
|
* classpath. |
|
|
* classpath. |
|
@@ -261,9 +264,27 @@ public class JUnitTestRunner implements TestListener { |
|
|
ByteArrayOutputStream outStrm = new ByteArrayOutputStream(); |
|
|
ByteArrayOutputStream outStrm = new ByteArrayOutputStream(); |
|
|
systemOut = new PrintStream(outStrm); |
|
|
systemOut = new PrintStream(outStrm); |
|
|
|
|
|
|
|
|
|
|
|
PrintStream savedOut = null; |
|
|
|
|
|
PrintStream savedErr = null; |
|
|
|
|
|
|
|
|
|
|
|
if (forked) { |
|
|
|
|
|
savedOut = System.out; |
|
|
|
|
|
System.setOut(systemOut); |
|
|
|
|
|
savedErr = System.err; |
|
|
|
|
|
System.setErr(systemError); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
suite.run(res); |
|
|
suite.run(res); |
|
|
} finally { |
|
|
} finally { |
|
|
|
|
|
if (savedOut != null) { |
|
|
|
|
|
System.setOut(savedOut); |
|
|
|
|
|
} |
|
|
|
|
|
if (savedErr != null) { |
|
|
|
|
|
System.setErr(savedOut); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
systemError.close(); |
|
|
systemError.close(); |
|
|
systemError = null; |
|
|
systemError = null; |
|
|
systemOut.close(); |
|
|
systemOut.close(); |
|
@@ -442,6 +463,7 @@ public class JUnitTestRunner implements TestListener { |
|
|
t.setProperties(props); |
|
|
t.setProperties(props); |
|
|
|
|
|
|
|
|
JUnitTestRunner runner = new JUnitTestRunner(t, haltError, stackfilter, haltFail); |
|
|
JUnitTestRunner runner = new JUnitTestRunner(t, haltError, stackfilter, haltFail); |
|
|
|
|
|
runner.forked = true; |
|
|
transferFormatters(runner); |
|
|
transferFormatters(runner); |
|
|
runner.run(); |
|
|
runner.run(); |
|
|
System.exit(runner.getRetCode()); |
|
|
System.exit(runner.getRetCode()); |
|
|