Skip to content

[test-parallel] Add t.Parallel() to safe cross-run audit and agent example tests - #52860

Merged
pelikhan merged 1 commit into
mainfrom
go-test-parallelizer-batch-20260815-8a7fc2ff3bf85964
Aug 15, 2026
Merged

pelikhan merged 1 commit into
mainfrom
go-test-parallelizer-batch-20260815-8a7fc2ff3bf85964

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Daily Go test parallelizer run analyzing a batch of 25 pkg/cli test files (round-robin, starting after pkg/cli/add_description_test.go).

Files analyzed (batch)

add_gitattributes_test.go, add_integration_test.go, add_interactive_engine_test.go, add_interactive_git_test.go, add_interactive_orchestrator_test.go, add_interactive_schedule_test.go, add_interactive_secrets_test.go, add_interactive_workflow_test.go, add_no_args_test.go, add_package_manifest_test.go, add_skill_rewrite_test.go, add_source_test.go, add_wildcard_test.go, add_wizard_command_test.go, add_wizard_tuistory_integration_test.go, add_workflow_pr_test.go, add_workflow_resolution_manifest_ref_test.go, add_workflow_resolution_redirect_test.go, audit_agent_example_test.go, audit_agent_output_test.go, audit_agentic_analysis_test.go, audit_ambient_context_test.go, audit_comparison_test.go, audit_concurrency_test.go, audit_cross_run_test.go.

Changes made

  • pkg/cli/audit_agent_example_test.go: added t.Parallel() to TestAgentFriendlyOutputFailureScenario — it only constructs local WorkflowRun/audit data values and has no shared state (the sibling test in the same file, TestAgentFriendlyOutputExample, was left untouched because a subtest reassigns the global os.Stderr).
  • pkg/cli/audit_cross_run_test.go: added t.Parallel() to 18 top-level tests (TestBuildCrossRunAuditReport_*, TestRenderCrossRunReport*, TestNewLogsCommand_HasFormatFlag, TestLogsCommand_FormatPrecedence, TestLogsCommand_RepoParsingWithHost, TestBuildMetricsTrend_*, TestBuildDrain3InsightsFromCrossRunInputs_*) — all operate purely on locally-constructed values/report structs with no environment, filesystem, or shared-global mutation. TestRenderPrettyMetricsTrend_IncludesDurationWithoutTokens was left alone because it reassigns global os.Stderr.

Left unchanged (unsafe)

Files/tests using os.Chdir, os.Setenv/t.Setenv, package-level mock function globals, os.Stderr/os.Stdout reassignment, external CLI/network dependencies (git, gh, npx/tuistory, PTY sessions), or fixed shared binaries were intentionally left without t.Parallel() per the safety rules.

Validation

  • go build ./... — passes.
  • go test -race ./pkg/cli/... -run '<all newly-parallel tests>' — all pass.
  • go test ./pkg/cli/... — only two pre-existing, unrelated failures remain (TestRenderScheduleCalendarCell_UsesANSIInColorTerminal, TestConfirmRunAddedWorkflow_ContextCancelled), both environment-dependent (terminal color / gh auth) and untouched by this change.
  • Diff reviewed: contains only t.Parallel() additions in the two files above, no other changes.

State persisted to cache for next round-robin run: last_file = pkg/cli/audit_cross_run_test.go.

Generated by Daily Go Test Parallelizer · auto · 94.2 AIC · ⌖ 8.24 AIC · ⊞ 9.5K · ◷

  • expires on Aug 17, 2026, 10:08 PM UTC-08:00

Analyzed 25 test files in pkg/cli (batch after add_description_test.go).
Added t.Parallel() to:
- TestAgentFriendlyOutputFailureScenario (audit_agent_example_test.go): pure struct construction, no shared state
- 18 tests in audit_cross_run_test.go: buildCrossRunAuditReport/render/logs-command tests operating on local values with no env, filesystem, or shared-global mutation

Left unparallelized: tests using os.Chdir, os.Setenv/t.Setenv, package-level mock globals, os.Stderr/os.Stdout reassignment, or external CLI/network dependencies (see sub-agent analysis).

Co-authored-by: Copilot <[email protected]>
@pelikhan
pelikhan marked this pull request as ready for review August 15, 2026 12:52
Copilot AI balanced review requested due to automatic review settings August 15, 2026 12:52
@pelikhan
pelikhan merged commit caa9b6b into main Aug 15, 2026
10 checks passed
@pelikhan
pelikhan deleted the go-test-parallelizer-batch-20260815-8a7fc2ff3bf85964 branch August 15, 2026 12:52
@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #52860 does not have the implementation label and has only 20 new lines of code in business logic directories (threshold: 100).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Ponytail Reviewer completed successfully!

Lean already. Ship.

Generated by Ponytail Reviewer for #52860

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ PR Code Quality Reviewer completed the code quality review.

Completed PR review analysis for #52860; no actionable review comments were warranted because the diff only adds t.Parallel() to tests that operate on local state and intentionally excludes tests that mutate global stdio.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM. All added t.Parallel() calls are on stateless, side-effect-free test functions. No shared mutable state is present in the changed tests, so parallelisation is safe.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 14.3 AIC · ⌖ 6.99 AIC · ⊞ 5.6K

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 parallel execution to safe-looking CLI audit tests to reduce Go test runtime.

Changes:

  • Adds t.Parallel() to 19 cross-run audit tests.
  • Adds t.Parallel() to one agent failure scenario test.
  • Four cross-run tests remain unsafe because they mutate global os.Stdout.
Show a summary per file
File Description
pkg/cli/audit_cross_run_test.go Parallelizes cross-run audit tests.
pkg/cli/audit_agent_example_test.go Parallelizes the failure scenario test.

Review details

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

Suppressed comments (3)

pkg/cli/audit_cross_run_test.go:272

  • This test cannot run in parallel while it replaces process-global os.Stdout. The other newly parallel render tests perform the same replacement, allowing output to be redirected to the wrong pipe and causing race-detector failures. Remove t.Parallel() or rewrite the test to call the writer-based renderer directly.
	t.Parallel()

pkg/cli/audit_cross_run_test.go:840

  • t.Parallel() lets this test overlap with three other newly parallel tests that also replace os.Stdout. Concurrent assignment and restoration of that global can redirect output into another test's pipe and trigger data races. Remove this parallel marker unless stdout capture is changed to use an injected writer.
	t.Parallel()

pkg/cli/audit_cross_run_test.go:631

  • Parallelizing this test is unsafe because its stdout-capture block mutates os.Stdout, which is shared by the entire process. It can race with the other parallel render tests and make their output assertions nondeterministic. Keep it serial or pass the pipe/buffer to the writer-based renderer instead.
	t.Parallel()
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

}

func TestRenderCrossRunReportJSON(t *testing.T) {
t.Parallel()

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /tdd — changes look correct; two minor suggestions for completeness.

📋 Key Themes & Highlights

Positive Highlights

  • ✅ Excellent safety judgement: os.Stderr-reassigning tests correctly left non-parallel
  • ✅ All parallelised tests are genuinely pure (local struct construction only)
  • ✅ -race validation confirmed in PR description
  • ✅ Clean, minimal diff — only t.Parallel() lines, nothing else touched

Minor Suggestions

  • The two table-driven tests (TestLogsCommand_FormatPrecedence, TestLogsCommand_RepoParsingWithHost) already have t.Parallel() on the parent, but their subtests inside t.Run don't call t.Parallel(). Since Go 1.22+ the loop variable capture concern is gone, and both subtest bodies are pure — adding t.Parallel() inside the closures would maximise intra-test parallelism.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 36.3 AIC · ⌖ 8.53 AIC · ⊞ 7.7K
Comment /matt to run again

Comments that could not be inline-anchored

pkg/cli/audit_cross_run_test.go:422

[/tdd] The subtests inside TestLogsCommand_FormatPrecedence are pure (no shared state, no I/O) — they could also call t.Parallel() to maximise parallelism within the parent test.

<details>
<summary>💡 Suggested change</summary>

for _, tt := range tests {
	t.Run(tt.name, func(t *testing.T) {
		t.Parallel() // safe: subtests are pure
		// existing assertions ...
	})
}

Since this repo targets Go 1.26.5, loop variable capture is already correct — just add t.Parallel() as the …

pkg/cli/audit_cross_run_test.go:482

[/tdd] Same as the sibling table-driven test above — TestLogsCommand_RepoParsingWithHost subtests are pure string-splitting logic with no side effects and could call t.Parallel() inside t.Run.

@copilot please address this.

@github-actions

Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

✅ Test Quality Score: N/A — Parallelization Only

Infrastructure-only change: this PR adds t.Parallel() to existing tests in audit_agent_example_test.go (+1 line) and audit_cross_run_test.go (+19 lines). No new behavioral test functions were added or modified.

📊 Infrastructure Signals
Signal Value
Files changed 2
Lines added 20
New func Test* functions 0
Modified func Test* functions 0
🚨 Violations 0

Parallelization safety verified: tests operate on locally-constructed values with no shared state, environment mutation, or global os.Stderr/os.Stdout reassignment. Tests using global state were correctly left without t.Parallel().

Verdict

✅ passed. Parallelization-only PR; behavioral test ratio not applicable. No violations detected.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 38.2 AIC · ⌖ 8.4 AIC · ⊞ 7.8K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: N/A (parallelization only). 0% implementation tests (no new behavioral tests). No violations.

@github-actions github-actions Bot mentioned this pull request Aug 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.86.3

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants