Skip to content

Commit

Permalink
Fix NO_COLOR support in console launcher
Browse files Browse the repository at this point in the history
Closes #3328
  • Loading branch information
sormuras authored and marcphilipp committed Sep 16, 2024
1 parent 4e76c4f commit 37e6059
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ on GitHub.
This could lead to deadlocks in certain scenarios.
* Fixed potential locking issue with `ExclusiveResource` in the
`HierarchicalTestExecutorService`, which could lead to deadlocks in certain scenarios.
* Fix support for disabling ANSI colors on the console when the `NO_COLOR` environment
variable is available.

[[release-notes-5.11.1-junit-platform-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class AnsiColorOptionMixin {
@Spec(MIXEE)
CommandSpec commandSpec;

private boolean disableAnsiColors;
// https://no-color.org
// ANSI is disabled when environment variable NO_COLOR is defined (regardless of its value).
private boolean disableAnsiColors = System.getenv("NO_COLOR") != null;

public boolean isDisableAnsiColors() {
return disableAnsiColors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,13 @@ JUnit Jupiter > JupiterIntegration > disabled()

private static Result discover(String... args) {
var result = Request.builder() //
.putEnvironment("NO_COLOR", "1") // --disable-ansi-colors
.setTool(new Java()) //
.setProject(Projects.STANDALONE) //
.addArguments("-jar", MavenRepo.jar("junit-platform-console-standalone")) //
.addArguments("discover") //
.addArguments("--scan-class-path") //
.addArguments("--disable-banner") //
.addArguments("--disable-ansi-colors") //
.addArguments("--include-classname", "standalone.*") //
.addArguments("--classpath", "bin") //
.addArguments((Object[]) args) //
Expand All @@ -405,6 +405,7 @@ private static Result discover(String... args) {
@Order(3)
void execute() throws IOException {
var result = Request.builder() //
.putEnvironment("NO_COLOR", "1") // --disable-ansi-colors
.setTool(new Java()) //
.setProject(Projects.STANDALONE) //
.addArguments("--show-version") //
Expand Down

0 comments on commit 37e6059

Please sign in to comment.