Skip to content

Commit 0ad6dd8

Browse files
authored
Suppress OSC taskbar reset on plain/piped stdout (#37646)
2 parents e745573 + 966025d commit 0ad6dd8

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

platforms/core-runtime/logging/src/integTest/groovy/org/gradle/internal/logging/console/TaskbarProgressResetFunctionalTest.groovy

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,40 @@ class TaskbarProgressResetFunctionalTest extends AbstractIntegrationSpec {
9898
then:
9999
result.output.contains(OSC_RESET)
100100
}
101+
102+
@Issue("https://github.com/gradle/gradle/issues/37611")
103+
@SuppressWarnings("IntegrationTestFixtures")
104+
@Requires(value = IntegTestPreconditions.NotEmbeddedExecutor,
105+
reason = "OSC taskbar progress sequences are only emitted by the forked client JVM")
106+
def "does not emit OSC 9;4 sequences when --console=plain"() {
107+
given:
108+
executer.withConsole(ConsoleOutput.Plain)
109+
buildFile << """
110+
task ok { }
111+
"""
112+
113+
when:
114+
result = succeeds("ok")
115+
116+
then:
117+
!result.output.contains(OSC_PROGRESS_PREFIX)
118+
}
119+
120+
@Issue("https://github.com/gradle/gradle/issues/37611")
121+
@SuppressWarnings("IntegrationTestFixtures")
122+
@Requires(value = IntegTestPreconditions.NotEmbeddedExecutor,
123+
reason = "OSC taskbar progress sequences are only emitted by the forked client JVM")
124+
def "does not emit OSC 9;4 sequences when console is Auto and stdout is not a terminal"() {
125+
given:
126+
executer.withConsole(ConsoleOutput.Auto)
127+
buildFile << """
128+
task ok { }
129+
"""
130+
131+
when:
132+
result = succeeds("ok")
133+
134+
then:
135+
!result.output.contains(OSC_PROGRESS_PREFIX)
136+
}
101137
}

platforms/core-runtime/logging/src/main/java/org/gradle/internal/logging/sink/ConsoleConfigureAction.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ public static void execute(OutputEventRenderer renderer, ConsoleOutput consoleOu
5959
configureColoredConsole(renderer, consoleMetadata, stdout, stderr);
6060
}
6161

62-
registerTaskbarReset(consoleMetadata, stdout);
62+
if (shouldEmitTaskbarProgress(consoleOutput, consoleMetadata)) {
63+
registerTaskbarReset(consoleMetadata, stdout);
64+
}
65+
}
66+
67+
private static boolean shouldEmitTaskbarProgress(ConsoleOutput consoleOutput, ConsoleMetaData consoleMetadata) {
68+
if (consoleOutput == ConsoleOutput.Plain) {
69+
return false;
70+
}
71+
return consoleOutput != ConsoleOutput.Auto || consoleMetadata.isStdOutATerminal();
6372
}
6473

6574
private static void registerTaskbarReset(ConsoleMetaData consoleMetadata, OutputStream stdout) {

0 commit comments

Comments
 (0)