Skip to content

A JSON test skipped for missing jq is reported under a framework function name #1223

Description

@Chemaclass

Problem

When jq is not installed, JSON assertions skip the test — documented, and correct. The report names the wrong function:

$ bashunit --no-parallel multi_test.sh          # with jq absent from PATH
↷ Skipped: Bashunit::assert json::require jq    jq is required for JSON assertions
↷ Skipped: Bashunit::assert json::require jq    jq is required for JSON assertions
↷ Skipped: Plain one                            no database
Tests:      3 skipped, 3 total

The first two are test_user_has_a_name and test_order_has_an_id. Both render as the internal helper bashunit::assert_json::require_jq, so they are indistinguishable from each other and from any other JSON test. A user-level bashunit::skip on the third test names its test correctly.

On a machine without jq, a suite with twenty JSON tests prints the same internal name twenty times, and --show-skipped output tells you nothing about which tests did not run.

Cause

bashunit::skip resolves the label at FUNCNAME[2], which is the test function when a test calls it directly. src/assert/json.sh:5 calls it from bashunit::assert_json::require_jq, two frames deeper (test → assert_json_*require_jq), so frame 2 is the helper.

src/api/skip_todo.sh already documents the convention — "every public helper states its own distance to the test function" — and bashunit::skip::__mark takes that depth as $2. The JSON helper is the one caller that does not state it.

The runner's # @skip annotation path is unaffected: it uses __mark_with_label with an explicit label.

Suggested fix

Have require_jq state its depth. All four call sites (assert_json_key_exists, assert_json_key_not_exists, assert_json_equals, assert_json_contains) are the same distance from the test, so one depth covers them.

Verified correct nearby

The skip itself behaves as docs/installation.md documents: the test is skipped rather than failed, and the run exits 0. Also verified in that guide: the Bash 3.0 floor matches the enforced gate, all six GitHub Action inputs and both outputs match action.yml including defaults, both completion scripts load and register, upgrade prints > You are already on latest version, the npm package ships only the binary and npm test propagates a failing suite as exit 1, and the brew/MacPorts/nixpkgs/bashdep packages all exist upstream.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions