Skip to content

Add RetryArtifactProcessor.ProcessAsync unit tests - #10579

Merged
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/test-retry-artifact-processor
Aug 18, 2026
Merged

Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/test-retry-artifact-processor

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

  • add focused unit coverage for retry artifact processor selection, matching, and complete-attempt validation
  • verify ordered processor inputs, replacement bookkeeping, external artifact publication, and platform path comparison
  • cover null and invalid processor output, exact warning behavior, continuation, and cancellation semantics

Testing

  • .\build.cmd -projects test\UnitTests\Microsoft.Testing.Extensions.UnitTests\Microsoft.Testing.Extensions.UnitTests.csproj -bl
  • .\.dotnet\dotnet.exe test test\UnitTests\Microsoft.Testing.Extensions.UnitTests\Microsoft.Testing.Extensions.UnitTests.csproj -c Debug --no-build --no-restore -bl:artifacts\log\Debug\RetryArtifactProcessor.AllTfms.binlog
    • 4,200 passed and 24 platform-specific skipped across net462, net472, net8.0, and net9.0

Closes #10578

Add focused coverage for processor selection, matching, completeness, replacement bookkeeping, warning behavior, and cancellation semantics.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 13, 2026 02:21
@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Aug 13, 2026

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.

Pull request overview

Adds focused unit coverage for retry artifact processing and related artifact handling.

Changes:

  • Tests processor selection, matching, validation, ordering, and replacement bookkeeping.
  • Covers warning, continuation, and cancellation behavior.
  • Adds reusable test setup helpers and post-processor fake.
Show a summary per file
File Description
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/RetryTests.cs Expands retry artifact processor unit coverage.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Expert test review — PR #10579

Reviewed the 11 new test methods added to RetryTests.cs. These tests exercise RetryArtifactProcessor.SnapshotAttemptArtifacts, PublishExternalArtifacts, and the new ProcessAsync artifact-post-processing pipeline (production code in src/Platform/Microsoft.Testing.Extensions.Retry/RetryArtifactProcessor.cs and ArtifactPostProcessingDispatcherTool.ValidateProcessedArtifact).

Overall quality is high: each test isolates a single branch (guard clauses, ordering, kind/extension matching, validation failure + continuation, cancellation vs. unrelated-cancellation warning paths), uses Mock<IFileSystem>/Mock<ILogger>/Mock<IOutputDevice> verification consistent with the project's MSTest Assert conventions, and cleans up temp directories in finally blocks.

GradeTestMutationNotesHow to improve
B (80–89) new RetryTests.
ProcessAsync_
ReplacementLookupUsesPlatformPathComparison
2/3 killed Correct but conditional assertion (branches on RuntimeInformation.IsOSPlatform) makes the single test's intent harder to read at a glance. Split into two explicit tests (or a `[DataRow(bool isWindows)]`-driven helper) asserting the exact expected boolean per OS instead of branching in the assertion.
A (90–100) new RetryTests.
SnapshotAttemptArtifacts_
LeavesAttemptArtifactInPlace
4/4 killed Verifies no copy/create-directory occurs and destination stays null when the artifact is already under the attempt directory. —
A (90–100) new RetryTests.
PublishExternalArtifacts_
UsesFinalSnapshotWhenNoReplacementExists
3/3 killed Confirms fallback to the final snapshot and that non-final/no-destination artifacts are skipped. —
A (90–100) new RetryTests.
ProcessAsync_
ProcessorWithoutRetryMode_
IsNotCalled
2/2 killed Guards the SupportedModes filter; processor call count and empty replacements both checked. —
A (90–100) new RetryTests.
ProcessAsync_
SingleAttempt_
IsNotProcessed
2/2 killed Covers the attemptCount < 2 short-circuit. —
A (90–100) new RetryTests.
ProcessAsync_
CompleteArtifacts_
UsesAttemptOrderAndMapsFinalArtifact
7/7 killed Thorough: checks input ordering by attempt, execution IDs, null producer metadata, captured context/mode/cancellation token, and final replacement mapping. —
A (90–100) new RetryTests.
ProcessAsync_
MatchesProducerKindOrUntaggedExtension
5/5 killed Data-driven coverage of kind-based (case-sensitive) vs. extension-based (case-insensitive) matching, including the "no match" cases. —
A (90–100) new RetryTests.
ProcessAsync_
IncompleteOrDuplicateAttemptArtifacts_
AreNotProcessed
2/2 killed Confirms both a missing attempt and a duplicate-attempt group are skipped without invoking the processor. —
A (90–100) new RetryTests.
ProcessAsync_
ProcessorDeclinesMerge_
ReturnsNoReplacement
2/2 killed Processor returning null still gets invoked but yields no replacement. —
A (90–100) new RetryTests.
ProcessAsync_
InvalidOutput_
WarnsAndContinuesWithOtherKinds
5/5 killed Exercises ValidateProcessedArtifact failure (missing file) triggering a warning + log while a second, valid processor still succeeds. —
A (90–100) new RetryTests.
ProcessAsync_
CanceledProcessor_
PropagatesWithoutWarning
3/3 killed Confirms cancellation tied to the ambient token rethrows without logging or displaying a warning. —
A (90–100) new RetryTests.
ProcessAsync_
UnrelatedCancellation_
WarnsWithoutPropagating
4/4 killed Distinguishes a processor-thrown OperationCanceledException unrelated to the ambient token, verifying it is swallowed and reported as a warning with the exact formatted message. —

No high-confidence, inline-actionable findings beyond the one B-grade note above (which is a readability/clarity suggestion, not a correctness bug — the assertion itself is correct for both platforms). No inline suggestion was posted since the improvement is a structural refactor (splitting into two tests) rather than a single-line mechanical edit.

This advisory comment was generated automatically. Grades are heuristic and informational — they do not block merging. Re-run with /review-tests.

🤖 Automated content by GitHub Copilot. Generated by the Test Reviewer on PR (on open / sync) workflow. · auto · 116.8 AIC · ⌖ 3.95 AIC · ⊞ 16.9K · [◷]( · ◷)

@github-actions

Copy link
Copy Markdown
Contributor

🧵 Parallel-safety audit — PR #10579

Parallelization — assembly audited:

Test assembly Scope Workers Analyzer coverage
Microsoft.Testing.Extensions.UnitTests MethodLevel 0 (CPU count) coverable once the parallel-safety analyzers ship (attribute opt-in in Program.cs)

Findings: A (global-state) 0 · B (paths) 0 · C (declaration) 0 · D (over-serialization) 0 — by severity: Critical 0 · High 0 · Warning 0 · Info 0.

RetryTests.cs adds coverage for RetryArtifactProcessor.ProcessAsync/SnapshotAttemptArtifacts. Reviewed under MethodLevel scope (every method is its own concurrency chunk, so intra-class conflicts are live), nothing unsafe was found:

  • Filesystem paths (category B): every test that actually writes a file obtains its directory from CreateTemporaryDirectory(), which builds a fresh Path.Combine(Path.GetTempPath(), $"retry-artifact-processor-{Guid.NewGuid():N}") and calls Directory.CreateDirectory per invocation — each test owns a unique directory, so there is no cross-test collision, and each disposes it in a finally (Directory.Delete(outputDirectory, recursive: true)).
  • Several tests (e.g. ProcessAsync_ProcessorWithoutRetryMode_IsNotCalled, ProcessAsync_SingleAttempt_IsNotProcessed, ProcessAsync_IncompleteOrDuplicateAttemptArtifacts_AreNotProcessed, ProcessAsync_CanceledProcessor_PropagatesWithoutWarning, ProcessAsync_UnrelatedCancellation_WarnsWithoutPropagating) pass Path.GetTempPath() directly as outputDirectory, but their processor stub either never gets called, returns null, or throws before any File.WriteAllText — no actual I/O reaches the shared OS temp root, so this is not a category-B finding (no proven mutation, per the "trace the value" rule).
  • Process-global state (category A): no Environment.SetEnvironmentVariable, Directory.SetCurrentDirectory, Console.Set*, or culture mutation in the file; CultureInfo.CurrentCulture is only read (in string.Format assertions), never written.
  • Static/shared state: TestArtifactPostProcessor instances and ProcessCallCount are per-test locals/instance fields, not static; the production RetryArtifactProcessor (src/Platform/Microsoft.Testing.Extensions.Retry/RetryArtifactProcessor.cs) is a stateless static class with no mutable fields.
  • Declaration reconciliation (category C): the file adds no [ResourceLock] / [DoNotParallelize], so no near-miss or over/under-declaration is possible; sibling tests in the project (TrxLongPathHelperTests.cs, AzureFoundryChatClientProviderTests.cs) use [DoNotParallelize] for unrelated reasons and don't share keys with this file.

No changes to .runsettings, testconfig.json, or any assembly-level [Parallelize]/[DoNotParallelize] attribute in this PR — the project's existing [assembly: Parallelize(Scope = ExecutionScope.MethodLevel, Workers = 0)] in Program.cs is unmodified.

Advisory only — heuristic, non-blocking. Re-run with /parallel-audit. This audit answers "is it parallel-safe?"; for testability, smells, or flakiness see the detect-static-dependencies / test-smell-detection / test-anti-patterns analyses.

🤖 Automated content by GitHub Copilot. Generated by the Parallel-safety audit on PR (on open / sync) workflow. · auto · 92 AIC · ⌖ 4.71 AIC · ⊞ 24.8K · [◷]( · ◷)

@Evangelink
Amaury Levé (Evangelink) merged commit 6067819 into main Aug 18, 2026
41 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/test-retry-artifact-processor branch August 18, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test-improver] Add unit tests for RetryArtifactProcessor.ProcessAsync

3 participants