|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Assertions: sync trees declared in the manifest (issue #90). |
| 3 | +# |
| 4 | +# update/check must resolve scripts/test membership from the TEMPLATE REF |
| 5 | +# (delivering new files, replacing stale ones, never touching host-added |
| 6 | +# files under the tree); adopt must resolve it from the template checkout |
| 7 | +# on disk and ADD the harness to adopted hosts. |
| 8 | + |
| 9 | +STAGE="$SANDBOX/harness-tree-sync" |
| 10 | +H="$STAGE/host" |
| 11 | +REPO_ROOT_HTS="$(cd "$HERE/../.." && pwd)" |
| 12 | + |
| 13 | +# --- update leg ------------------------------------------------------------- |
| 14 | +UP_LOG="$STAGE/update.log" |
| 15 | +( cd "$H" && bash scripts/update-from-template.sh --template-url="$STAGE/template-src" ) \ |
| 16 | + > "$UP_LOG" 2>&1 |
| 17 | +RC=$? |
| 18 | + |
| 19 | +assert "update exits 0" "[ $RC -eq 0 ]" |
| 20 | +assert "stale harness runner REPLACED with the template's" \ |
| 21 | + "grep -qF 'NEW-RUNNER-MARKER' '$H/scripts/test/run.sh'" |
| 22 | +assert "old runner content gone" \ |
| 23 | + "! grep -qF 'OLD-RUNNER-MARKER' '$H/scripts/test/run.sh'" |
| 24 | +assert "new harness lib delivered" \ |
| 25 | + "[ -f '$H/scripts/test/lib/guard.sh' ]" |
| 26 | +assert "new fixture delivered" \ |
| 27 | + "[ -f '$H/scripts/test/tests/unit/sample/assertions.sh' ]" |
| 28 | +assert "CI workflow delivered" \ |
| 29 | + "[ -f '$H/.github/workflows/test-harness.yml' ]" |
| 30 | +assert "host-owned feature test untouched (copy-no-delete)" \ |
| 31 | + "grep -qF 'HOST-FEATURE-TEST-MARKER' '$H/scripts/test/tests/unit/myfeat/assertions.sh'" |
| 32 | + |
| 33 | +# --- convergence + check leg ------------------------------------------------ |
| 34 | +UP2_LOG="$STAGE/update2.log" |
| 35 | +( cd "$H" && bash scripts/update-from-template.sh --template-url="$STAGE/template-src" ) \ |
| 36 | + > "$UP2_LOG" 2>&1 |
| 37 | +assert "second update reports zero changed files" \ |
| 38 | + "grep -qF 'Changed (0):' '$UP2_LOG'" |
| 39 | + |
| 40 | +CK_LOG="$STAGE/check.log" |
| 41 | +( cd "$H" && bash scripts/check-template-version.sh --template-url="$STAGE/template-src" ) \ |
| 42 | + > "$CK_LOG" 2>&1 |
| 43 | +CK_RC=$? |
| 44 | +assert "check-template-version exits 0 (no drift incl. harness)" \ |
| 45 | + "[ $CK_RC -eq 0 ]" |
| 46 | + |
| 47 | +# --- adopt leg (dir-mode enumeration from the real template checkout) ------- |
| 48 | +# Template-checkout only: this leg runs the CHECKOUT's own scripts/adopt.sh |
| 49 | +# against its own tree. In a derived project that binary is the frozen |
| 50 | +# instantiation-vintage adopt (not manifest-synced, by design), so its |
| 51 | +# behavior is unspecifiable here — observed in the field: a stub-era copy |
| 52 | +# dry-runs and ADDs nothing. Same discriminator as manifest-shape's guard. |
| 53 | +if [ ! -f "$REPO_ROOT_HTS/CLAUDE.md.template" ]; then |
| 54 | + skip "harness-tree-sync adopt leg" "not a template checkout (derived project; local adopt.sh vintage is unspecified)" |
| 55 | + return 0 2>/dev/null || true |
| 56 | +fi |
| 57 | +AD_LOG="$STAGE/adopt.log" |
| 58 | +( cd "$STAGE/adopt-host" && \ |
| 59 | + bash "$REPO_ROOT_HTS/scripts/adopt.sh" --target=. --apply --agent=none ) \ |
| 60 | + > "$AD_LOG" 2>&1 |
| 61 | +AD_RC=$? |
| 62 | +assert "adopt --apply exits 0" "[ $AD_RC -eq 0 ]" |
| 63 | +assert "adopt ADDed the real harness runner" \ |
| 64 | + "[ -f '$STAGE/adopt-host/scripts/test/run.sh' ]" |
| 65 | +assert "adopt ADDed the harness lib" \ |
| 66 | + "[ -f '$STAGE/adopt-host/scripts/test/lib/template.sh' ]" |
| 67 | +assert "adopt ADDed the CI workflow" \ |
| 68 | + "[ -f '$STAGE/adopt-host/.github/workflows/test-harness.yml' ]" |
0 commit comments