jq
The atago project wrote these specs on its own initiative and runs them in its own CI, to exercise atago against a real program. They are not jq’s official test suite, and the jq project is not affiliated with atago.
Summary #
2 suites · 11 scenarios
Contents #
- jq (uncovered contracts — unicode passthrough + empty validation) — 2 scenarios
- jq (third-party CLI, no build required) — 9 scenarios
- identity filter echoes the document from stdin
- sort-keys output is deterministic and exact
- raw output strips JSON quoting
- arguments flow in with –arg
- reduce aggregates an array
- -e exits 1 when the result is false
- a program that does not compile exits 3 with a diagnostic on stderr
- invalid JSON input fails loudly and keeps stdout clean
- streaming several documents produces one result per document
jq (uncovered contracts — unicode passthrough + empty validation) #
Source: test/e2e/thirdparty/jq/extra.atago.yaml
Scenario: multibyte unicode passes through unchanged #
Inputs #
stdin for jq:
{"s":"café 😀 日本語"}
When #
jq -c .
Then #
- exit code is
0 - stdout equals an exact value
Scenario: jq empty validates JSON — silent success, loud failure #
Inputs #
stdin for jq:
{"a":1,"b":[2,3]}
stdin for jq:
not json
When #
jq empty
jq empty
Then #
- after
jq empty:- exit code is
0 - stdout is empty
- stderr is empty
- exit code is
- after
jq empty:- exit code is one of
4,5 - stdout is empty
- stderr contains
parse error
- exit code is one of
jq (third-party CLI, no build required) #
Source: test/e2e/thirdparty/jq/jq.atago.yaml
Scenario: identity filter echoes the document from stdin #
Inputs #
stdin for jq:
{"b":2,"a":1}
When #
jq -c .
Then #
- exit code is
0 - stdout at
$.aequals1 - stderr is empty
Scenario: sort-keys output is deterministic and exact #
Given #
- Fixture file
input.jsonis created.
Inputs #
Fixture input.json:
{"b":2,"a":1}
stdin for jq:
(read from file input.json)
When #
jq -c --sort-keys .
Then #
- exit code is
0 - stdout equals an exact value
Scenario: raw output strips JSON quoting #
Given #
- Fixture file
user.jsonis created.
Inputs #
Fixture user.json:
{"name":"alice","admin":true}
When #
jq -r .name user.json
Then #
- exit code is
0 - stdout equals an exact value
Scenario: arguments flow in with –arg #
Inputs #
stdin for jq:
null
When #
jq -c --arg who atago '{greeting: ("hello " + $who)}'
Then #
- exit code is
0 - stdout at
$.greetingequalshello atago
Scenario: reduce aggregates an array #
Given #
- Fixture file
nums.jsonis created.
Inputs #
Fixture nums.json:
[1,2,3,4,5]
When #
jq 'reduce .[] as $n (0; . + $n)' nums.json
Then #
- exit code is
0 - stdout equals an exact value
Scenario: -e exits 1 when the result is false #
Inputs #
stdin for jq:
{"present":1}
When #
jq -e '.missing'
Then #
- exit code is
1
Scenario: a program that does not compile exits 3 with a diagnostic on stderr #
Inputs #
stdin for jq:
{}
When #
jq '.foo['
Then #
- exit code is
3 - stdout is empty
- stderr contains
error
Scenario: invalid JSON input fails loudly and keeps stdout clean #
Inputs #
stdin for jq:
not json at all
When #
jq .
Then #
- exit code is not
0 - stderr contains
parse error
Scenario: streaming several documents produces one result per document #
Inputs #
stdin for jq:
{"n":1}
{"n":2}
When #
jq -c '.n * 2'
Then #
- exit code is
0 - stdout equals an exact value
- stdout equals an exact value