Skip to content

Commit f6fddfc

Browse files
test: add t.Parallel() to safe pkg/cli test cases (#53568)
1 parent bdb3e93 commit f6fddfc

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

pkg/cli/audit_expanded_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
func TestExtractEngineConfig(t *testing.T) {
18+
t.Parallel()
1819
tests := []struct {
1920
name string
2021
awInfoContent string
@@ -54,6 +55,7 @@ func TestExtractEngineConfig(t *testing.T) {
5455

5556
for _, tt := range tests {
5657
t.Run(tt.name, func(t *testing.T) {
58+
t.Parallel()
5759
if tt.expectNil && tt.awInfoContent == "" {
5860
result := extractEngineConfigWithInferredEngine("", "")
5961
assert.Nil(t, result, "Should return nil for empty logs path")
@@ -86,6 +88,7 @@ func TestExtractEngineConfig(t *testing.T) {
8688
}
8789

8890
func TestExtractEngineConfigWithDetails(t *testing.T) {
91+
t.Parallel()
8992
tmpDir := testutil.TempDir(t, "engine-config-details-*")
9093
awInfoContent := `{
9194
"engine_id": "copilot",
@@ -113,6 +116,7 @@ func TestExtractEngineConfigWithDetails(t *testing.T) {
113116
}
114117

115118
func TestExtractEngineConfigInferredWithoutAwInfo(t *testing.T) {
119+
t.Parallel()
116120
tmpDir := testutil.TempDir(t, "engine-infer-*")
117121
logContent := `{"type":"result","subtype":"success","num_turns":3,"usage":{"input_tokens":100,"output_tokens":200}}`
118122
require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "agent-stdio.log"), []byte(logContent), 0o644))
@@ -124,6 +128,7 @@ func TestExtractEngineConfigInferredWithoutAwInfo(t *testing.T) {
124128
}
125129

126130
func TestInferFallbackLogMetricsFindsNestedAgentStdioLog(t *testing.T) {
131+
t.Parallel()
127132
tmpDir := testutil.TempDir(t, "engine-infer-nested-*")
128133
nestedDir := filepath.Join(tmpDir, "agent", "logs")
129134
require.NoError(t, os.MkdirAll(nestedDir, 0o755))
@@ -136,6 +141,7 @@ func TestInferFallbackLogMetricsFindsNestedAgentStdioLog(t *testing.T) {
136141
}
137142

138143
func TestExtractPromptAnalysis(t *testing.T) {
144+
t.Parallel()
139145
tests := []struct {
140146
name string
141147
promptContent string
@@ -184,6 +190,7 @@ func TestExtractPromptAnalysis(t *testing.T) {
184190

185191
for _, tt := range tests {
186192
t.Run(tt.name, func(t *testing.T) {
193+
t.Parallel()
187194
if tt.name == "empty logs path" {
188195
result := extractPromptAnalysis("")
189196
assert.Nil(t, result, "Should return nil for empty logs path")
@@ -217,6 +224,7 @@ func TestExtractPromptAnalysis(t *testing.T) {
217224
}
218225

219226
func TestBuildSessionAnalysis(t *testing.T) {
227+
t.Parallel()
220228
tests := []struct {
221229
name string
222230
run WorkflowRun
@@ -287,6 +295,7 @@ func TestBuildSessionAnalysis(t *testing.T) {
287295

288296
for _, tt := range tests {
289297
t.Run(tt.name, func(t *testing.T) {
298+
t.Parallel()
290299
processedRun := ProcessedRun{
291300
Run: tt.run,
292301
JobDetails: tt.jobDetails,
@@ -314,6 +323,7 @@ func TestBuildSessionAnalysis(t *testing.T) {
314323
}
315324

316325
func TestBuildSafeOutputSummary(t *testing.T) {
326+
t.Parallel()
317327
tests := []struct {
318328
name string
319329
items []CreatedItemReport
@@ -382,6 +392,7 @@ func TestBuildSafeOutputSummary(t *testing.T) {
382392

383393
for _, tt := range tests {
384394
t.Run(tt.name, func(t *testing.T) {
395+
t.Parallel()
385396
result := buildSafeOutputSummary(tt.items, tt.chainMetrics)
386397
if tt.expectNil {
387398
assert.Nil(t, result, "Should return nil for empty items")
@@ -405,6 +416,7 @@ func TestBuildSafeOutputSummary(t *testing.T) {
405416
}
406417

407418
func TestBuildSafeOutputSummaryString(t *testing.T) {
419+
t.Parallel()
408420
tests := []struct {
409421
name string
410422
details []SafeOutputTypeDetail
@@ -434,20 +446,23 @@ func TestBuildSafeOutputSummaryString(t *testing.T) {
434446

435447
for _, tt := range tests {
436448
t.Run(tt.name, func(t *testing.T) {
449+
t.Parallel()
437450
result := buildSafeOutputSummaryString(tt.details)
438451
assert.Equal(t, tt.expected, result, "Summary string should match")
439452
})
440453
}
441454
}
442455

443456
func TestPrettifySafeOutputType(t *testing.T) {
457+
t.Parallel()
444458
assert.Equal(t, "PR(s)", prettifySafeOutputType("create_pull_request"), "Should prettify PR type")
445459
assert.Equal(t, "issue(s)", prettifySafeOutputType("create_issue"), "Should prettify issue type")
446460
assert.Equal(t, "comment(s)", prettifySafeOutputType("add_comment"), "Should prettify comment type")
447461
assert.Equal(t, "custom_type", prettifySafeOutputType("custom_type"), "Should return unknown types as-is")
448462
}
449463

450464
func TestBuildMCPServerHealth(t *testing.T) {
465+
t.Parallel()
451466
tests := []struct {
452467
name string
453468
mcpUsage *MCPToolUsageData
@@ -488,6 +503,7 @@ func TestBuildMCPServerHealth(t *testing.T) {
488503

489504
for _, tt := range tests {
490505
t.Run(tt.name, func(t *testing.T) {
506+
t.Parallel()
491507
result := buildMCPServerHealth(tt.mcpUsage, tt.mcpFailures)
492508
if tt.expectNil {
493509
assert.Nil(t, result, "Should return nil when both inputs are nil/empty")
@@ -506,6 +522,7 @@ func TestBuildMCPServerHealth(t *testing.T) {
506522
}
507523

508524
func TestBuildMCPServerHealthErrorRate(t *testing.T) {
525+
t.Parallel()
509526
mcpUsage := &MCPToolUsageData{
510527
Servers: []MCPServerStats{
511528
{ServerName: "github", RequestCount: 100, ToolCallCount: 80, ErrorCount: 15, AvgDuration: "200ms"},
@@ -525,6 +542,7 @@ func TestBuildMCPServerHealthErrorRate(t *testing.T) {
525542
}
526543

527544
func TestBuildSlowestToolCalls(t *testing.T) {
545+
t.Parallel()
528546
calls := []MCPToolCall{
529547
{ServerName: "github", ToolName: "search_code", Duration: "100ms"},
530548
{ServerName: "github", ToolName: "get_file", Duration: "500ms"},
@@ -542,6 +560,7 @@ func TestBuildSlowestToolCalls(t *testing.T) {
542560
}
543561

544562
func TestBuildSlowestToolCallsEmpty(t *testing.T) {
563+
t.Parallel()
545564
result := buildSlowestToolCalls(nil, 5)
546565
assert.Nil(t, result, "Should return nil for empty calls")
547566

@@ -550,6 +569,7 @@ func TestBuildSlowestToolCallsEmpty(t *testing.T) {
550569
}
551570

552571
func TestBuildAuditDataWithExpandedSections(t *testing.T) {
572+
t.Parallel()
553573
tmpDir := testutil.TempDir(t, "audit-expanded-*")
554574

555575
// Create test aw_info.json in activation/ subdir (unflattened artifact structure)
@@ -651,6 +671,7 @@ func TestBuildAuditDataWithExpandedSections(t *testing.T) {
651671
}
652672

653673
func TestBuildAuditDataExpandedWithNoData(t *testing.T) {
674+
t.Parallel()
654675
// Test that expanded sections are nil when no data is available
655676
processedRun := ProcessedRun{
656677
Run: WorkflowRun{
@@ -672,6 +693,7 @@ func TestBuildAuditDataExpandedWithNoData(t *testing.T) {
672693
}
673694

674695
func TestAwInfoHasMCPServers(t *testing.T) {
696+
t.Parallel()
675697
tests := []struct {
676698
name string
677699
awInfoContent string
@@ -706,6 +728,7 @@ func TestAwInfoHasMCPServers(t *testing.T) {
706728

707729
for _, tt := range tests {
708730
t.Run(tt.name, func(t *testing.T) {
731+
t.Parallel()
709732
tmpDir := testutil.TempDir(t, "mcp-servers-*")
710733
targetDir := tmpDir
711734
if tt.awInfoSubdir != "" {

pkg/cli/bootstrap_profile_git_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
func TestRunBootstrapCommitAndPushAction_CommitsAndPushesChanges(t *testing.T) {
15+
t.Parallel()
1516
repoDir := initBootstrapGitRepo(t)
1617
remoteDir := t.TempDir()
1718

@@ -74,6 +75,7 @@ func TestRunBootstrapCommitAndPushAction_CommitsAndPushesChanges(t *testing.T) {
7475
}
7576

7677
func TestRunBootstrapCommitAndPushAction_RequiresRepoDir(t *testing.T) {
78+
t.Parallel()
7779
if err := runBootstrapCommitAndPushAction(context.Background(), "", repositoryPackageBootstrapAction{
7880
Type: "commit-and-push",
7981
Message: "Bootstrap repository changes",
@@ -83,6 +85,7 @@ func TestRunBootstrapCommitAndPushAction_RequiresRepoDir(t *testing.T) {
8385
}
8486

8587
func TestRunBootstrapCommitAndPushAction_SkipsCleanCheckout(t *testing.T) {
88+
t.Parallel()
8689
repoDir := initBootstrapGitRepo(t)
8790
runRepoGit := func(args ...string) {
8891
t.Helper()

pkg/cli/cli_consistency_help_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
func TestAuditCommandDescriptionsAreConsistent(t *testing.T) {
18+
t.Parallel()
1819
cmd := NewAuditCommand()
1920

2021
assert.Contains(t, cmd.Short, "workflow runs", "audit short description should describe multiple run inputs")
@@ -23,6 +24,7 @@ func TestAuditCommandDescriptionsAreConsistent(t *testing.T) {
2324
}
2425

2526
func TestTrialCommandUsesStandardExamplesHeading(t *testing.T) {
27+
t.Parallel()
2628
cmd := NewTrialCommand(func(string) error { return nil })
2729

2830
assert.NotEmpty(t, cmd.Example, "trial command should use cobra's Example field for examples")
@@ -36,6 +38,7 @@ func TestTrialCommandUsesStandardExamplesHeading(t *testing.T) {
3638
}
3739

3840
func TestUpdateDocsIncludeCoolDownOption(t *testing.T) {
41+
t.Parallel()
3942
_, currentFile, _, ok := runtime.Caller(0)
4043
require.True(t, ok, "should resolve current test file path")
4144

@@ -52,6 +55,7 @@ func TestUpdateDocsIncludeCoolDownOption(t *testing.T) {
5255
}
5356

5457
func TestCompileDocsReflectCurrentOptions(t *testing.T) {
58+
t.Parallel()
5559
_, currentFile, _, ok := runtime.Caller(0)
5660
require.True(t, ok, "should resolve current test file path")
5761

@@ -69,6 +73,7 @@ func TestCompileDocsReflectCurrentOptions(t *testing.T) {
6973
}
7074

7175
func TestCLIDocsReflectStatusAuditAndExperimentsCommands(t *testing.T) {
76+
t.Parallel()
7277
_, currentFile, _, ok := runtime.Caller(0)
7378
require.True(t, ok, "should resolve current test file path")
7479

@@ -96,6 +101,7 @@ func TestCLIDocsReflectStatusAuditAndExperimentsCommands(t *testing.T) {
96101
}
97102

98103
func TestSubcommandListingsUseHyphenBullets(t *testing.T) {
104+
t.Parallel()
99105
tests := []struct {
100106
name string
101107
longDoc string
@@ -115,6 +121,7 @@ func TestSubcommandListingsUseHyphenBullets(t *testing.T) {
115121
}
116122

117123
func TestSubcommandListingsMatchCobraShortDescriptions(t *testing.T) {
124+
t.Parallel()
118125
t.Run("secrets bootstrap", func(t *testing.T) {
119126
cmd := NewSecretsCommand()
120127
bootstrapCmd, _, err := cmd.Find([]string{"bootstrap"})
@@ -135,6 +142,7 @@ func TestSubcommandListingsMatchCobraShortDescriptions(t *testing.T) {
135142
}
136143

137144
func TestHelpTextUsesStandardEgPunctuation(t *testing.T) {
145+
t.Parallel()
138146
assert.Contains(t, coolDownFlagUsage, "(e.g., 7d", "--cool-down help should use e.g., punctuation")
139147
assert.Contains(t, NewEnvCommand().Long, "(e.g., default_max_turns)", "env help should use e.g., punctuation")
140148
assert.Contains(t, NewDomainsCommand().Long, "(e.g., \"node\", \"python\", \"github\")", "domains help should use e.g., punctuation")
@@ -144,6 +152,7 @@ func TestHelpTextUsesStandardEgPunctuation(t *testing.T) {
144152
}
145153

146154
func TestLegacyNestedGHHelpIsRejected(t *testing.T) {
155+
t.Parallel()
147156
tests := []struct {
148157
name string
149158
newCmd func() *cobra.Command
@@ -160,6 +169,7 @@ func TestLegacyNestedGHHelpIsRejected(t *testing.T) {
160169

161170
for _, tt := range tests {
162171
t.Run(tt.name, func(t *testing.T) {
172+
t.Parallel()
163173
cmd := tt.newCmd()
164174
cmd.SilenceUsage = true
165175
cmd.SilenceErrors = true

0 commit comments

Comments
 (0)