From eb8cbbbcb9a613757ac4440246c43ebba6758afe Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 17 Jun 2026 21:45:40 +0300 Subject: ln0 make --clean remove leftover staging directories The --clean action deleted DIST_DIR but left behind the staging/backup directories the generation pipeline creates as siblings of DIST_DIR (.shuriken..staging.* / .backup.*). Users expect --clean to remove all generation output, so extend it to also delete those. Cleanup runs after the validate_clean_dist_dir safety guard (8n0), so a dangerous DIST_DIR still aborts before any deletion. It only matches shuriken's own basename-specific staging/backup prefixes (the exact mktemp templates from config.staging.source.sh), uses nullglob so a missing match never expands to a literal pattern, and only removes directories. Unrelated dotfiles in the parent are never touched. Update test_clean to assert the staging/backup dirs are removed while unrelated entries survive, and document the behavior in the CLI usage text and README. Co-Authored-By: Claude Opus 4.8 --- tests/cli.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/cli.sh b/tests/cli.sh index 5a58384..ad2a1d7 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -253,21 +253,36 @@ test_just_install_and_deinstall_with_destdir() { test::teardown } +# --clean removes DIST_DIR and any leftover staging/backup directories that the +# generation pipeline created as siblings of DIST_DIR (ln0). Unrelated dotfiles +# and other entries in the parent must survive: we only target shuriken's own +# basename-specific ".shuriken..staging.*"/".backup.*" prefixes. test_clean() { local staging_dir + local backup_dir + local unrelated_dir + local unrelated_file test::setup printf 'DIST_DIR=%q/dist\n' "$TEST_TMPDIR" \ > "$TEST_TMPDIR/shuriken.conf" mkdir -p "$TEST_TMPDIR/dist" staging_dir="$TEST_TMPDIR/.shuriken.dist.staging.manual" - mkdir -p "$staging_dir" + backup_dir="$TEST_TMPDIR/.shuriken.dist.backup.manual" + unrelated_dir="$TEST_TMPDIR/.shuriken.other.staging.keep" + unrelated_file="$TEST_TMPDIR/.keep-me" + mkdir -p "$staging_dir" "$backup_dir" "$unrelated_dir" + touch "$unrelated_file" ( cd "$TEST_TMPDIR" "$TEST_SHURIKEN" --clean test::assert_path_absent "$TEST_TMPDIR/dist" - test::assert_dir_exists "$staging_dir" + test::assert_path_absent "$staging_dir" + test::assert_path_absent "$backup_dir" + # Unrelated entries (different basename / non-shuriken) must survive. + test::assert_dir_exists "$unrelated_dir" + test::assert_file_exists "$unrelated_file" ) test::teardown } -- cgit v1.2.3