Skip to content
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

Miscellaneous logging improvements #6326

Merged
merged 14 commits into from Apr 20, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/Build.UnitTests/BackEnd/TargetBuilder_Tests.cs
Expand Up @@ -198,6 +198,43 @@ public void TestDependencyBuildWithError()
Assert.Equal(TargetResultCode.Success, resultsCache.GetResultForRequest(entry.Request)["Baz"].ResultCode);
}

[Fact]
public void TestLoggingForSkippedTargetInputsAndOutputs()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really not already have a test for this? Seems so fundamental...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, surprisingly I didn't find anything.

{
string projectContents = @"
<Project>
<Target Name=""Build"" Inputs=""a.txt;b.txt"" Outputs=""c.txt"">
<Message Text=""test"" Importance=""High"" />
</Target>
</Project>";

using (var env = TestEnvironment.Create())
{
var files = env.CreateTestProjectWithFiles(projectContents, new[] { "a.txt", "b.txt", "c.txt" });
var fileA = new FileInfo(files.CreatedFiles[0]);
var fileB = new FileInfo(files.CreatedFiles[1]);
var fileC = new FileInfo(files.CreatedFiles[2]);

var now = DateTime.UtcNow;
fileA.LastWriteTimeUtc = now - TimeSpan.FromSeconds(10);
fileB.LastWriteTimeUtc = now - TimeSpan.FromSeconds(10);
fileC.LastWriteTimeUtc = now;

var logger = files.BuildProjectExpectSuccess();
var logText = logger.FullLog.Replace("\r\n", "\n");

var expected = @"
Skipping target ""Build"" because all output files are up-to-date with respect to the input files.
Input files:
a.txt
b.txt
Output files: c.txt
Done building target ""Build"" in project ""build.proj"".".Replace("\r\n", "\n");

logText.ShouldContainWithoutWhitespace(expected);
}
}

/// <summary>
/// Ensure that skipped targets only infer outputs once
/// </summary>
Expand Down