Skip to content

Commit e700cb9

Browse files
author
ddx-checkpoint
committed
test: harden persona contract cleanup
1 parent 0c72a7a commit e700cb9

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ not racing asynchronous network/cache work. Workerprobe integration tests also
2929
isolate server state before constructing test servers, preventing CI's
3030
state-pollution guard from seeing worker fixture projects. The D3 graph now
3131
uses the dedicated solid graph-edge tokens for document edges and arrowheads, so
32-
the frontend contrast guard passes without relying on stroke opacity.
32+
the frontend contrast guard passes without relying on stroke opacity. Persona
33+
contract tests now use retrying temp-directory cleanup for the release-blocking
34+
CI cleanup race observed in the `persona show` not-found case.
3335

3436
### Fixed: autonomous provider-connectivity recovery
3537

cli/cmd/persona_contract_test.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package cmd
33
import (
44
"os"
55
"path/filepath"
6+
"strings"
67
"testing"
8+
"time"
79

810
"github.com/DocumentDrivenDX/ddx/internal/ddxroot"
911
"github.com/spf13/cobra"
@@ -51,6 +53,28 @@ persona_bindings: {}
5153
))
5254
}
5355

56+
func personaContractTempDir(t *testing.T) string {
57+
t.Helper()
58+
59+
prefix := strings.NewReplacer("/", "-", " ", "-").Replace(t.Name())
60+
dir, err := os.MkdirTemp("", prefix+"-*")
61+
require.NoError(t, err)
62+
63+
t.Cleanup(func() {
64+
var removeErr error
65+
for attempt := 0; attempt < 5; attempt++ {
66+
removeErr = os.RemoveAll(dir)
67+
if removeErr == nil {
68+
return
69+
}
70+
time.Sleep(time.Duration(attempt+1) * 25 * time.Millisecond)
71+
}
72+
require.NoError(t, removeErr)
73+
})
74+
75+
return dir
76+
}
77+
5478
// Contract validation tests verify that persona CLI commands conform to their API contracts
5579
// as defined in the CLI persona contract
5680

@@ -359,7 +383,7 @@ func TestPersonaShowCommand_Contract(t *testing.T) {
359383
description: "Exit code 0: Persona found and displayed",
360384
args: []string{"persona", "show", "test-reviewer"},
361385
setup: func(t *testing.T) string {
362-
testWorkDir := t.TempDir()
386+
testWorkDir := personaContractTempDir(t)
363387

364388
homeDir := t.TempDir()
365389
t.Setenv("HOME", homeDir)
@@ -410,7 +434,7 @@ You are an experienced code reviewer who enforces high standards.
410434
description: "Exit code 6: Persona not found",
411435
args: []string{"persona", "show", "nonexistent-persona"},
412436
setup: func(t *testing.T) string {
413-
testWorkDir := t.TempDir()
437+
testWorkDir := personaContractTempDir(t)
414438

415439
homeDir := t.TempDir()
416440
t.Setenv("HOME", homeDir)

0 commit comments

Comments
 (0)