[ 
https://issues.apache.org/jira/browse/SUREFIRE-1369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15995148#comment-15995148
 ] 

Gili commented on SUREFIRE-1369:
--------------------------------

[~tibor17] No, I don't think `System.setOut(...)` is relevant. My code should 
only be affected by stdout being redirected on an operating-system level. As 
mentioned above, I am configuring Surefire **not** to fork for each test. If it 
is ignoring this configuration for some reason then we'd have a problem. 
Forking processes implies redirection on an operating-system level because 
you're redirecting stdout of each child process to the parent in order to 
centralize the output of all test results in the same process.

If you are certain that Surefire is not doing this sort of redirection (when 
using the configuration posted above) then it sounds to me like this is a 
problem in Maven core.

> Is there any segmentation fault or an exception?

Not exactly. The method call fails which means that colors are never enabled. 
If I then output ANSI colors to the console, the raw control characters are 
visible instead of being converted to colors.

> One more question, why you are interested in JNDI and such things 
> GetStdHandle?

My API outputs colored diffs (see 
https://bitbucket.org/cowwoc/requirements/wiki/Home#markdown-header-string-diff).
 In order to output colors under Windows 10, you are forced to use JNI. There 
is no other way.

> No way to output ANSI colors when running under Surefire
> --------------------------------------------------------
>
>                 Key: SUREFIRE-1369
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1369
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Maven Surefire Plugin
>    Affects Versions: 2.20
>         Environment: Windows 10 64-bit, 10.0.14393
>            Reporter: Gili
>            Assignee: Tibor Digana
>
> I invoke the following native code from inside a unit test:
> {{GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &sbi)}}
> It fails with {{GetLastError() == ERROR_INVALID_HANDLE}} indicating that 
> stdout has been redirected.
> I am blocked by the fact that it isn't possible to use ANSI colors under 
> Windows when stdout has been redirected. I tried configuring Surefire with:
> {code}
>       <forkCount>0</forkCount>
>       <redirectTestOutputToFile>false</redirectTestOutputToFile>
>       <useFile>false</useFile>
>       <printSummary>false</printSummary>
> {code}
> but stdout is still getting redirected. Is it possible to configure Surefire 
> to use the default stdout (connected to a terminal) without redirection?
> Expected behavior: Surefire shouldn't fork the JVM or redirect stdout when 
> {{forkCount}} is zero and {{useFile}} is false.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to