Community
Participate
Working Groups
The standard err and out streams are captured in several places in the harness to reduce the verbosity of output and allow validation of testcase behavior. Unfortunately this is implemented by switching redirection on and off at the beginning and end of each test which has a number of drawbacks: 1. Certain AspectJ classes store a static reference to err/out e.g. IMessageHandler.SYSTER_ERR. They may store a reference to a redirected version rendering them useless in later tests 2. All uses of System.err/out for debugging are redirected making this debug mechanism largely useless 3. Using System.err/out can cause tests to fail by changing expected output 4. Redirected output does not go the screen immediately which means it does not appear while stepping through the code, even in verbose mode, making it largely useless 5. Redirected output is often not show automatically when a test fails The answer is to redirect the streams once when the harness starts but leave them permanently connected to their original destinations. To reduces verbosity the destination streams can be switched on and off during test execution. To capture output a second stream is connected and disconnected to/form the redirected. Because the verbose mode decides what goes to the screen not the redirection text will appear while stepping through the code. Finally the original err/out are stored in a public final static to be used when output needs to go to the screen.
Created attachment 30674 [details] Enhancement to AjcTestCase Use new DelegatingOutputStream in AjcTestCase to capture and redirect err and out. Behaviour remains the same however verbosity can be controlled with 2 System properties: - "org.aspectj.tools.ajc.AjcTestCase.verbose.err": err - "org.aspectj.tools.ajc.AjcTestCase.verbose.out": out - "org.aspectj.tools.ajc.AjcTestCase.verbose": both e.g. using "-Dorg.aspectj.tools.ajc.AjcTestCase.verbose.out=true" will ensure all data sent via System.out calls will go the console/screen immediately as well as being captured. A public final static "AjcTestCase.out" is always available to send data to the console, bypassing any capture. The verbosity of Ajc can also be controlled using "-Dorg.aspectj.tools.ajc.Ajc.verbose=false".
Hmmmm... I was expecting that once this was applied the default behaviour is that all I'd see was 'TEST: <testname>' and then no output and I'd have to turn on output if I wished to see it, but I still get the 'command was:' and all the info messages from the compiler. is that what I should expect Matthew?
The intention was to maintain the status quo but make it more useable. Ajc and AjcTestCase have separate redirection logic. This patch changes the implementation of only the latter. If all is OK I will create a follow-up patch that changes Ajc too.
patches committed. And I've turned off the verbose output again (I think it was me that accidentally committed it turned 'on' a little while ago). The main feature I want it for is point (4) from the original post in this bug report - so I can see the output/error as I go along whilst debugging. I'd like to note that some of these changes are necessary because of the new requirement of properly testing LTW (catching output early enough) - I wouldn't necessarily agree that much of what we've been using up to this point is 'largely useless'.
fixes available.
reopening as there is future work to be done...