Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BuiltInTools/DotNetDeltaApplier/StartupHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static void Log(string message)
if (!string.IsNullOrEmpty(prefix))
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine($"{prefix} {message}");
Console.Error.WriteLine($"{prefix} {message}");
Console.ResetColor();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/BuiltInTools/dotnet-watch/UI/ConsoleReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ public void Report(EventId id, Emoji emoji, MessageSeverity severity, string mes
{
case MessageSeverity.Error:
// Use stdout for error messages to preserve ordering with respect to other output.
WriteLine(console.Out, message, ConsoleColor.Red, emoji);
WriteLine(console.Error, message, ConsoleColor.Red, emoji);
break;

case MessageSeverity.Warning:
WriteLine(console.Out, message, ConsoleColor.Yellow, emoji);
WriteLine(console.Error, message, ConsoleColor.Yellow, emoji);
break;

case MessageSeverity.Output:
if (!IsQuiet)
{
WriteLine(console.Out, message, color: null, emoji);
WriteLine(console.Error, message, color: null, emoji);
}
break;

case MessageSeverity.Verbose:
if (IsVerbose)
{
WriteLine(console.Out, message, ConsoleColor.DarkGray, emoji);
WriteLine(console.Error, message, ConsoleColor.DarkGray, emoji);
}
break;
}
Expand Down
8 changes: 4 additions & 4 deletions test/dotnet-watch.Tests/ConsoleReporterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ public void WritesToStandardStreams(bool suppressEmojis)
var reporter = new ConsoleReporter(testConsole, verbose: true, quiet: false, suppressEmojis: suppressEmojis);

reporter.Report(id: default, Emoji.Watch, MessageSeverity.Verbose, "verbose {0}");
Assert.Equal($"dotnet watch {(suppressEmojis ? ":" : "⌚")} verbose {{0}}" + EOL, testConsole.GetOutput());
Assert.Equal($"dotnet watch {(suppressEmojis ? ":" : "⌚")} verbose {{0}}" + EOL, testConsole.GetError());
testConsole.Clear();

reporter.Report(id: default, Emoji.Watch, MessageSeverity.Output, "out");
Assert.Equal($"dotnet watch {(suppressEmojis ? ":" : "⌚")} out" + EOL, testConsole.GetOutput());
Assert.Equal($"dotnet watch {(suppressEmojis ? ":" : "⌚")} out" + EOL, testConsole.GetError());
testConsole.Clear();

reporter.Report(id: default, Emoji.Warning, MessageSeverity.Warning, "warn");
Assert.Equal($"dotnet watch {(suppressEmojis ? ":" : "⚠")} warn" + EOL, testConsole.GetOutput());
Assert.Equal($"dotnet watch {(suppressEmojis ? ":" : "⚠")} warn" + EOL, testConsole.GetError());
testConsole.Clear();

reporter.Report(id: default, Emoji.Error, MessageSeverity.Error, "error");
Assert.Equal($"dotnet watch {(suppressEmojis ? ":" : "❌")} error" + EOL, testConsole.GetOutput());
Assert.Equal($"dotnet watch {(suppressEmojis ? ":" : "❌")} error" + EOL, testConsole.GetError());
testConsole.Clear();
}

Expand Down
28 changes: 18 additions & 10 deletions test/dotnet.Tests/CommandTests/Run/RunFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ public void FilePath_AsProjectArgument()
/// </summary>
[Theory]
// error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
[InlineData("build", "MSB1003")]
[InlineData("build", "MSB1003", false)]
// dotnet watch: Could not find a MSBuild project file in '...'. Specify which project to use with the --project option.
[InlineData("watch", "--project")]
public void Precedence_BuiltInCommand(string cmd, string error)
[InlineData("watch", "--project", true)]
public void Precedence_BuiltInCommand(string cmd, string error, bool errorInStdErr)
{
var testInstance = _testAssetsManager.CreateTestDirectory();
File.WriteAllText(Path.Join(testInstance.Path, cmd), """
Expand All @@ -348,18 +348,26 @@ public void Precedence_BuiltInCommand(string cmd, string error)
""");

// dotnet build -> built-in command
new DotnetCommand(Log, cmd)
var failure = new DotnetCommand(Log, cmd)
.WithWorkingDirectory(testInstance.Path)
.Execute()
.Should().Fail()
.And.HaveStdOutContaining(error);
.Should().Fail();

if (errorInStdErr)
{
failure.And.HaveStdErrContaining(error);
}
else
{
failure.And.HaveStdOutContaining(error);
}

// dotnet ./build -> file-based app
new DotnetCommand(Log, $"./{cmd}")
.WithWorkingDirectory(testInstance.Path)
.Execute()
.Should().Pass()
.And.HaveStdOut("hello 1");
.WithWorkingDirectory(testInstance.Path)
.Execute()
.Should().Pass()
.And.HaveStdOut("hello 1");

// dotnet run build -> file-based app
new DotnetCommand(Log, "run", cmd)
Expand Down
Loading