-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate JSON for --jsonarg #2658
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,19 @@ fi | |
echo '{"a":1,"b",' | $JQ --stream > /dev/null 2> $d/err | ||
grep 'Objects must consist of key:value pairs' $d/err > /dev/null | ||
|
||
## Regression test for issue #2572 assert when using --jsonargs and invalid JSON | ||
$JQ -n --jsonargs null invalid && EC=$? || EC=$? | ||
if [ "$EC" -ne 2 ]; then | ||
echo "--jsonargs exited with wrong exit code, expected 2 got $EC" 1>&2 | ||
exit 1 | ||
fi | ||
# this tests the args_done code path "--" | ||
$JQ -n --jsonargs null -- invalid && EC=$? || EC=$? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this should be exit 2 (usage error?) or invalid input error? I also noticed that we skip using $VALGRIND is some places, should we fix that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're not very consistent regarding exit status codes. It'd be nice if a) we documented And yes, we should fix the non-use of valgrind, but we should do so separately. |
||
if [ "$EC" -ne 2 ]; then | ||
echo "--jsonargs exited with wrong exit code, expected 2 got $EC" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
## Fuzz parser | ||
|
||
## XXX With a $(urandom) builtin we could move this test into tests/all.test | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of duplication here. I guess one could extract to some kind of parse_or_die function? could be use for
--argjson
code also. Maybe for later?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, it's fine.