Skip to content

Commit 391e70c

Browse files
committed
test(assert): drop jq from flaky custom-assertion test
The 'custom assertion with fail shows correct test name' test was the only one of its three siblings to shell out to jq, and the only one that flaked on the macOS CI runner (empty/mismatched captured output) while the two pure-bash siblings never did. Route the failure through bashunit::fail with a pure-bash json check so the test no longer depends on an external binary.
1 parent a8ad5fb commit 391e70c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tests/unit/custom_assertions_test.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
#!/usr/bin/env bash
22

3-
# Custom assertion that uses fail internally
3+
# Custom assertion that uses fail internally.
4+
# jq-free on purpose: this scaffolding only needs to route a failure through
5+
# bashunit::fail deterministically; depending on the external jq binary made the
6+
# test flaky on the macOS CI runner while the pure-bash sibling tests never were.
47
function _assert_valid_json() {
58
local json="$1"
69

7-
if ! echo "$json" | jq . >/dev/null 2>&1; then
10+
case "$json" in
11+
'{'*'}' | '['*']') bashunit::state::add_assertions_passed ;;
12+
*)
813
bashunit::fail "Invalid json: $json"
914
return
10-
fi
11-
12-
bashunit::state::add_assertions_passed
15+
;;
16+
esac
1317
}
1418

1519
# Custom assertion that uses bashunit::assertion_failed

0 commit comments

Comments
 (0)