diff options
Diffstat (limited to 'scripts/tests/audit.bats')
| -rw-r--r-- | scripts/tests/audit.bats | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/tests/audit.bats b/scripts/tests/audit.bats index 3df69c9..c6123e1 100644 --- a/scripts/tests/audit.bats +++ b/scripts/tests/audit.bats @@ -40,9 +40,28 @@ git_init_with_ai_tracked() { local proj_dir="$1" (cd "$proj_dir" \ && git init -q \ + && git config maintenance.auto false \ + && git config gc.auto 0 \ && git add -A \ && git -c user.email=test@test -c user.name=test commit -q -m initial) } +# maintenance.auto/gc.auto are off because `git commit` otherwise spawns +# `git maintenance run --auto --quiet --detach` (traced on git 2.55). The commit +# returns while that detached process is still writing .git/objects/pack, so +# teardown's `rm -rf` intermittently failed with "Directory not empty" and bats +# reported a passing test as failed. Measured at ~8% of runs. Killing the +# background writer is the fix; a retry loop in teardown would only hide it. +# +# What triggers it: the fixture rsyncs ~170 workflow/script files before +# committing, and maintenance's loose-objects task fires at a default threshold +# of 100. (Not gc.auto's 6700 — that never fires here, which is why disabling +# gc.auto alone was never the explanation.) maintenance.auto false is what +# suppresses it on 2.55; gc.auto 0 is the portable guard for older git, where +# commit calls gc --auto directly and maintenance.auto does not exist. Either +# is sufficient on its own here. +# +# Other bats suites that git-init fixtures are currently safe only by staying +# under that 100-object threshold — an implicit dependency, not a guarantee. @test "audit: clean projects report ok with exit 0" { scaffold_synced_ai "$TEST_HOME/code/alpha" @@ -113,6 +132,23 @@ git_init_with_ai_tracked() { ! grep -q "# uncommitted" "$TEST_HOME/code/alpha/.ai/protocols.org" } +@test "audit: retired projects are excluded entirely" { + # ~/projects/.retired/<name> holds shelved projects. The audit must + # never sync into them — they're not live targets. A drifted retired + # project must not appear in the output or the counts. + scaffold_synced_ai "$TEST_HOME/projects/.retired/oldproj" + echo "# drift marker" >> "$TEST_HOME/projects/.retired/oldproj/.ai/protocols.org" + scaffold_synced_ai "$TEST_HOME/code/alpha" + + run bash "$AUDIT" --no-doctor + + # The retired project is invisible to the audit, in any state. + [[ "$output" != *".retired/oldproj"* ]] + # The live project is still audited and clean. + [[ "$output" == *"ok ~/code/alpha"* ]] + [[ "$output" == *"Summary: 1 ok, 0 drift, 0 skipped, 0 failed"* ]] +} + @test "audit: loop continues past .ai/-missing failure" { # Edge case 2 from todo.org:1766. The defensive [ ! -d "$proj/.ai" ] # branch fires when a discovered .ai/ disappears between find and |
