Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane.io/blob/main/scripts/tests/check-sync.sh # interplane.io Source of interplane.io: a Rust generator that renders the page from the protocol repository's public record, deployed hourly from the Spark. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane.io / scripts / tests / check-sync.sh` 507 lines ยท 30043 bytes Raw Blame History 1 #!/bin/sh 2 # Controls for scripts/sync-to-hub.sh. Nothing here contacts a server or writes outside its own 3 # temporary folder. git is the real git, working on local repositories made here (the history, 4 # and the project repository of a signed store that holds it); the git wrapper only traces calls 5 # and refuses any remote, clone, fetch or ref change. ipl is a stand-in for `ipl verify`: it answers 6 # with the real tool's OK line for the store's actual main, or refuses (exit 3) as the real tool 7 # does when the project does not verify or the owner asked for is not the pinned one. quietlock, 8 # uname, the compiler, the builder, rsync and sudo are stubs. The sudo stub replays the root copy 9 # into a temporary folder so that "the destination is empty" is measured, not assumed. 10 set -eu 11 ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) 12 TEST_ROOT=$(mktemp -d) 13 trap 'rm -rf "$TEST_ROOT"' 0 14 trap 'exit 1' 1 2 15 15 REAL_SHA256=$(command -v sha256sum) 16 REAL_GIT=$(command -v git) 17 REAL_RSYNC=$(command -v rsync) 18 GIT_CONFIG_GLOBAL=/dev/null 19 GIT_CONFIG_NOSYSTEM=1 20 GIT_AUTHOR_NAME=fixture GIT_AUTHOR_EMAIL=fixture GIT_COMMITTER_NAME=fixture GIT_COMMITTER_EMAIL=fixture 21 GIT_AUTHOR_DATE='2000-01-01T00:00:00Z' GIT_COMMITTER_DATE='2000-01-01T00:00:00Z' 22 export TEST_ROOT REAL_SHA256 REAL_GIT REAL_RSYNC GIT_CONFIG_GLOBAL GIT_CONFIG_NOSYSTEM 23 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_DATE GIT_COMMITTER_DATE 24 OWNER_FP=SHA256:FixtureOwnerKey0000000000000000000000000000 25 OTHER_FP=SHA256:SomeOtherOwnerKey11111111111111111111111111 26 mkdir -p "$TEST_ROOT/bin" 27 28 # ---- the history (A, then B, then C) and the signed store's repository for the project 29 UP="$TEST_ROOT/upstream" 30 STORE="$TEST_ROOT/store" 31 SRC="$STORE/projects/interplane.io/repo.git" 32 mkdir -p "$UP/scripts" "$UP/native/lib" "$UP/content" 33 "$REAL_GIT" -C "$UP" init -q 34 "$REAL_GIT" -C "$UP" symbolic-ref HEAD refs/heads/main 35 cp "$ROOT/scripts/build-native.sh" "$UP/scripts/build-native.sh" 36 cp "$ROOT/native/site.om" "$UP/native/site.om" 37 cp "$ROOT/native/translate.om" "$UP/native/translate.om" 38 cp "$ROOT/native/lib/sha2.om" "$UP/native/lib/sha2.om" 39 cp "$ROOT/native/omc.sha256" "$UP/native/omc.sha256" 40 read -r PIN_HASH _ < "$ROOT/native/omc.sha256" 41 export PIN_HASH 42 commit() { 43 printf '%s\n' "$1" > "$UP/content/marker.txt" 44 "$REAL_GIT" -C "$UP" add -A 45 "$REAL_GIT" -C "$UP" commit -q -m "$1" 46 "$REAL_GIT" -C "$UP" rev-parse HEAD 47 } 48 A=$(commit release-a) 49 B=$(commit release-b) 50 printf 'note changed\n' >> "$UP/native/lib/sha2.om" 51 C=$(commit release-c-with-a-changed-sha2-unit) 52 "$REAL_GIT" init -q --bare "$SRC" 53 "$REAL_GIT" -C "$SRC" symbolic-ref HEAD refs/heads/main 54 "$REAL_GIT" -C "$UP" push -q "$SRC" "$A:refs/heads/main" "$C:refs/heads/history" 55 # store_main COMMIT: what `ipl land` would leave, the store's main at COMMIT 56 store_main() { "$REAL_GIT" -C "$SRC" update-ref refs/heads/main "$1"; } 57 58 cat > "$TEST_ROOT/bin/git" <<'STUB' 59 #!/bin/sh 60 set -eu 61 printf 'git %s\n' "$*" >> "$TEST_ROOT/trace" 62 for a in "$@"; do 63 case "$a" in 64 ls-remote|clone|fetch|pull|push|remote|update-ref|*://*) echo "git $a in deployment test: the source is the store, read in place" >&2; exit 90 ;; 65 esac 66 done 67 exec "$REAL_GIT" "$@" 68 STUB 69 cat > "$TEST_ROOT/bin/ipl" <<'STUB' 70 #!/bin/sh 71 set -eu 72 printf 'ipl %s\n' "$*" >> "$TEST_ROOT/trace" 73 [ "$#" -eq 5 ] && [ "$1" = verify ] && [ "$2" = "$STORE" ] && [ "$3" = interplane.io ] && [ "$4" = --expect-owner ] || { echo 'unexpected ipl command' >&2; exit 90; } 74 # As the real tool: exit 3 when the owner asked for is not the pinned owner, or nothing verifies. 75 [ "$5" = "$OWNER_FP" ] || { printf 'ipl: current owner pin is %s, not %s\n' "$OWNER_FP" "$5" >&2; exit 3; } 76 [ "${STUB_IPL:-ok}" != fail ] || { echo 'ipl: interplane.io: does not verify: fixture' >&2; exit 3; } 77 HEAD=$("$REAL_GIT" --git-dir="$STORE/projects/interplane.io/repo.git" rev-parse refs/heads/main) 78 ID=$(printf '%064d' 1) CH=$(printf '%064d' 2) 79 ok() { printf 'OK %s %s %s %s public %s 8 %s\n' "$1" "$ID" "$2" "$HEAD" "$3" "$CH"; } 80 case "${STUB_IPL:-ok}" in 81 ok) ok interplane.io main "$5" ;; 82 other-owner) ok interplane.io main "$OTHER_FP" ;; 83 other-project) ok interplane-forge main "$5" ;; 84 other-branch) ok interplane.io next "$5" ;; 85 two) ok interplane.io main "$5"; ok interplane.io main "$5" ;; 86 empty) ;; 87 *) exit 95 ;; 88 esac 89 STUB 90 cat > "$TEST_ROOT/bin/quietlock" <<'STUB' 91 #!/bin/sh 92 exit "${STUB_QUIET:-0}" 93 STUB 94 cat > "$TEST_ROOT/bin/uname" <<'STUB' 95 #!/bin/sh 96 printf '%s\n' "${STUB_MACHINE:-aarch64}" 97 STUB 98 cat > "$TEST_ROOT/bin/sha256sum" <<'STUB' 99 #!/bin/sh 100 set -eu 101 case "$1" in 102 "$TEST_ROOT/compiler"|"$TEST_ROOT/omega/seed/out/omc") 103 if [ "${STUB_BAD_COMPILER:-0}" = 1 ]; then 104 printf '%s %s\n' invalid "$1" 105 else 106 printf '%s %s\n' "$PIN_HASH" "$1" 107 fi ;; 108 */native/lib/sha2.om) exec "$REAL_SHA256" "$@" ;; 109 *) [ "${STUB_HASH_FAIL:-0}" = 0 ] || exit 91 110 exec "$REAL_SHA256" "$@" ;; 111 esac 112 STUB 113 cat > "$TEST_ROOT/compiler" <<'STUB' 114 #!/bin/sh 115 set -eu 116 echo compile >> "$TEST_ROOT/trace" 117 cat > "$TEST_ROOT/compiled-input" 118 [ "${STUB_COMPILE_FAIL:-0}" = 0 ] || exit 92 119 cat "$TEST_ROOT/builder-template" 120 STUB 121 # The stand-in builder runs from the exported commit, like the real one, and copies the commit's 122 # marker into the page so a control can tell which commit was built. 123 cat > "$TEST_ROOT/builder-template" <<'STUB' 124 #!/bin/sh 125 set -eu 126 printf 'builder %s\n' "$1" >> "$TEST_ROOT/trace" 127 case "$1" in 128 build) 129 [ "${STUB_BUILD_FAIL:-0}" = 0 ] || exit 93 130 test ! -e "$2" 131 mkdir -p "$2/public" 132 BANNER= 133 [ "${STUB_TESTDATA:-}" != banner ] || BANNER='
TEST DATA
' 134 printf '%s
%s\n' "$(cat content/marker.txt)" "$BANNER" > "$2/index.html" 135 cp "$2/index.html" "$TEST_ROOT/built-index" 136 printf '%s\n' '{"source":"committed"}' > "$2/facts.json" 137 printf '%s\n' "${STUB_ASSET:-base}" > "$2/public/style.css" 138 [ "${STUB_TESTDATA:-}" != file ] || printf 'fixture output\n' > "$2/TEST-DATA" 139 [ "${STUB_TESTDATA:-}" != manifest ] || printf '%064d TEST-DATA\n' 0 > "$2/manifest.sha256" 140 if [ "${STUB_HOP:-0}" != 0 ]; then 141 mkdir -p "$3" 142 printf 'release-b
' "$TEST_ROOT/built-index" || fail 'the page was not built from the signed main' 285 [ "$(sed -n 1p "$TEST_ROOT/trace")" = "$VERIFY_LINE" ] || fail 'ipl verify was not the first step' 286 grep -Fq "git --git-dir=$SRC archive --format=tar " "$TEST_ROOT/trace" || fail 'the source was not exported from the store' 287 "$REAL_GIT" -C "$SRC" for-each-ref | cmp -s - "$TEST_ROOT/refs.before" || fail 'the publisher changed a ref in the store' 288 [ -z "$(find "$STORE" -newer "$TEST_ROOT/store.mark" -print)" ] || fail 'the publisher wrote into the store' 289 if grep -q -e 'rad:' -e 'ls-remote' -e ' clone ' -e ' fetch ' "$TEST_ROOT/trace"; then fail 'the publisher asked a remote'; fi 290 receipt interplane.io published fixture-hub:/fixture-web "$B" 291 passed 'signed main named: verify first, then an export of exactly that commit from the store; the store is not written and no remote is asked' 292 293 prepare no-commit; store_main "$B" 294 run 295 [ "$RC" -eq 0 ] || { cat "$TEST_ROOT/stdout" "$TEST_ROOT/stderr" >&2; fail "no commit named: expected a publish, got exit $RC"; } 296 grep -q "commit: the signed main of interplane.io, $B" "$TEST_ROOT/stdout" && grep -q 'release-b
' "$TEST_ROOT/built-index" || fail 'no commit named: the signed main was not the commit built' 297 receipt interplane.io published fixture-hub:/fixture-web "$B" 298 passed 'no commit named (the service start): the verified signed main is resolved, built and published' 299 300 # ---- compiler, build, verify and digest refusals 301 prepare bad-compiler; store_main "$B"; STUB_BAD_COMPILER=1 302 refused 'compiler with the wrong SHA-256' 3 'compilation failed' "$B" 303 if grep -q '^compile$' "$TEST_ROOT/trace"; then fail 'a compiler with the wrong hash was run'; fi 304 prepare missing-compiler; store_main "$B"; OMC="$TEST_ROOT/absent" 305 refused 'missing compiler' 3 'compilation failed' "$B" 306 OMC="$TEST_ROOT/compiler" 307 prepare compile-failed; store_main "$B"; STUB_COMPILE_FAIL=1 308 refused 'compilation failure' 3 'compilation failed' "$B" 309 prepare build-failed; store_main "$B"; STUB_BUILD_FAIL=1 310 refused 'build failure' 4 'native build failed' "$B" 311 prepare verify-failed; store_main "$B"; STUB_VERIFY_FAIL=1 312 refused 'verify failure' 4 'verify failed' "$B" 313 prepare hash-failed; store_main "$B"; STUB_HASH_FAIL=1 314 refused 'digest failure' 8 'could not take the digest' "$B" 315 prepare changed-sha2; store_main "$C" 316 refused 'commit whose SHA-2 unit is not the pinned one' 3 'compilation failed' "$C" 317 if grep -q '^compile$' "$TEST_ROOT/trace"; then fail 'a changed SHA-2 unit reached the compiler'; fi 318 prepare unit-composition; store_main "$B" 319 published "$B" 320 "$REAL_GIT" -C "$UP" show "$B:native/lib/sha2.om" > "$TEST_ROOT/sha2.b" 321 "$REAL_GIT" -C "$UP" show "$B:native/site.om" > "$TEST_ROOT/site.b" 322 "$REAL_GIT" -C "$UP" show "$B:native/translate.om" > "$TEST_ROOT/translate.b" 323 { printf 'om2\n'; cat "$TEST_ROOT/sha2.b" "$TEST_ROOT/site.b" "$TEST_ROOT/translate.b"; } > "$TEST_ROOT/expected-unit.om" 324 cmp "$TEST_ROOT/compiled-input" "$TEST_ROOT/expected-unit.om" || fail 'compiler input differs' 325 passed "compiler input is the om2 line, the commit's SHA-2 unit, then the commit's builder and translation unit" 326 327 # ---- fixture output is never published 328 for kind in file manifest banner; do 329 prepare "testdata-$kind"; store_main "$B"; STUB_TESTDATA=$kind 330 refused "fixture output ($kind marker) in the interplane.io build" 6 'fixture output is never published' "$B" 331 done 332 prepare testdata-hop; store_main "$B"; STUB_HOP=1; STUB_TESTDATA=hopfile 333 refused 'fixture output (file marker) in the hopbot.org build' 6 'fixture output is never published' "$B" 334 335 # ---- interplane.io: transfer, receipt, unchanged, pending 336 prepare publish; store_main "$B" 337 published "$B" 338 grep -q '^rsync -a --delete --exclude .well-known .*/dist/ fixture-hub:/fixture-web/$' "$TEST_ROOT/trace" || fail 'transfer options or destination differ' 339 [ "$(transfers)" -eq 1 ] || fail 'a build without a Hop release made more than one transfer' 340 receipt interplane.io published fixture-hub:/fixture-web "$B" 341 [ ! -e "$LOGDIR/receipt.hopbot.org" ] && [ -z "$(ls -A "$HOPWEBDIR")" ] || fail 'the hopbot.org folder was touched without a Hop release' 342 D1=$(field "$LOGDIR/receipt.interplane.io" digest) 343 [ "${#D1}" -eq 64 ] || fail 'the receipt holds no digest' 344 passed 'publish without a Hop release: one transfer to the hub, a receipt with destination, digest and the full commit; hopbot.org untouched' 345 again; published "$B" 346 no_transfer unchanged; grep -q '^.* unchanged: interplane.io' "$TEST_ROOT/stdout" || fail 'unchanged run did not say so' 347 [ "$(field "$LOGDIR/receipt.interplane.io" digest)" = "$D1" ] || fail 'unchanged run rewrote the receipt' 348 passed 'same commit, same content, same destination: nothing is transferred' 349 STUB_ASSET=changed; again; published "$B" 350 [ "$(transfers)" -eq 1 ] && [ "$(field "$LOGDIR/receipt.interplane.io" digest)" != "$D1" ] || fail 'a stylesheet-only change was not published' 351 passed 'a stylesheet-only change is published' 352 D2=$(field "$LOGDIR/receipt.interplane.io" digest) 353 STUB_ASSET=changed-again STUB_RSYNC_FAIL=1; again; run "$B" 354 [ "$RC" -eq 8 ] && [ "$(field "$LOGDIR/receipt.interplane.io" digest)" = "$D2" ] && [ -f "$LOGDIR/pending.interplane.io" ] || fail 'failed transfer: receipt or pending marker wrong' 355 passed 'a failed transfer exits 8, keeps the old receipt and leaves the pending marker' 356 STUB_ASSET=changed STUB_RSYNC_FAIL=0; again; published "$B" 357 [ "$(transfers)" -eq 1 ] && [ ! -e "$LOGDIR/pending.interplane.io" ] && [ "$(field "$LOGDIR/receipt.interplane.io" digest)" = "$D2" ] || fail 'a pending transfer was not repaired' 358 passed 'content back at the last published digest is still transferred while a pending marker is left' 359 STUB_ASSET=changed-again; again; published "$B" 360 [ "$(transfers)" -eq 1 ] && [ "$(field "$LOGDIR/receipt.interplane.io" digest)" != "$D2" ] || fail 'later release not published' 361 passed 'the later release is then published' 362 363 # A receipt belongs to one commit: the same bytes from another commit are transferred and recorded anew. 364 prepare commit-bound; store_main "$A" 365 published "$A" 366 E=$("$REAL_GIT" -C "$UP" commit-tree -p "$B" -m 'same tree as A' "$A^{tree}") 367 "$REAL_GIT" -C "$UP" update-ref refs/heads/same-tree "$E" 368 "$REAL_GIT" -C "$UP" push -q "$SRC" "$E:refs/heads/same-tree" 369 store_main "$E"; again; published "$E" 370 [ "$(transfers)" -eq 1 ] || fail 'a new commit with the same content was not transferred' 371 receipt interplane.io published fixture-hub:/fixture-web "$E" 372 passed 'a new approved commit with identical content is transferred and its receipt names the new commit' 373 374 # ---- destinations: interplane.io 375 prepare main-dest; store_main "$B" 376 published "$B" 377 WEBDIR=/fixture-web-two; again; published "$B" 378 grep -q ' fixture-hub:/fixture-web-two/$' "$TEST_ROOT/trace" && grep -q 'destination changed from fixture-hub:/fixture-web to fixture-hub:/fixture-web-two' "$TEST_ROOT/stdout" || fail 'changed interplane.io destination was skipped' 379 receipt interplane.io published fixture-hub:/fixture-web-two "$B" 380 WEBDIR=/fixture-web 381 passed 'interplane.io destination change: the same content is transferred to the new destination and the receipt names it' 382 383 # ---- destinations: hopbot.org, on this machine, by one root command 384 prepare hop-missing; store_main "$B"; STUB_HOP=1; rmdir "$HOPWEBDIR" 385 refused 'Hop release while the hopbot.org folder is missing' 7 'hopbot.org folder is missing' "$B" 386 prepare hop-unnamed; store_main "$B"; STUB_HOP=1; HOPWEBDIR= 387 refused 'Hop release while HOPWEBDIR is empty' 7 'hopbot.org folder is missing' "$B" 388 389 prepare hop; store_main "$B"; STUB_HOP=1 390 published "$B" 391 [ "$(grep -c '^rsync ' "$TEST_ROOT/trace")" -eq 1 ] && [ "$(grep -c '^sudo ' "$TEST_ROOT/trace")" -eq 1 ] || fail 'a Hop release must make one hub transfer and one root copy' 392 grep -Fxq "$(SUDO_LINE)" "$TEST_ROOT/trace" || { cat "$TEST_ROOT/trace" >&2; fail 'the root command is not the one documented command'; } 393 if grep '^rsync ' "$TEST_ROOT/trace" | grep -q hopbot; then fail 'hopbot.org was sent to the hub'; fi 394 cmp "$HOPWEBDIR/index.html" "$LOGDIR/hopbot.stage/index.html" && [ -f "$HOPWEBDIR/install.sh" ] || fail 'the hopbot.org folder does not hold the built page and installer' 395 receipt interplane.io published fixture-hub:/fixture-web "$B" 396 receipt hopbot.org published "local:$HOPWEBDIR" "$B" 397 passed 'Hop release: interplane.io to the hub, hopbot.org to its folder on this machine by the one documented root command, one receipt each' 398 again; published "$B" 399 no_transfer 'unchanged with Hop' 400 passed 'same Hop release again: neither destination is transferred' 401 402 # The reviewer's case: the content was already published when the Hop destination comes into play. 403 prepare enable; store_main "$B" 404 published "$B" 405 [ "$(transfers)" -eq 1 ] && [ ! -e "$LOGDIR/receipt.hopbot.org" ] || fail 'enable-after-skip: unexpected first run' 406 STUB_HOP=1; again; published "$B" 407 grep -q '^.* unchanged: interplane.io' "$TEST_ROOT/stdout" || fail 'enable-after-skip: interplane.io content was unchanged in this control' 408 [ "$(grep -c '^rsync ' "$TEST_ROOT/trace")" -eq 0 ] && [ "$(grep -c '^sudo ' "$TEST_ROOT/trace")" -eq 1 ] || fail 'a newly enabled hopbot.org destination was skipped' 409 receipt hopbot.org published "local:$HOPWEBDIR" "$B" 410 passed 'enable after skip: interplane.io unchanged and skipped, the newly enabled hopbot.org destination is still transferred' 411 412 prepare hop-fail; store_main "$B"; STUB_HOP=1; STUB_SUDO_FAIL=1 413 run "$B" 414 [ "$RC" -eq 8 ] && [ -f "$LOGDIR/pending.hopbot.org" ] && [ ! -e "$LOGDIR/receipt.hopbot.org" ] || fail 'failed root copy: wrong exit, receipt or marker' 415 receipt interplane.io published fixture-hub:/fixture-web "$B" 416 STUB_SUDO_FAIL=0; again; published "$B" 417 [ "$(grep -c '^rsync ' "$TEST_ROOT/trace")" -eq 0 ] && [ "$(grep -c '^sudo ' "$TEST_ROOT/trace")" -eq 1 ] || fail 'retry did not transfer hopbot.org alone' 418 receipt hopbot.org published "local:$HOPWEBDIR" "$B" 419 passed 'a failed root copy exits 8 with interplane.io receipted and hopbot.org pending; the retry transfers hopbot.org alone' 420 421 prepare hop-dest; store_main "$B"; STUB_HOP=1 422 published "$B" 423 OLDHOP=$HOPWEBDIR 424 HOPWEBDIR="$TEST_ROOT/www-hop-dest/hopbot-two"; mkdir -p "$HOPWEBDIR" 425 again; published "$B" 426 [ "$(grep -c '^rsync ' "$TEST_ROOT/trace")" -eq 0 ] && grep -Fxq "$(SUDO_LINE)" "$TEST_ROOT/trace" || fail 'changed hopbot.org destination was skipped' 427 [ -f "$HOPWEBDIR/index.html" ] && [ -f "$OLDHOP/index.html" ] || fail 'destination change: new folder empty or old folder altered' 428 grep -q "destination changed from local:$OLDHOP to local:$HOPWEBDIR" "$TEST_ROOT/stdout" || fail 'the log does not name the destination change' 429 receipt hopbot.org published "local:$HOPWEBDIR" "$B" 430 passed 'hopbot.org destination change: the same content is transferred to the new folder; the old folder is left as it was and the log says so' 431 432 # ---- withdrawal 433 prepare withdraw; store_main "$B"; STUB_HOP=1 434 published "$B" 435 [ -f "$HOPWEBDIR/index.html" ] || fail 'withdrawal control: nothing was published first' 436 STUB_HOP=0; again; published "$B" 437 grep -Fxq "$(SUDO_LINE)" "$TEST_ROOT/trace" || fail 'withdrawal did not use the one documented root command' 438 [ -d "$HOPWEBDIR" ] && [ -z "$(ls -A "$HOPWEBDIR")" ] || fail 'withdrawal left files in the hopbot.org folder' 439 [ "$(field "$LOGDIR/receipt.hopbot.org" state)" = withdrawn ] && [ "$(field "$LOGDIR/receipt.hopbot.org" digest)" = none ] || fail 'no withdrawal record' 440 receipt hopbot.org withdrawn "local:$HOPWEBDIR" "$B" 441 passed 'withdrawal: a commit without a Hop release empties the hopbot.org folder with the same root command and leaves a withdrawal record' 442 again; published "$B" 443 no_transfer 'after withdrawal' 444 passed 'after a withdrawal nothing more is transferred' 445 STUB_HOP=2; again; published "$B" 446 [ "$(grep -c '^sudo ' "$TEST_ROOT/trace")" -eq 1 ] && [ -f "$HOPWEBDIR/index.html" ] || fail 'a Hop release after a withdrawal was not published' 447 receipt hopbot.org published "local:$HOPWEBDIR" "$B" 448 passed 'a Hop release after a withdrawal is published again' 449 450 prepare withdraw-missing; store_main "$B"; STUB_HOP=1 451 published "$B" 452 cp "$LOGDIR/receipt.hopbot.org" "$TEST_ROOT/hop-receipt" 453 STUB_HOP=0; HOPWEBDIR="$TEST_ROOT/www-withdraw-missing/elsewhere"; mkdir -p "$HOPWEBDIR"; again; run "$B" 454 [ "$RC" -eq 7 ] && grep -q 'name that folder in HOPWEBDIR to withdraw it' "$TEST_ROOT/stdout" || fail 'withdrawal from another folder was not refused' 455 no_transfer 'withdrawal from another folder'; cmp "$LOGDIR/receipt.hopbot.org" "$TEST_ROOT/hop-receipt" || fail 'refused withdrawal changed the receipt' 456 HOPWEBDIR="$TEST_ROOT/www-withdraw-missing/hopbot.org"; rm -rf "$HOPWEBDIR"; again; run "$B" 457 [ "$RC" -eq 7 ] && grep -q 'withdrawn and the hopbot.org folder is missing' "$TEST_ROOT/stdout" || fail 'withdrawal with a missing folder was not refused' 458 no_transfer 'withdrawal with a missing folder'; cmp "$LOGDIR/receipt.hopbot.org" "$TEST_ROOT/hop-receipt" || fail 'refused withdrawal changed the receipt' 459 passed 'withdrawal is refused, exit 7, with no transfer and the receipt kept, when HOPWEBDIR names another folder or the folder is missing' 460 461 # ---- the log: a run that names no folder leaves the default (live) folder alone unless it publishes 462 prepare log-default; store_main "$B" 463 OLDHOME=$HOME; HOME="$TEST_ROOT/home-log"; mkdir -p "$HOME"; export HOME 464 LIVE="$HOME/.local/share/interplane-site" 465 unset LOGDIR 466 run "$A" 467 [ "$RC" -eq 5 ] && grep -q 'is not the signed main' "$TEST_ROOT/stdout" || fail "default log folder: expected refusal 5, got $RC" 468 grep -q 'not logged: no log folder was named' "$TEST_ROOT/stderr" || fail 'the refusal does not say that it was not logged' 469 [ ! -e "$LIVE" ] || fail 'a refused run that named no log folder wrote to the default log folder' 470 passed 'no log folder named: a refusal (commit is not the signed main) is printed, exit 5, and the default log folder is not created or written' 471 STUB_QUIET=1; run "$B"; STUB_QUIET=0 472 [ "$RC" -eq 0 ] && [ ! -e "$LIVE" ] || fail 'the quiet-flag skip wrote to the default log folder' 473 passed 'no log folder named: the quiet-flag skip leaves the default log folder alone' 474 NAMEDDIR="$TEST_ROOT/log-named" 475 run --log-dir "$NAMEDDIR" "$A" 476 [ "$RC" -eq 5 ] && grep -q 'refuse: .* is not the signed main' "$NAMEDDIR/sync.log" || fail '--log-dir: the refusal is not in the named log' 477 [ ! -e "$LIVE" ] || fail '--log-dir: the default log folder was written' 478 passed '--log-dir DIR: the same refusal is recorded in DIR/sync.log and the default folder stays untouched' 479 LOGDIR="$TEST_ROOT/log-env"; export LOGDIR 480 run "$A" 481 [ "$RC" -eq 5 ] && grep -q 'refuse: .* is not the signed main' "$LOGDIR/sync.log" || fail 'LOGDIR: the refusal is not in the named log' 482 [ ! -e "$LIVE" ] || fail 'LOGDIR: the default log folder was written' 483 passed 'LOGDIR set: the refusal is recorded there' 484 unset LOGDIR; again 485 run "$B" 486 [ "$RC" -eq 0 ] && [ "$(transfers)" -eq 1 ] || { cat "$TEST_ROOT/stdout" "$TEST_ROOT/stderr" >&2; fail "default log folder: a publish gave $RC"; } 487 grep -q "published interplane.io $B" "$LIVE/sync.log" && [ "$(field "$LIVE/receipt.interplane.io" commit)" = "$B" ] || fail 'a publish with no log folder named did not write the default log and receipt' 488 LINES=$(wc -l < "$LIVE/sync.log"); again; run "$B" 489 [ "$RC" -eq 0 ] && [ "$(transfers)" -eq 0 ] && [ "$(wc -l < "$LIVE/sync.log")" -eq "$LINES" ] || fail 'an unchanged run added a line to the default log' 490 again; run "$A" 491 [ "$RC" -eq 5 ] && [ "$(wc -l < "$LIVE/sync.log")" -eq "$LINES" ] || fail 'a refusal after a publish added a line to the default log' 492 passed 'no log folder named: a publish writes the default log and receipt; a later unchanged run and a later refusal add no line to it' 493 HOME=$OLDHOME; export HOME 494 LOGDIR="$TEST_ROOT/log-after"; export LOGDIR 495 496 # ---- the default compiler lookup is local and still passes the checksum gate 497 prepare default-compiler; store_main "$B" 498 OMEGA_SRC="$TEST_ROOT/omega" 499 export OMEGA_SRC 500 mkdir -p "$OMEGA_SRC/seed/out" 501 cp "$TEST_ROOT/compiler" "$OMEGA_SRC/seed/out/omc" 502 unset OMC 503 published "$B" 504 [ "$(transfers)" -eq 1 ] || fail 'default compiler lookup did not publish' 505 passed 'default compiler lookup' 506 507 printf 'RESULT pass=%d fail=0 (publisher controls; git is real and local, ipl, compiler, builder, rsync and sudo are stubbed)\n' "$N"