summaryrefslogtreecommitdiff
path: root/tests/ranking.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2026-06-12 09:19:28 -0300
committerEuAndreh <eu@euandre.org>2026-06-12 09:19:28 -0300
commit46fd0362bce11d709e5efe6d540358533985d363 (patch)
treef77d2ed33c4f3fb6e85353e436efca4e19028f73 /tests/ranking.sh
parentrm .tdrc COPYING (diff)
downloadremembering-46fd0362bce11d709e5efe6d540358533985d363.tar.gz
remembering-46fd0362bce11d709e5efe6d540358533985d363.tar.xz
Rewrite remembering in Go
The shell pipeline (sed | sort | tee | awk | sort | cut | "$@" plus the cut | uniq | awk profile rewrite) becomes a single static binary with the same observable behaviour, pinned by the original ranking.sh, signals.sh and cli-opts.sh suites, now aimed at remembering.bin: - the profile keeps the exact on-disk format, COUNT profile TEXT, byte-sorted with new picks appended at 1 and offered-but-never- picked entries persisted at 0; - the menu stays count-descending with byte-order ties, stdin alone defines what is offered, and duplicate profile lines sum for ranking but collapse to the highest count on rewrite, as sort | uniq -f1 did; - the wrapped command's exit status is forwarded as-is (128+sig for signal deaths), its stderr passes through, and an empty pick learns nothing; - the profile rewrite stays atomic via .tmp plus rename. Per the house CLI conventions, -h/-V/--help/--version are gone (the manpage is the documentation; bad options print the usage on stderr and exit 2), and getopts-style attached option arguments (-pNAME) are not accepted any more --- no script in the wild used them. The project layout follows rot: raw go tool compile/link Makefile, mkdeps.sh-generated deps.mk, white-box unit suite, fuzz target over the profile parse/serialize roundtrip, functional pick roundtrip, a 1M-line ranking benchmark, and a single English asciidoc manpage absorbing the old .5 page; the po4a/aux release machinery goes away. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'tests/ranking.sh')
-rwxr-xr-xtests/ranking.sh12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/ranking.sh b/tests/ranking.sh
index af26c94..45cb0ec 100755
--- a/tests/ranking.sh
+++ b/tests/ranking.sh
@@ -3,6 +3,8 @@ set -eu
. tests/lib.sh
+REMEMBERING="$PWD/remembering.bin"
+
export XDG_DATA_HOME="$PWD/tests/test-profiles"
export LANG=C.UTF-8
@@ -38,7 +40,7 @@ pick_x() {
PICK="$1"
echo "${2:-$INPUT}" | \
- ./src/remembering \
+ "$REMEMBERING" \
-p "$PROFILE" \
-- sh -c "tee -a /dev/stderr | grep -F \"$PICK\"" \
1>"$OUT" 2>"$ERR"
@@ -83,7 +85,7 @@ test_picking_first_makes_it_be_always_first() {
PROFILE="always-picks-first-$(uuid)"
for _ in $(seq 10); do
printf 'always-picked\nnever-picked\n' | \
- ./src/remembering \
+ "$REMEMBERING" \
-p "$PROFILE" \
-- head -n1 \
1>"$OUT" 2>"$ERR"
@@ -203,7 +205,7 @@ d
e'
echo "$INPUT" | \
- ./src/remembering \
+ "$REMEMBERING" \
-p "$PROFILE" \
-- echo f \
1>"$OUT" 2>"$ERR"
@@ -277,7 +279,7 @@ test_stdin_is_empty() {
ERR="$(mkstemp)"
printf '' | \
- ./src/remembering \
+ "$REMEMBERING" \
-p "$PROFILE" \
-- sh -c 'tee -a /dev/stderr | head -n1' \
1>"$OUT" 2>"$ERR"
@@ -340,7 +342,7 @@ test_really_long_list() {
PROFILE="really-long-list-$(uuid)"
N=999999
seq "$N" | \
- ./src/remembering \
+ "$REMEMBERING" \
-p "$PROFILE" \
-- tail -n1 \
1>"$OUT" 2>"$ERR"