Skip to content

Capture binlogs from SDK test scenarios - #56744

Open
mthalman wants to merge 7 commits into
dotnet:mainfrom
mthalman:mthalman-sdk-scenario-binlogs
Open

mthalman wants to merge 7 commits into
dotnet:mainfrom
mthalman:mthalman-sdk-scenario-binlogs

Conversation

@mthalman

Copy link
Copy Markdown
Member

Problem

The test runner's build.binlog captures the test project build, not necessarily builds performed by tests. When those scenario builds fail, their logs may not be available for diagnosis unless tests are changed to request binlogs.

Description

Add opt-in --test-binlogs support to capture build logs from MSBuildCommand and DotnetBuildCommand. Retain logs in a per-run test-binlogs directory, preserve explicitly configured logger destinations, and include the directory and binlog count in runner output. Capture is disabled unless requested.

Fixes #56658

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7c8b91f0-8d92-4828-a52c-1fc9e63fe773
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7c8b91f0-8d92-4828-a52c-1fc9e63fe773
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7c8b91f0-8d92-4828-a52c-1fc9e63fe773
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7c8b91f0-8d92-4828-a52c-1fc9e63fe773
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7c8b91f0-8d92-4828-a52c-1fc9e63fe773
Copilot AI balanced review requested due to automatic review settings October 21, 2026 17:21
@mthalman
mthalman requested a review from lbussell as a code owner October 21, 2026 17:21
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Windows path handling can prevent builds or miss logs, Helix retention is bypassed, and scenario-level regression coverage is missing.

4 open issues
What changed in this PR

Adds opt-in scenario-build binlog capture to the SDK test harness, separating logs produced by tests from the runner’s build log.

Changes:

  • Adds --test-binlogs, per-run retention, and artifact counts.
  • Instruments supported build wrappers with command-level opt-out.
  • Updates runner tests and contributor guidance.
File Description
test/​Microsoft.NET.TestFramework/​Utilities/​TestPathUtility.cs Adds cross-platform path helpers.
test/​Microsoft.NET.TestFramework/​Utilities/​FileUtility.cs Adds file hashing for change detection.
test/​Microsoft.NET.TestFramework/​Commands/​TestCommand.cs Integrates capture into command execution.
test/​Microsoft.NET.TestFramework/​Commands/​TestBinlogCapture.cs Implements logger discovery and artifact retention.
test/​Microsoft.NET.TestFramework/​Commands/​MSBuildCommand.cs Enables capture support.
test/​Microsoft.NET.TestFramework/​Commands/​DotnetBuildCommand.cs Enables capture support.
test/​Microsoft.NET.Infrastructure.Tests/​RunTestsScriptTests.cs Tests runner options and reporting.
test/​AGENTS.md Documents capture configuration and opt-out.
scripts/​RunTests.cs Adds capture option and artifact summaries.
.github/​skills/​run-tests/​SKILL.md Documents runner usage.

Review effort: Balanced

Comment on lines +259 to +260
string candidate = argument.Trim('"');
string candidatePath = TestPathUtility.ResolveFullPath(candidate, workingDirectory);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 301eb2d

{
testBinlogCapture.Complete(result.ExitCode);
}
else if (Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is string uploadRoot)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Given that this skill is really meant for 1-off investigations, there won't be an associated Helix run to capture these logs. So this change isn't needed.

return Path.GetFullPath(Path.Combine(Path.GetPathRoot(basePath)!, path.TrimStart('\\', '/')));
}

return Path.GetFullPath(Path.IsPathRooted(path) ? path : Path.Combine(basePath, path));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 2b7dad5

Comment on lines +111 to +112
commandSpec.Arguments.Add($"/bl:{binlogPath}");
destinations.Add(new LoggerDestination(binlogPath, true, false));
mthalman and others added 2 commits October 21, 2026 13:51
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7c8b91f0-8d92-4828-a52c-1fc9e63fe773
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7c8b91f0-8d92-4828-a52c-1fc9e63fe773

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable SDK test scenario binlogs

2 participants