-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Consolidate default verbosity of msbuild-based commands #50243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1116,6 +1116,68 @@ public void TerminalLogger(bool on) | |
} | ||
} | ||
|
||
[Fact] | ||
public void Verbosity_Run() | ||
{ | ||
var testInstance = _testAssetsManager.CreateTestDirectory(); | ||
var programFile = Path.Join(testInstance.Path, "Program.cs"); | ||
File.WriteAllText(programFile, s_program); | ||
|
||
new DotnetCommand(Log, "run", "Program.cs", "--no-cache") | ||
.WithWorkingDirectory(testInstance.Path) | ||
.Execute() | ||
.Should().Pass() | ||
// no additional build messages | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels like if no build message is expected then it would be good to verify that, for example, the stdout does not contain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.And.HaveStdOut("Hello from Program") | ||
.And.NotHaveStdErr(); | ||
} | ||
|
||
[Fact] // https://github.com/dotnet/sdk/issues/50227 | ||
public void Verbosity_Build() | ||
{ | ||
var testInstance = _testAssetsManager.CreateTestDirectory(); | ||
var programFile = Path.Join(testInstance.Path, "Program.cs"); | ||
File.WriteAllText(programFile, s_program); | ||
|
||
new DotnetCommand(Log, "build", "Program.cs") | ||
.WithWorkingDirectory(testInstance.Path) | ||
.Execute() | ||
.Should().Pass() | ||
// should print path to the built DLL | ||
.And.HaveStdOutContaining("Program.dll"); | ||
} | ||
|
||
[Fact] | ||
public void Verbosity_CompilationDiagnostics() | ||
{ | ||
var testInstance = _testAssetsManager.CreateTestDirectory(); | ||
|
||
File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """ | ||
string x = null; | ||
Console.WriteLine("ran" + x); | ||
"""); | ||
|
||
new DotnetCommand(Log, "run", "Program.cs") | ||
.WithWorkingDirectory(testInstance.Path) | ||
.Execute() | ||
.Should().Pass() | ||
// warning CS8600: Converting null literal or possible null value to non-nullable type. | ||
.And.HaveStdOutContaining("warning CS8600") | ||
.And.HaveStdOutContaining("ran"); | ||
|
||
File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """ | ||
Console.Write | ||
"""); | ||
|
||
new DotnetCommand(Log, "run", "Program.cs") | ||
.WithWorkingDirectory(testInstance.Path) | ||
.Execute() | ||
.Should().Fail() | ||
// error CS1002: ; expected | ||
.And.HaveStdOutContaining("error CS1002") | ||
.And.HaveStdErrContaining(CliCommandStrings.RunCommandException); | ||
} | ||
|
||
/// <summary> | ||
/// Default projects include embedded resources by default. | ||
/// </summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It might be good to put this const with the other consts above. In particular seeing it used in an initializer just before its definition causes me to do a double take, until I realize it is a const it feels like something may be wrong.