From b600d744553080a8245988c5c07ebdf9701d8e53 Mon Sep 17 00:00:00 2001 From: Michal Duda <44705056+michal-duda-sonarsource@users.noreply.github.com> Date: Tue, 8 Jan 2019 12:14:26 +0100 Subject: [PATCH] SQSCANNER-54 don't print warnings to stderr (#57) Redirect warnings to stdout instead of stderr. --- src/main/java/org/sonarsource/scanner/cli/Logs.java | 2 +- .../java/org/sonarsource/scanner/cli/LogsTest.java | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/sonarsource/scanner/cli/Logs.java b/src/main/java/org/sonarsource/scanner/cli/Logs.java index 87794d6..a5cbcc8 100644 --- a/src/main/java/org/sonarsource/scanner/cli/Logs.java +++ b/src/main/java/org/sonarsource/scanner/cli/Logs.java @@ -56,7 +56,7 @@ public class Logs { } public void warn(String message) { - print(stdErr, "WARN: " + message); + print(stdOut, "WARN: " + message); } public void error(String message) { diff --git a/src/test/java/org/sonarsource/scanner/cli/LogsTest.java b/src/test/java/org/sonarsource/scanner/cli/LogsTest.java index 385b329..5e1e0e3 100644 --- a/src/test/java/org/sonarsource/scanner/cli/LogsTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/LogsTest.java @@ -19,16 +19,15 @@ */ package org.sonarsource.scanner.cli; +import java.io.PrintStream; import org.junit.Before; import org.junit.Test; import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.sonarsource.scanner.cli.Logs; -import java.io.PrintStream; -import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; public class LogsTest { @Mock @@ -51,19 +50,19 @@ public class LogsTest { verify(stdOut).println("INFO: info"); verifyNoMoreInteractions(stdOut, stdErr); } - + @Test public void testWarn() { logs.warn("warn"); - verify(stdErr).println("WARN: warn"); + verify(stdOut).println("WARN: warn"); verifyNoMoreInteractions(stdOut, stdErr); } - + @Test public void testWarnWithTimestamp() { logs.setDebugEnabled(true); logs.warn("warn"); - verify(stdErr).println(Matchers.matches("\\d\\d:\\d\\d:\\d\\d.\\d\\d\\d WARN: warn")); + verify(stdOut).println(Matchers.matches("\\d\\d:\\d\\d:\\d\\d.\\d\\d\\d WARN: warn")); verifyNoMoreInteractions(stdOut, stdErr); } -- 2.39.5