From c9c8a932e7b9d73f7468239897d2b92e3451bfda Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Tue, 21 Jul 2026 04:07:11 +1000 Subject: [PATCH] concurrency.test: retrying workspace cleanup for background-child log race The two child-spawning tests (two-writers, lock-holder) proceed on the children's done-marker files, but a just-finished child can still hold its redirected stdout log open for a beat after writing the marker - on Windows the -cleanup tree delete then hits 'permission denied' (observed as a ~1-in-3 flake under the slower Tcl 8.6 interp, exposed by the new native-8.6 runtests support; same race existed under Tcl 9). cleanup_workspace retries the delete briefly (10s deadline) instead of flaking. 8/8 consecutive clean runs under 8.6.17 post-fix; Tcl 9.0.3 punkcheck subtree 84/84. Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.com --- .../testsuites/punkcheck/concurrency.test | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/tests/modules/punkcheck/testsuites/punkcheck/concurrency.test b/src/tests/modules/punkcheck/testsuites/punkcheck/concurrency.test index 068dd433..bb207c96 100644 --- a/src/tests/modules/punkcheck/testsuites/punkcheck/concurrency.test +++ b/src/tests/modules/punkcheck/testsuites/punkcheck/concurrency.test @@ -68,6 +68,18 @@ namespace eval ::testspace { after 25 } } + #cleanup for workspaces where background children were spawned with redirected logs: the + #done-marker appears before the child fully exits, so on Windows its log file can still be + #open (undeletable) for a beat - retry the tree delete briefly instead of flaking + proc cleanup_workspace {root} { + set deadline [expr {[clock milliseconds] + 10000}] + while {[catch {file delete -force $root} errdel]} { + if {[clock milliseconds] >= $deadline} { + error "cleanup_workspace '$root': $errdel" + } + after 100 + } + } #added 2026-07-21 (agent, G-095) - concurrency suite: atomic saves, advisory event lock, stale-break, non-interactive recovery @@ -157,7 +169,7 @@ namespace eval ::testspace { list parse_errors [llength $parse_errors] reader_ran [expr {$observed_loads > 0}] installer_problems $dup_or_missing missing_targets $missing_targets leftovers $leftovers }\ -cleanup { - file delete -force [dict get $ws root] + cleanup_workspace [dict get $ws root] }\ -result {parse_errors 0 reader_ran 1 installer_problems {} missing_targets {} leftovers {}} @@ -194,7 +206,7 @@ namespace eval ::testspace { list errcaught $errcaught code_ok $code_ok names_holder [string match "*held by:*HOLDER-CHILD*" $errmsg] lock_cleared [expr {![file exists $pf.lock]}] }\ -cleanup { - file delete -force [dict get $ws root] + cleanup_workspace [dict get $ws root] }\ -result {errcaught 1 code_ok 1 names_holder 1 lock_cleared 1}