Skip to content

Fix Git test output capture and make JSON/DI contracts explicit - #5393

Merged
arturcic merged 4 commits into
GitTools:mainfrom
arturcic:codex/backend-neutral-aot-prerequisites
Oct 21, 2026
Merged

arturcic merged 4 commits into
GitTools:mainfrom
arturcic:codex/backend-neutral-aot-prerequisites

Conversation

@arturcic

@arturcic arturcic commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Description

Concurrent stdout/stderr callbacks in the Git test helper can corrupt its shared
buffer or abort the test process. Serialize those writes and retain a regression
that checks every line from both streams.

Use source-generated JSON contracts for configuration-validation results and
AppVeyor requests, preserving field names, nulls, escaping and the GitVersion_
variable prefix. Register the seven built-in version strategies and fifteen
build agents explicitly, with tests preserving the complete discovery order.

These three commits are extracted from #5391 and apply directly to main. The
ordinary CLI continues to support LibGit2Sharp and managed Git with existing
release defaults. NativeAOT publication, build flags, backend restrictions,
configuration/YAML and version-formatting work remain in #5391. Rebase #5391
after this PR lands to remove the shared changes.

Development for #5210: these backend-neutral runtime/serialization improvements
can land independently of the managed-only NativeAOT work in #5391.

Validation

Base: bde36696007d412195a0f2dd5f43d6ae820de025 (main).
Validated head: 61a047930 on macOS ARM64, SDK
11.0.100-rc.2.26504.105, with GITVERSION_GIT_BACKEND=libgit2.

All six relevant project/framework runs passed with LibGit2Sharp selected:

Suite net10.0 net11.0
Core (full suite) 36,492 passed 36,492 passed
CLI (full suite) 659 passed 659 passed
Build agents (full suite) 111 passed 111 passed

Total: 74,524 passed, 0 failed, 0 skipped in the completed passing runs.
JUnit reports were parsed and checked for the exact extracted regression names.

An initial net10 CLI run had one failure in
BeingOnBuildServerWithOutputJsonDoesNotFail: an INFO line from stderr was
interleaved into JSON in the test helper's combined output. That test, its
capture helper and combined-output parser are unchanged from main. The focused
four-case rerun and a complete 659-test CLI rerun both passed without changes.
The initial failed report is retained locally; it is not counted as passing.

Requirement Evidence
Preserve concurrent Git command output ExecuteGitCmdPreservesConcurrentStandardOutputAndError checks 10,000 stdout and 10,000 stderr lines. Its original failure was reproduced before the synchronization fix.
Preserve configuration-validation JSON ValidationEnvelopePreservesFieldNamesNullsAndDiagnosticDetails, SuccessfulValidationPreservesEmptyDiagnostics, YamlDiagnosticPreservesNumericLocationAndEscapedUnicodePath pin the wire contract.
Preserve AppVeyor requests BuildNumberRequestPreservesWireNameAndVersion, VariableRequestPreservesWireNamesAndEscaping pin request names, values and escaping.
Preserve strategy/build-agent selection order VersionStrategiesPreserveTheCompleteDiscoveryOrder, BuildAgentsPreserveTheCompleteDiscoveryOrder compare the complete registration sequences and singleton lifetimes.

Reproduction with the pinned SDK available on PATH:

for framework in net10.0 net11.0; do
  for project in GitVersion.Core.Tests GitVersion.App.Tests GitVersion.BuildAgents.Tests; do
    GITVERSION_GIT_BACKEND=libgit2 dotnet test \
      --project "$PWD/src/$project/$project.csproj" \
      --framework "$framework" --report-spekt-junit \
      --results-directory "$PWD/TestResults/$project/$framework"
  done
done

CodeRabbit CLI completed the entire 11-file diff against origin/main with zero
findings. The extracted files exactly match their reviewed #5391 counterparts.
git diff --check passes. No validation workflow or harness is added.

Codex responding on behalf of @arturcic.

Summary by CodeRabbit

  • Bug Fixes

    • Improved configuration-validation JSON output, preserving field names, null values, diagnostics, numeric locations, and escaped characters.
    • Improved AppVeyor request serialization, including special characters and empty values.
    • Improved Git command output capture when standard output and error streams arrive concurrently.
  • Refactor

    • Made service registration more predictable while preserving supported versioning strategies and build agents.
  • Tests

    • Added coverage for validation, AppVeyor requests, dependency registration, and concurrent Git output.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 07:00

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 986cd560-440c-42d0-8873-e6a2cadf756a
📥 Commits

Reviewing files that changed from the base of the PR and between 61a0479 and 1dd16af.

📒 Files selected for processing: 2
  • src/GitVersion.App.Tests/ConfigurationValidationJsonTests.cs
  • src/GitVersion.BuildAgents.Tests/Agents/AppVeyorJsonTests.cs
🚧 Files skipped from review as they are similar to previous changes: 2
  • src/GitVersion.BuildAgents.Tests/Agents/AppVeyorJsonTests.cs
  • src/GitVersion.App.Tests/ConfigurationValidationJsonTests.cs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

📝 Walkthrough

The changes add source-generated JSON serialization for configuration validation results and AppVeyor requests, replace reflection-based registrations with explicit singleton registrations, and synchronize stdout and stderr collection in ExecuteGitCmd.

Changes: Configuration validation JSON

Layer / File(s) Summary
Validation result serialization
src/GitVersion.App/ConfigurationValidationJsonContext.cs, src/GitVersion.App/ConfigurationValidationExecutor.cs, src/GitVersion.App.Tests/ConfigurationValidationJsonTests.cs
The executor serializes typed validation results through a source-generated JSON context. Tests check null fields, diagnostic details and escaping, empty diagnostics, and numeric YAML locations.

AppVeyor request JSON

Layer / File(s) Summary
AppVeyor request serialization
src/GitVersion.BuildAgents/Agents/AppVeyorJsonContext.cs, src/GitVersion.BuildAgents/Agents/AppVeyor.cs, src/GitVersion.BuildAgents.Tests/Agents/AppVeyorJsonTests.cs
Build-number and variable requests use typed models and source-generated serialization. Tests check wire names, values, and handling of empty, quoted, and newline-containing values.

Dependency registrations

Layer / File(s) Summary
Explicit singleton registrations
src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/VersionStrategyModule.cs, src/GitVersion.BuildAgents/GitVersionBuildAgentsModule.cs, src/GitVersion.Core.Tests/DependencyRegistrationTests.cs
The modules explicitly register built-in strategies and build agents as singletons. Tests check registration order, service types, and lifetimes.

Git process output

Layer / File(s) Summary
Synchronized process output collection
src/GitVersion.Testing/Extensions/GitTestExtensions.cs, src/GitVersion.Core.Tests/Extensions/GitTestExtensionsTests.cs
ExecuteGitCmd synchronizes stdout and stderr appends with a shared lock. A test checks captured output from 10,000 stdout and stderr pairs.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 1dd16

The JSON expectations retain their prior behavior; no issue identified here prevents merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately summarizes the main changes: fixing Git test output capture and making JSON and dependency-injection contracts explicit.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@arturcic
arturcic merged commit b4f0146 into GitTools:main Oct 21, 2026
50 checks passed
@arturcic
arturcic deleted the codex/backend-neutral-aot-prerequisites branch October 21, 2026 07:48
@mergify

mergify Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Thank you @arturcic for your contribution!

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.

Evaluate .NET 11 SDK, runtime and BCL improvements

2 participants