Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 256905 - [tests] Abuse of Sytem.out.println
Summary: [tests] Abuse of Sytem.out.println
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M5   Edit
Assignee: P2 Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-28 10:43 EST by Simon Kaegi CLA
Modified: 2008-12-11 17:02 EST (History)
2 users (show)

See Also:


Attachments
Disables verbose logging for Mirror Application Tests (5.42 KB, patch)
2008-12-09 09:03 EST, Andrew Cattle CLA
simon_kaegi: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Kaegi CLA 2008-11-28 10:43:31 EST
When I run the automated tests I get a barage of useless junk printed out to the console and as a result it's very easy to miss important problems like exceptions getting thrown and genuine errors that are indicitive of problems butdon't cause a test to fail. We should clean this up.

The two worst offenders are:
1) The jar verifier tests that print out countless messages like:
Verifying org.eclipse.equinox.p2.artifact.repository_1.0.100.v20081024.jar:  STDOUT: jar verified.
STDOUT: 
STDOUT: Warning: 
STDOUT: This jar contains entries whose signer certificate will expire within six months. 
STDOUT: 
STDOUT: Re-run with the -verbose and -certs options for more details.

2) The mirroring tests with emssage like:
Mirroring: helloworldfeature/org.eclipse.update.feature/1.0.0 (Descriptor: canonical: helloworldfeature/org.eclipse.update.feature/1.0.0)
Mirroring: yetanotherfeature/org.eclipse.update.feature/1.0.0 (Descriptor: canonical: yetanotherfeature/org.eclipse.update.feature/1.0.0)
Artifact: canonical: helloworld/osgi.bundle/1.0.0 already exists in repository: file:/C:/workspaces/junit-workspace/1227886938015-0.8651159694093722/BasicMirrorApplicationTest/.
Artifact: canonical: helloworldfeature/org.eclipse.update.feature/1.0.0 already exists in repository: file:/C:/workspaces/junit-workspace/1227886938015-0.8651159694093722/BasicMirrorApplicationTest/.
Comment 1 DJ Houghton CLA 2008-11-28 11:29:26 EST
I'm not sure if there is a way to suppress the messages from the mirror tests since they just call the application which is simulating calling the app from the command-line. (and prints messages back to the user)

Comment 2 Andrew Niefer CLA 2008-11-28 11:41:29 EST
Tests can redirect the output streams before running other code, see org.eclipse.pde.build.tests/ProductTests.testBug238001 as an example
Comment 3 DJ Houghton CLA 2008-11-28 11:51:25 EST
Ah cool... didn't know that! 

Here is the block of code for those who don't have pde.build.tests checked out in their workspace:

PrintStream oldErr = System.err;
PrintStream newErr = new PrintStream(new FileOutputStream(buildFolder.getLocation().toOSString() + "/out.out"));
System.setErr(newErr);
IconExe.main(new String[] {win32File.getLocation().toOSString(), icoFile.getLocation().toOSString()});
IconExe.main(new String[] {win64File.getLocation().toOSString(), icoFile.getLocation().toOSString()});
System.setErr(oldErr);
newErr.close();

Comment 4 Andrew Niefer CLA 2008-12-05 17:05:20 EST
I have fixed JarProcessorTests to not spew to sysout.
Comment 5 DJ Houghton CLA 2008-12-08 16:00:59 EST
For the mirror app tests, perhaps we could put code in the #run method. Maybe something like:

PrintStream oldErr = System.err;
PrintStream oldOut = System.out;
PrintStream newErr = new PrintStream(...);
PrintStream newOut = new PrintStream(...);
try {
   app.start(context);
} finally {
   System.setOut(oldOut);
   System.setErr(oldErr);
   newErr.close();
   newOut.close();
}

Comment 6 Andrew Cattle CLA 2008-12-09 09:03:48 EST
Created attachment 119904 [details]
Disables verbose logging for Mirror Application Tests

I just removed the -verbose argument from all tests except testCompareUsingMD5Comparator and testBaselineCompareUsingMD5Comparator. These are the only tests that need verbose logging, so I just reassigned stdout as per DJ's suggestion (I was reassigning stderr anyway)

Only affects the Artifact Repository Mirror Application.
Comment 7 Simon Kaegi CLA 2008-12-11 17:02:12 EST
Thanks Andrew. I've committed to HEAD with a tiny tweak on the file names for sys out and err.