b0698e0a66
`tools/` is for libraries (arti-build); shell-based interop harnesses
that drive the `amy` binary belong with the CLI module. New layout:
cli/tests/
├── lib.sh # shared logging + result tracking
├── headless/helpers.sh # shared amy_a / amy_json / assertions
├── marmot/ # MLS group-messaging interop (vs whitenoise-rs)
│ ├── marmot-interop.sh
│ ├── marmot-interop-headless.sh
│ ├── setup.sh
│ ├── tests-create.sh
│ ├── tests-manage.sh
│ ├── tests-extras.sh
│ └── patches/
└── dm/ # NIP-17 DM interop (amy ↔ amy)
├── dm-interop-headless.sh
├── setup.sh
└── tests-dm.sh
Per-suite changes:
- Each suite owns its own setup.sh; previously the Marmot setup was at
headless/setup.sh and the DM setup at headless/setup-dm.sh, which
implied shared infra they don't actually share.
- `cli/tests/lib.sh` and `cli/tests/headless/helpers.sh` are the only
shared bits across suites.
- The DM harness still reuses Marmot's `start_local_relay` /
`stop_local_relay` (sourced via `../marmot/setup.sh`) — same relay
binary, no duplication.
- All sourcing paths updated; REPO_ROOT now climbs three levels (was
two when the harness lived under `tools/`); patches/ is now a sibling
of marmot/setup.sh rather than under marmot/headless/.
- `.gitignore` updated to cover both suites' state dirs.
cli/ROADMAP.md and cli/tests/README.md updated to point at the new paths.
No behavioural change — every test runs the same code; only the file
layout and source paths moved.
56 lines
1.8 KiB
Bash
56 lines
1.8 KiB
Bash
# shellcheck shell=bash
|
|
#
|
|
# helpers.sh — thin wrappers that keep the per-test code tight.
|
|
|
|
# --- amy wrapper -------------------------------------------------------------
|
|
amy_a() { "$AMY_BIN" --data-dir "$A_DIR" "$@"; }
|
|
|
|
# Run amy, log stderr, surface JSON on stdout, remember last result.
|
|
amy_json() {
|
|
local out
|
|
if ! out=$(amy_a "$@" 2>>"$LOG_FILE"); then
|
|
fail_msg "amy $*: exit $? (see $LOG_FILE)"
|
|
printf '%s\n' "$out" >>"$LOG_FILE"
|
|
return 1
|
|
fi
|
|
printf '%s' "$out"
|
|
}
|
|
|
|
# Convenience extractors — the CLI emits one JSON object per success so we can
|
|
# jq with impunity.
|
|
amy_field() {
|
|
# usage: amy_field '.group_id' init [args...]
|
|
local path="$1"; shift
|
|
amy_json "$@" | jq -r "$path"
|
|
}
|
|
|
|
# --- assertion helpers -------------------------------------------------------
|
|
# Assert a substring is present in a variable; append a failed result on miss
|
|
# and return 1. Positive case just logs.
|
|
assert_contains() {
|
|
local haystack="$1" needle="$2" test_id="$3" note="${4:-}"
|
|
if [[ "$haystack" == *"$needle"* ]]; then
|
|
info "assertion hit: $test_id contains \"$needle\""
|
|
return 0
|
|
fi
|
|
fail_msg "$test_id: missing \"$needle\" (${note:-no note})"
|
|
info "actual: $haystack"
|
|
record_result "$test_id" fail "${note:-missing \"$needle\"}"
|
|
return 1
|
|
}
|
|
|
|
# Assert two strings are equal (leniently trimmed).
|
|
assert_eq() {
|
|
local actual="$1" expected="$2" test_id="$3" note="${4:-}"
|
|
if [[ "${actual// /}" == "${expected// /}" ]]; then
|
|
info "assertion hit: $test_id \"$actual\" == \"$expected\""
|
|
return 0
|
|
fi
|
|
fail_msg "$test_id: expected \"$expected\", got \"$actual\" (${note:-})"
|
|
record_result "$test_id" fail "${note:-mismatch}"
|
|
return 1
|
|
}
|
|
|
|
# --- wn-side pollers (delegates to lib.sh) -----------------------------------
|
|
# Both exist in lib.sh already; this file only adds headless-specific niceties.
|