bodewig 02/04/09 07:04:27
Modified: src/main/org/apache/tools/ant/taskdefs/optional/junit
JUnitTestRunner.java
Log:
capture System.out and System.err and pass it to the formatters in
<junit> with fork=yes as well.
PR: 5377
Revision Changes Path
1.20 +23 -1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
Index: JUnitTestRunner.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- JUnitTestRunner.java 27 Jan 2002 10:47:55 -0000 1.19
+++ JUnitTestRunner.java 9 Apr 2002 14:04:27 -0000 1.20
@@ -1,7 +1,7 @@
/*
* 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.
*
* Redistribution and use in source and binary forms, with or without
@@ -180,6 +180,9 @@
/** Error output during the test */
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
* classpath.
@@ -261,9 +264,27 @@
ByteArrayOutputStream outStrm = new ByteArrayOutputStream();
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 {
suite.run(res);
} finally {
+ if (savedOut != null) {
+ System.setOut(savedOut);
+ }
+ if (savedErr != null) {
+ System.setErr(savedOut);
+ }
+
systemError.close();
systemError = null;
systemOut.close();
@@ -442,6 +463,7 @@
t.setProperties(props);
JUnitTestRunner runner = new JUnitTestRunner(t, haltError,
stackfilter, haltFail);
+ runner.forked = true;
transferFormatters(runner);
runner.run();
System.exit(runner.getRetCode());
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>