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-forge/blob/main/collab/tests/issue-title.sh # interplane-forge INTERPLANE Forge 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-forge / collab / tests / issue-title.sh` 88 lines ยท 6684 bytes Raw Blame History 1 #!/bin/bash 2 # ORACLE: host test driver (bash + curl + rad + iconv), not product code. 3 # collab/tests/issue-title.sh: an issue whose title is longer than the 256-byte page title must not end 4 # forged (coittl, collab/co5iss.om), and the cut title must stay valid UTF-8 (cottlcut, collab/co4pat.om). 5 # Everything is private to a temp dir: a throwaway Radicle profile (RAD_HOME) with one private repo and 6 # one issue whose 401-byte title has 3-byte characters across byte 256, and a test forged on PORT 7 # (default 18499) whose store and allow-list point at that profile. Nothing touches ~/.radicle. 8 # A patch with the same title covers copttl the same way (added after the second review of `486f1cd8`). 9 # Negative controls: without cottlcut the title element is not valid UTF-8; without the cap in coittl 10 # the same request exits 104 (trap 4). 11 # Usage: collab/tests/issue-title.sh (CORES default 14; ISSUE_TITLE_PORT; KEEP=1 keeps the temp dir) 12 set -u 13 H=$(cd "$(dirname "$0")" && pwd) 14 export PORT=${ISSUE_TITLE_PORT:-18499} CORES=${CORES:-14} 15 T=$(mktemp -d /tmp/cpititle.XXXXXX); W=$T/w 16 PASS=0; FAIL=0; PID= 17 ok() { PASS=$((PASS+1)); echo "PASS $*"; } 18 bad() { FAIL=$((FAIL+1)); echo "FAIL $*"; } 19 check() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: want $2, got $1"; fi; } 20 trap '[ -n "$PID" ] && kill $PID 2>/dev/null; wait 2>/dev/null; [ -n "${KEEP:-}" ] || rm -rf "$T"' EXIT 21 if ss -ltn | grep -q "127.0.0.1:$PORT "; then echo "NOT_RUN: port $PORT busy"; exit 3; fi 22 export RAD_HOME=$T/rad RAD_PASSPHRASE= 23 rad auth --alias cptitle < /dev/null > /dev/null 2>&1 || { echo "rad auth failed"; exit 1; } 24 git init -q -b main "$W" && cd "$W" && echo hi > a.txt && git add a.txt \ 25 && git -c user.name=t -c user.email=t@t.invalid commit -qm init \ 26 && rad init --private --name cpititle --description "issue title test" --default-branch main --no-confirm --no-seed > /dev/null 2>&1 \ 27 || { echo "rad init failed"; exit 1; } 28 RID=$(rad . | sed 's/^rad://') 29 # 254 ASCII bytes, then 49 euro signs (e2 82 ac): byte 256 is inside the first one; 401 bytes in all 30 TITLE="$(printf 'x%.0s' $(seq 254))$(printf '\xe2\x82\xac%.0s' $(seq 49))" 31 check "$(printf '%s' "$TITLE" | LC_ALL=C wc -c)" 401 "fixture: title bytes" 32 rad issue open --repo "rad:$RID" --title "$TITLE" --description body --no-announce > "$T/open.out" 2>&1 \ 33 || { echo "rad issue open failed: $(cat "$T/open.out")"; exit 1; } 34 ISS=$(git -C "$RAD_HOME/storage/$RID" for-each-ref --format='%(refname)' 'refs/namespaces/*/refs/cobs/xyz.radicle.issue/*' | head -1 | sed 's|.*/||') 35 [ -n "$ISS" ] || { echo "issue id not found in $RAD_HOME/storage/$RID"; exit 1; } 36 # the patch: pushed with a short message, then given the title, because git quotes a push option 37 # that holds bytes outside ASCII and the remote helper does not read the quoted form 38 git checkout -q -b f1 && echo b > b.txt && git add b.txt && git -c user.name=t -c user.email=t@t.invalid commit -qm second \ 39 && git push -o patch.message=short rad HEAD:refs/patches > "$T/push.out" 2>&1 || { echo "patch push failed: $(cat "$T/push.out")"; exit 1; } 40 PAT=$(git -C "$RAD_HOME/storage/$RID" for-each-ref --format='%(refname)' 'refs/namespaces/*/refs/cobs/xyz.radicle.patch/*' | head -1 | sed 's|.*/||') 41 [ -n "$PAT" ] || { echo "patch id not found in $RAD_HOME/storage/$RID"; exit 1; } 42 rad patch edit "$PAT" --repo "rad:$RID" --no-announce --message "$TITLE" --message body > "$T/edit.out" 2>&1 \ 43 || { echo "rad patch edit failed: $(cat "$T/edit.out")"; exit 1; } 44 PP=/drakestapleton/cpititle/patches/$PAT 45 printf '# test allow-list\n\n| repo | RID | default branch |\n|---|---|---|\n| cpititle | rad:%s | main |\n' "$RID" > "$T/rids.md" 46 mkdir -p "$T/data" "$T/social" 47 start() { # start OUT [SEDX]: build and start a test forged; PID set 48 DATA=$T/data/ STORE=$RAD_HOME/storage/ RIDS=$T/rids.md SEDX=${2:-} "$H/tbuild.sh" "$1" || return 1 49 FORGE_SOCIAL_DIR=$T/social/ taskset -c "$CORES" nice -n 10 "$1" 2>> "$1.log" & 50 PID=$! 51 for _ in $(seq 50); do curl -s -o /dev/null "http://127.0.0.1:$PORT/explore" && return 0; sleep 0.1; done 52 return 1 53 } 54 stop() { kill $PID 2> /dev/null; wait $PID 2> /dev/null; PID=; sleep 0.3; } 55 # title BODY -> the bytes inside