. "$BST_LIB" require jq jq/present tmp=${TMPDIR:-/tmp}/bst-jq.$$ printf '{"a":1,"b":[10,20],"s":"Hello"}\n' > "$tmp.json" # real jq (the meta-oe package), not a stub. jq's compiled-in version string is # empty in this build ("jq-" with no number; jq --help shows "[version ]") -- a jq # packaging quirk, not a wasm32-hwjs fault, and jq is otherwise fully functional. # Identity is asserted on the help banner, which names the tool, rather than the # (empty) version string. check_out jq/identity "commandline JSON processor" sh -c "jq --help 2>&1" # the ticket's headline check: echo '{"a":1}' | jq .a -> 1 (stdin/pipe form) check_out jq/field-pipe "1" sh -c "echo '{\"a\":1}' | jq '.a'" # object field + array index read from a file, -r raw output check_out jq/field "1" jq -r ".a" "$tmp.json" check_out jq/index "20" jq -r ".b[1]" "$tmp.json" # a slurp/aggregate program -- exercises the VM beyond a single path lookup check_out jq/aggregate "30" sh -c "echo '[10,20]' | jq 'add'" # oniguruma regex builtins are gated: jq is built --without-oniguruma because # onig's disable_noname_group_capture VLA-escape is REFUSED by the wasm32-hwjs # coroutinize pass. test/1 therefore is unavailable. Recorded skip; flips to ok # on its own the day onig can be re-enabled (a tripwire for that toolchain fix). if echo '"Hello"' | jq -e 'test("^H")' >/dev/null 2>&1; then bst_ok jq/regex-onig else bst_skip jq/regex-onig "jq built --without-oniguruma (onig VLA-escape REFUSED by wasm32-hwjs coroutinize pass)" fi # a jq program compile error exits 3 (jq's documented status for an invalid program) check_rc jq/badprog 3 sh -c "echo '{}' | jq '.['" rm -f "$tmp.json"