Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/add-app-errors.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "add refuses to run outside a git repository" {
Expand Down
2 changes: 1 addition & 1 deletion tests/add-app.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "add installs an adapter at an arbitrary path" {
Expand Down
2 changes: 1 addition & 1 deletion tests/compose.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "the compose files are valid" {
Expand Down
2 changes: 1 addition & 1 deletion tests/docs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "docs is a config root with the full contract" {
Expand Down
29 changes: 29 additions & 0 deletions tests/helpers/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ if [ -z "${GIT_CONFIG_GLOBAL:-}" ]; then
export GIT_CONFIG_GLOBAL
git config --global user.name "scaffold tests"
git config --global user.email "tests@scaffold.invalid"
# `scaffold new` commits, and a commit can hand the repository to a detached
# `git gc`. That process outlives the command and keeps writing into .git,
# which is the likeliest thing remove_workdir below is racing. A throwaway
# repository has nothing worth maintaining.
git config --global gc.auto 0
fi

# mise records every config it trusts under its state directory, so a suite
Expand Down Expand Up @@ -62,3 +67,27 @@ copy_toolbox() {
cp "${SCAFFOLD_ROOT}/docs/PROVENANCE.md" "$dest/docs/" 2>/dev/null || true
printf '%s' "$dest"
}

# remove_workdir — teardown's `rm -rf`, retried.
#
# `rm -rf` reports "Directory not empty" when an entry appears after it walked
# the directory, so a background process still writing into a generated project
# fails a teardown that has nothing to do with what the test asserted. Seen on
# CI against `tests/compose.bats`, which generates a project per test under
# --jobs, and on a different test each run; never reproduced locally, and the
# writer was never caught in the act, so this waits the race out rather than
# naming a cause. A tree that is genuinely stuck still fails, and says what is
# left in it.
remove_workdir() {
local -r dir="$1"

for _ in 1 2 3 4 5; do
rm -rf "$dir" 2>/dev/null && return 0
sleep 1
done

rm -rf "$dir" && return 0
echo "could not remove ${dir}, left behind:" >&2
find "$dir" >&2
return 1
}
2 changes: 1 addition & 1 deletion tests/new-flask.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "flask generates an app at apps/api" {
Expand Down
2 changes: 1 addition & 1 deletion tests/new-laravel-api.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "laravel-api generates an app at apps/api" {
Expand Down
2 changes: 1 addition & 1 deletion tests/new-laravel-inertia.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "laravel-inertia generates a single app at apps/app" {
Expand Down
2 changes: 1 addition & 1 deletion tests/new-nestjs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "nestjs generates an app at apps/api" {
Expand Down
2 changes: 1 addition & 1 deletion tests/new-nextjs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "nextjs generates an app at apps/web" {
Expand Down
2 changes: 1 addition & 1 deletion tests/new-project.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "new creates a git repository on main" {
Expand Down
2 changes: 1 addition & 1 deletion tests/publish.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

# _stub_gh — a `gh` that records what it was asked to do and answers from
Expand Down
2 changes: 1 addition & 1 deletion tests/update.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

_commit() {
Expand Down
2 changes: 1 addition & 1 deletion tests/workflows.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ setup() {
}

teardown() {
rm -rf "$WORKDIR"
remove_workdir "$WORKDIR"
}

@test "the project ships five workflows" {
Expand Down