separate jq, oniguruma, sh, and man tests
This commit is contained in:
1 parent
292f2d3208
commit
1146b8b84a
9 files changed
+172
-156
No files matched your search
+1
-1
@@ -40,7 +40,7 @@ m4/ltoptions.m4
|
|||||||
m4/ltsugar.m4
|
m4/ltsugar.m4
|
||||||
m4/ltversion.m4
|
m4/ltversion.m4
|
||||||
m4/lt~obsolete.m4
|
m4/lt~obsolete.m4
|
||||||
tests/all.trs
|
tests/*.trs
|
||||||
|
|
||||||
cscope.in.out
|
cscope.in.out
|
||||||
cscope.out
|
cscope.out
|
||||||
|
|||||||
+1
-2
@@ -79,8 +79,7 @@ endif
|
|||||||
|
|
||||||
### Tests (make check)
|
### Tests (make check)
|
||||||
|
|
||||||
TESTS = tests/all.test
|
TESTS = tests/mantest tests/jqtest tests/onigtest tests/shtest
|
||||||
TEST_LOG_COMPILER = ${srcdir}/tests/run
|
|
||||||
|
|
||||||
|
|
||||||
### Building the manpage
|
### Building the manpage
|
||||||
|
|||||||
@@ -874,79 +874,6 @@ null
|
|||||||
["fo", "foo", "barfoo", "foobar", "barfoob"]
|
["fo", "foo", "barfoo", "foobar", "barfoob"]
|
||||||
[false, true, true, false, false]
|
[false, true, true, false, false]
|
||||||
|
|
||||||
# match builtin
|
|
||||||
[match("( )*"; "g")]
|
|
||||||
"abc"
|
|
||||||
[{"offset":0, "length":0, "string":"", "captures":[]},{"offset":1, "length":0, "string":"", "captures":[]},{"offset":2, "length":0, "string":"", "captures":[]}]
|
|
||||||
|
|
||||||
[match("( )*"; "gn")]
|
|
||||||
"abc"
|
|
||||||
[]
|
|
||||||
|
|
||||||
[match("a"; "gi")]
|
|
||||||
"āáàä"
|
|
||||||
[]
|
|
||||||
|
|
||||||
[match(["(bar)"])]
|
|
||||||
"foo bar"
|
|
||||||
[{"offset": 4, "length": 3, "string": "bar", "captures":[{"offset": 4, "length": 3, "string": "bar", "name": null}]}]
|
|
||||||
|
|
||||||
# offsets account for combining codepoints and multi-byte UTF-8
|
|
||||||
[match("bar")]
|
|
||||||
"ā bar with a combining codepoint U+0304"
|
|
||||||
[{"offset": 3, "length": 3, "string": "bar", "captures":[]}]
|
|
||||||
|
|
||||||
# matches with combining codepoints still count them in their length
|
|
||||||
[match("bār")]
|
|
||||||
"a bār"
|
|
||||||
[{"offset": 2, "length": 4, "string": "bār", "captures":[]}]
|
|
||||||
|
|
||||||
[match(".+?\\b")]
|
|
||||||
"ā two-codepoint grapheme"
|
|
||||||
[{"offset": 0, "length": 2, "string": "ā", "captures":[]}]
|
|
||||||
|
|
||||||
[match(["foo (?<bar123>bar)? foo", "ig"])]
|
|
||||||
"foo bar foo foo foo"
|
|
||||||
[{"offset": 0, "length": 11, "string": "foo bar foo", "captures":[{"offset": 4, "length": 3, "string": "bar", "name": "bar123"}]},{"offset":12, "length": 8, "string": "foo foo", "captures":[{"offset": -1, "length": 0, "string": null, "name": "bar123"}]}]
|
|
||||||
|
|
||||||
#test builtin
|
|
||||||
[test("( )*"; "gn")]
|
|
||||||
"abc"
|
|
||||||
[false]
|
|
||||||
|
|
||||||
[test("ā")]
|
|
||||||
"ā"
|
|
||||||
[true]
|
|
||||||
|
|
||||||
capture("(?<a>[a-z]+)-(?<n>[0-9]+)")
|
|
||||||
"xyzzy-14"
|
|
||||||
{"a":"xyzzy","n":"14"}
|
|
||||||
|
|
||||||
|
|
||||||
# jq-coded utilities built on match:
|
|
||||||
#
|
|
||||||
# The second element in these tests' inputs tests the case where the
|
|
||||||
# fromstring matches both the head and tail of the string
|
|
||||||
[.[] | sub(", "; ":")]
|
|
||||||
["a,b, c, d, e,f", ", a,b, c, d, e,f, "]
|
|
||||||
["a,b:c, d, e,f",":a,b, c, d, e,f, "]
|
|
||||||
|
|
||||||
sub("^(?<head>.)"; "Head=\(.head) Tail=")
|
|
||||||
"abcdef"
|
|
||||||
"Head=a Tail=bcdef"
|
|
||||||
|
|
||||||
[.[] | gsub(", "; ":")]
|
|
||||||
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
|
||||||
["a,b:c:d:e,f",":a,b:c:d:e,f:"]
|
|
||||||
|
|
||||||
gsub("(?<d>\\d)"; ":\(.d);")
|
|
||||||
"a1b2"
|
|
||||||
"a:1;b:2;"
|
|
||||||
|
|
||||||
[.[] | scan(", ")]
|
|
||||||
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
|
||||||
[", ",", ",", ",", ",", ",", ",", ",", "]
|
|
||||||
|
|
||||||
[.[] | split(", ")]
|
[.[] | split(", ")]
|
||||||
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
||||||
[["a,b","c","d","e,f"],["","a,b","c","d","e,f",""]]
|
[["a,b","c","d","e,f"],["","a,b","c","d","e,f",""]]
|
||||||
@@ -955,20 +882,6 @@ split("")
|
|||||||
"abc"
|
"abc"
|
||||||
["a","b","c"]
|
["a","b","c"]
|
||||||
|
|
||||||
########################
|
|
||||||
[.[]|[[sub(", *";":")], [gsub(", *";":")], [scan(", *")]]]
|
|
||||||
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
|
||||||
[[["a:b, c, d, e,f"],["a:b:c:d:e:f"],[",",", ",", ",", ",","]],[[":a,b, c, d, e,f, "],[":a:b:c:d:e:f:"],[", ",",",", ",", ",", ",",",", "]]]
|
|
||||||
|
|
||||||
[.[]|[[sub(", +";":")], [gsub(", +";":")], [scan(", +")]]]
|
|
||||||
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
|
||||||
[[["a,b:c, d, e,f"],["a,b:c:d:e,f"],[", ",", ",", "]],[[":a,b, c, d, e,f, "],[":a,b:c:d:e,f:"],[", ",", ",", ",", ",", "]]]
|
|
||||||
|
|
||||||
# reference to named captures
|
|
||||||
gsub("(?<x>.)[^a]*"; "+\(.x)-")
|
|
||||||
"Abcabc"
|
|
||||||
"+A-+a-"
|
|
||||||
|
|
||||||
[.[]|ltrimstr("foo")]
|
[.[]|ltrimstr("foo")]
|
||||||
["fo", "foo", "barfoo", "foobar", "afoo"]
|
["fo", "foo", "barfoo", "foobar", "afoo"]
|
||||||
["fo","","barfoo","bar","afoo"]
|
["fo","","barfoo","bar","afoo"]
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. "${0%/*}/setup"
|
||||||
|
|
||||||
|
$VALGRIND $Q $JQ -L "$mods" --run-tests $JQTESTDIR/jq.test
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. "${0%/*}/setup"
|
||||||
|
|
||||||
|
(cd $JQBASEDIR/docs && rake mantests) | $VALGRIND $Q $JQ -L "$mods" --run-tests
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
# match builtin
|
||||||
|
[match("( )*"; "g")]
|
||||||
|
"abc"
|
||||||
|
[{"offset":0, "length":0, "string":"", "captures":[]},{"offset":1, "length":0, "string":"", "captures":[]},{"offset":2, "length":0, "string":"", "captures":[]}]
|
||||||
|
|
||||||
|
[match("( )*"; "gn")]
|
||||||
|
"abc"
|
||||||
|
[]
|
||||||
|
|
||||||
|
[match("a"; "gi")]
|
||||||
|
"āáàä"
|
||||||
|
[]
|
||||||
|
|
||||||
|
[match(["(bar)"])]
|
||||||
|
"foo bar"
|
||||||
|
[{"offset": 4, "length": 3, "string": "bar", "captures":[{"offset": 4, "length": 3, "string": "bar", "name": null}]}]
|
||||||
|
|
||||||
|
# offsets account for combining codepoints and multi-byte UTF-8
|
||||||
|
[match("bar")]
|
||||||
|
"ā bar with a combining codepoint U+0304"
|
||||||
|
[{"offset": 3, "length": 3, "string": "bar", "captures":[]}]
|
||||||
|
|
||||||
|
# matches with combining codepoints still count them in their length
|
||||||
|
[match("bār")]
|
||||||
|
"a bār"
|
||||||
|
[{"offset": 2, "length": 4, "string": "bār", "captures":[]}]
|
||||||
|
|
||||||
|
[match(".+?\\b")]
|
||||||
|
"ā two-codepoint grapheme"
|
||||||
|
[{"offset": 0, "length": 2, "string": "ā", "captures":[]}]
|
||||||
|
|
||||||
|
[match(["foo (?<bar123>bar)? foo", "ig"])]
|
||||||
|
"foo bar foo foo foo"
|
||||||
|
[{"offset": 0, "length": 11, "string": "foo bar foo", "captures":[{"offset": 4, "length": 3, "string": "bar", "name": "bar123"}]},{"offset":12, "length": 8, "string": "foo foo", "captures":[{"offset": -1, "length": 0, "string": null, "name": "bar123"}]}]
|
||||||
|
|
||||||
|
#test builtin
|
||||||
|
[test("( )*"; "gn")]
|
||||||
|
"abc"
|
||||||
|
[false]
|
||||||
|
|
||||||
|
[test("ā")]
|
||||||
|
"ā"
|
||||||
|
[true]
|
||||||
|
|
||||||
|
capture("(?<a>[a-z]+)-(?<n>[0-9]+)")
|
||||||
|
"xyzzy-14"
|
||||||
|
{"a":"xyzzy","n":"14"}
|
||||||
|
|
||||||
|
|
||||||
|
# jq-coded utilities built on match:
|
||||||
|
#
|
||||||
|
# The second element in these tests' inputs tests the case where the
|
||||||
|
# fromstring matches both the head and tail of the string
|
||||||
|
[.[] | sub(", "; ":")]
|
||||||
|
["a,b, c, d, e,f", ", a,b, c, d, e,f, "]
|
||||||
|
["a,b:c, d, e,f",":a,b, c, d, e,f, "]
|
||||||
|
|
||||||
|
sub("^(?<head>.)"; "Head=\(.head) Tail=")
|
||||||
|
"abcdef"
|
||||||
|
"Head=a Tail=bcdef"
|
||||||
|
|
||||||
|
[.[] | gsub(", "; ":")]
|
||||||
|
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
||||||
|
["a,b:c:d:e,f",":a,b:c:d:e,f:"]
|
||||||
|
|
||||||
|
gsub("(?<d>\\d)"; ":\(.d);")
|
||||||
|
"a1b2"
|
||||||
|
"a:1;b:2;"
|
||||||
|
|
||||||
|
[.[] | scan(", ")]
|
||||||
|
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
||||||
|
[", ",", ",", ",", ",", ",", ",", ",", "]
|
||||||
|
|
||||||
|
[.[]|[[sub(", *";":")], [gsub(", *";":")], [scan(", *")]]]
|
||||||
|
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
||||||
|
[[["a:b, c, d, e,f"],["a:b:c:d:e:f"],[",",", ",", ",", ",","]],[[":a,b, c, d, e,f, "],[":a:b:c:d:e:f:"],[", ",",",", ",", ",", ",",",", "]]]
|
||||||
|
|
||||||
|
[.[]|[[sub(", +";":")], [gsub(", +";":")], [scan(", +")]]]
|
||||||
|
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
||||||
|
[[["a,b:c, d, e,f"],["a,b:c:d:e,f"],[", ",", ",", "]],[[":a,b, c, d, e,f, "],[":a,b:c:d:e,f:"],[", ",", ",", ",", ",", "]]]
|
||||||
|
|
||||||
|
# reference to named captures
|
||||||
|
gsub("(?<x>.)[^a]*"; "+\(.x)-")
|
||||||
|
"Abcabc"
|
||||||
|
"+A-+a-"
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. "${0%/*}/setup"
|
||||||
|
|
||||||
|
$VALGRIND $Q $JQ -L "$mods" --run-tests $JQTESTDIR/onig.test
|
||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
JQTESTDIR=$(cd "$(dirname "$0")" && pwd)
|
||||||
|
JQBASEDIR=$JQTESTDIR/..
|
||||||
|
JQ=$JQBASEDIR/jq
|
||||||
|
|
||||||
|
if which valgrind > /dev/null; then
|
||||||
|
VALGRIND="valgrind --error-exitcode=1 --leak-check=full \
|
||||||
|
--suppressions=$JQTESTDIR/onig.supp"
|
||||||
|
Q=-q
|
||||||
|
else
|
||||||
|
VALGRIND=
|
||||||
|
Q=
|
||||||
|
fi
|
||||||
|
|
||||||
|
mods=$JQTESTDIR/modules
|
||||||
|
|
||||||
|
clean=true
|
||||||
|
d=
|
||||||
|
clean () {
|
||||||
|
if ! $clean; then
|
||||||
|
echo "See temp files in $d!"
|
||||||
|
elif [ -n "$d" ]; then
|
||||||
|
rm -rf "$d"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
trap clean EXIT
|
||||||
|
d=`mktemp -d -t || true`
|
||||||
|
if [ -z "$d" ]; then
|
||||||
|
echo "Your OS does not support mktemp(1) -d" 1>&2
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
+36
-66
@@ -1,55 +1,25 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
. "${0%/*}/setup"
|
||||||
|
|
||||||
if which valgrind > /dev/null; then
|
if [ -f "$JQBASEDIR/.libs/libinject_errors.so" ]; then
|
||||||
VALGRIND='valgrind --error-exitcode=1 --leak-check=full --suppressions=tests/onig.supp'
|
|
||||||
Q=-q
|
|
||||||
else
|
|
||||||
VALGRIND=
|
|
||||||
Q=
|
|
||||||
fi
|
|
||||||
|
|
||||||
mods=$PWD/tests/modules
|
|
||||||
|
|
||||||
# jq-coded tests here:
|
|
||||||
cat $@ | $VALGRIND $Q ./jq -L "$mods" --run-tests
|
|
||||||
|
|
||||||
clean=true
|
|
||||||
d=
|
|
||||||
clean () {
|
|
||||||
if ! $clean; then
|
|
||||||
echo "See temp files in $d!"
|
|
||||||
elif [ -n "$d" ]; then
|
|
||||||
rm -rf "$d"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
trap clean EXIT
|
|
||||||
d=`mktemp -d -t || true`
|
|
||||||
if [ -z "$d" ]; then
|
|
||||||
echo "Your OS does not support mktemp(1) -d" 1>&2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f $PWD/.libs/libinject_errors.so ]; then
|
|
||||||
# Do some simple error injection tests to check that we're handling
|
# Do some simple error injection tests to check that we're handling
|
||||||
# I/O errors correctly.
|
# I/O errors correctly.
|
||||||
(
|
(
|
||||||
jq=$PWD/jq
|
libinject=$JQBASEDIR/.libs/libinject_errors.so
|
||||||
libinject=$PWD/.libs/libinject_errors.so
|
|
||||||
cd $d
|
cd $d
|
||||||
LD_PRELOAD=$libinject $jq . /dev/null
|
LD_PRELOAD=$libinject $JQ . /dev/null
|
||||||
touch fail_read
|
touch fail_read
|
||||||
LD_PRELOAD=$libinject $jq . fail_read && exit 2
|
LD_PRELOAD=$libinject $JQ . fail_read && exit 2
|
||||||
touch fail_close
|
touch fail_close
|
||||||
LD_PRELOAD=$libinject $jq . fail_close && exit 2
|
LD_PRELOAD=$libinject $JQ . fail_close && exit 2
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf 'a\0b\nc\0d\ne' > $d/input
|
printf 'a\0b\nc\0d\ne' > $d/input
|
||||||
$VALGRIND $Q ./jq -Rse '. == "a\u0000b\nc\u0000d\ne"' $d/input
|
$VALGRIND $Q $JQ -Rse '. == "a\u0000b\nc\u0000d\ne"' $d/input
|
||||||
$VALGRIND $Q ./jq -Rne '[inputs] == ["a\u0000b", "c\u0000d", "e"]' $d/input
|
$VALGRIND $Q $JQ -Rne '[inputs] == ["a\u0000b", "c\u0000d", "e"]' $d/input
|
||||||
|
|
||||||
## Test constant folding
|
## Test constant folding
|
||||||
|
|
||||||
@@ -57,49 +27,49 @@ $VALGRIND $Q ./jq -Rne '[inputs] == ["a\u0000b", "c\u0000d", "e"]' $d/input
|
|||||||
## move all of these into tests/all.test
|
## move all of these into tests/all.test
|
||||||
|
|
||||||
# String constant folding (addition only)
|
# String constant folding (addition only)
|
||||||
n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '"foo"' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '"foo"' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne 5 ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Numeric constant folding (not all ops yet)
|
# Numeric constant folding (not all ops yet)
|
||||||
n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '1+1' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '1+1' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne 5 ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '1-1' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '1-1' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne 5 ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '2*3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '2*3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne 5 ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '9/3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9/3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne 5 ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '9==3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9==3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne 5 ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '9!=3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9!=3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne 5 ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '9<=3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9<=3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne 5 ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '9>=3' | wc -l`
|
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9>=3' | wc -l`
|
||||||
if [ $n -ne 5 ]; then
|
if [ $n -ne 5 ]; then
|
||||||
echo "Constant expression folding for strings didn't work"
|
echo "Constant expression folding for strings didn't work"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -115,7 +85,7 @@ ignoring parse error: Truncated value at line 2, column 5
|
|||||||
ignoring parse error: Truncated value at line 2, column 25
|
ignoring parse error: Truncated value at line 2, column 25
|
||||||
ignoring parse error: Truncated value at line 2, column 41
|
ignoring parse error: Truncated value at line 2, column 41
|
||||||
EOF
|
EOF
|
||||||
printf '1\0362 3\n[0,1\036[4,5]true"ab"{"c":4\036{}{"d":5,"e":6"\036false\n'|$VALGRIND $Q ./jq -ces --seq '. == [2,3,[4,5],true,"ab",{},false]' > /dev/null 2> $d/out
|
printf '1\0362 3\n[0,1\036[4,5]true"ab"{"c":4\036{}{"d":5,"e":6"\036false\n'|$VALGRIND $Q $JQ -ces --seq '. == [2,3,[4,5],true,"ab",{},false]' > /dev/null 2> $d/out
|
||||||
cmp $d/out $d/expected
|
cmp $d/out $d/expected
|
||||||
|
|
||||||
cat > $d/expected <<EOF
|
cat > $d/expected <<EOF
|
||||||
@@ -123,7 +93,7 @@ ignoring parse error: Truncated value at line 2, column 5
|
|||||||
ignoring parse error: Truncated value at line 2, column 25
|
ignoring parse error: Truncated value at line 2, column 25
|
||||||
ignoring parse error: Truncated value at line 3, column 1
|
ignoring parse error: Truncated value at line 3, column 1
|
||||||
EOF
|
EOF
|
||||||
printf '1\0362 3\n[0,1\036[4,5]true"ab"{"c":4\036{}{"d":5,"e":6"false\n\036null'|$VALGRIND $Q ./jq -ces --seq '. == [2,3,[4,5],true,"ab",{},null]' > /dev/null 2> $d/out
|
printf '1\0362 3\n[0,1\036[4,5]true"ab"{"c":4\036{}{"d":5,"e":6"false\n\036null'|$VALGRIND $Q $JQ -ces --seq '. == [2,3,[4,5],true,"ab",{},null]' > /dev/null 2> $d/out
|
||||||
cmp $d/out $d/expected
|
cmp $d/out $d/expected
|
||||||
|
|
||||||
# Note that here jq sees no inputs at all but it still succeeds because
|
# Note that here jq sees no inputs at all but it still succeeds because
|
||||||
@@ -131,27 +101,27 @@ cmp $d/out $d/expected
|
|||||||
cat > $d/expected <<EOF
|
cat > $d/expected <<EOF
|
||||||
ignoring parse error: Unfinished abandoned text at EOF at line 1, column 4
|
ignoring parse error: Unfinished abandoned text at EOF at line 1, column 4
|
||||||
EOF
|
EOF
|
||||||
printf '"foo'|./jq -ce --seq . > $d/out 2>&1
|
printf '"foo' | $JQ -ce --seq . > $d/out 2>&1
|
||||||
cmp $d/out $d/expected
|
cmp $d/out $d/expected
|
||||||
|
|
||||||
# Numeric values truncated by EOF are ignored
|
# Numeric values truncated by EOF are ignored
|
||||||
cat > $d/expected <<EOF
|
cat > $d/expected <<EOF
|
||||||
ignoring parse error: Unfinished abandoned text at EOF at line 1, column 1
|
ignoring parse error: Unfinished abandoned text at EOF at line 1, column 1
|
||||||
EOF
|
EOF
|
||||||
printf '1'|./jq -ce --seq . > $d/out 2>&1
|
printf '1' | $JQ -ce --seq . > $d/out 2>&1
|
||||||
cmp $d/out $d/expected
|
cmp $d/out $d/expected
|
||||||
|
|
||||||
cat > $d/expected <<EOF
|
cat > $d/expected <<EOF
|
||||||
EOF
|
EOF
|
||||||
printf '1\n'|./jq -cen --seq '[inputs] == []' >/dev/null 2> $d/out
|
printf '1\n' | $JQ -cen --seq '[inputs] == []' >/dev/null 2> $d/out
|
||||||
cmp $d/out $d/expected
|
cmp $d/out $d/expected
|
||||||
|
|
||||||
## Test streaming parser
|
## Test streaming parser
|
||||||
|
|
||||||
## If we add an option to stream to the `import ... as $symbol;` directive
|
## If we add an option to stream to the `import ... as $symbol;` directive
|
||||||
## then we can move these tests into tests/all.test.
|
## then we can move these tests into tests/all.test.
|
||||||
$VALGRIND $Q ./jq -c '. as $d|path(..) as $p|$d|getpath($p)|scalars_or_empty|[$p,.]' < "$PWD/tests/torture/input0.json" > $d/out0
|
$VALGRIND $Q $JQ -c '. as $d|path(..) as $p|$d|getpath($p)|scalars_or_empty|[$p,.]' < "$JQTESTDIR/torture/input0.json" > $d/out0
|
||||||
$VALGRIND $Q ./jq --stream -c '.|select(length==2)' < "$PWD/tests/torture/input0.json" > $d/out1
|
$VALGRIND $Q $JQ --stream -c '.|select(length==2)' < "$JQTESTDIR/torture/input0.json" > $d/out1
|
||||||
diff $d/out0 $d/out1
|
diff $d/out0 $d/out1
|
||||||
|
|
||||||
## XXX This test can be moved to tests/all.test _now_
|
## XXX This test can be moved to tests/all.test _now_
|
||||||
@@ -161,17 +131,17 @@ if which seq > /dev/null 2>&1; then
|
|||||||
# test very, very slow when run with valgrind, and the whole point
|
# test very, very slow when run with valgrind, and the whole point
|
||||||
# is to run it with valgrind.
|
# is to run it with valgrind.
|
||||||
#
|
#
|
||||||
#len=`wc -c < "$PWD/tests/torture/input0.json"`
|
#len=`wc -c < "$JQTESTDIR/torture/input0.json"`
|
||||||
if [ -z "$VALGRIND" ]; then
|
if [ -z "$VALGRIND" ]; then
|
||||||
start=1
|
start=1
|
||||||
end=`wc -c < "$PWD/tests/torture/input0.json"`
|
end=`wc -c < "$JQTESTDIR/torture/input0.json"`
|
||||||
else
|
else
|
||||||
start=120
|
start=120
|
||||||
end=151
|
end=151
|
||||||
fi
|
fi
|
||||||
for i in `seq $start $end`; do
|
for i in `seq $start $end`; do
|
||||||
dd "if=tests/torture/input0.json" bs=$i count=1 2>/dev/null |
|
dd "if=tests/torture/input0.json" bs=$i count=1 2>/dev/null |
|
||||||
$VALGRIND ./jq -c . > $d/out0 2>$d/err || true
|
$VALGRIND $JQ -c . > $d/out0 2>$d/err || true
|
||||||
if [ -n "$VALGRIND" ]; then
|
if [ -n "$VALGRIND" ]; then
|
||||||
grep '^==[0-9][0-9]*== ERROR SUMMARY: 0 errors' $d/err > /dev/null
|
grep '^==[0-9][0-9]*== ERROR SUMMARY: 0 errors' $d/err > /dev/null
|
||||||
else
|
else
|
||||||
@@ -179,7 +149,7 @@ if which seq > /dev/null 2>&1; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
dd "if=tests/torture/input0.json" bs=$i count=1 2>/dev/null |
|
dd "if=tests/torture/input0.json" bs=$i count=1 2>/dev/null |
|
||||||
$VALGRIND ./jq -cn --stream -L "$mods" 'import "streaming" as streaming; streaming::tovalues(inputs)' > $d/out1 2>$d/err || true
|
$VALGRIND $JQ -cn --stream -L "$mods" 'import "streaming" as streaming; streaming::tovalues(inputs)' > $d/out1 2>$d/err || true
|
||||||
if [ -n "$VALGRIND" ]; then
|
if [ -n "$VALGRIND" ]; then
|
||||||
grep '^==[0-9][0-9]*== ERROR SUMMARY: 0 errors' $d/err > /dev/null
|
grep '^==[0-9][0-9]*== ERROR SUMMARY: 0 errors' $d/err > /dev/null
|
||||||
else
|
else
|
||||||
@@ -198,14 +168,14 @@ fi
|
|||||||
clean=false
|
clean=false
|
||||||
if dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null; then
|
if dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null; then
|
||||||
# Have a /dev/urandom, good
|
# Have a /dev/urandom, good
|
||||||
$VALGRIND $Q ./jq --seq . $d/rand >/dev/null 2>&1
|
$VALGRIND $Q $JQ --seq . $d/rand >/dev/null 2>&1
|
||||||
$VALGRIND $Q ./jq --seq --stream . $d/rand >/dev/null 2>&1
|
$VALGRIND $Q $JQ --seq --stream . $d/rand >/dev/null 2>&1
|
||||||
dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null
|
dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null
|
||||||
$VALGRIND $Q ./jq --seq . $d/rand >/dev/null 2>&1
|
$VALGRIND $Q $JQ --seq . $d/rand >/dev/null 2>&1
|
||||||
$VALGRIND $Q ./jq --seq --stream . $d/rand >/dev/null 2>&1
|
$VALGRIND $Q $JQ --seq --stream . $d/rand >/dev/null 2>&1
|
||||||
dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null
|
dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null
|
||||||
$VALGRIND $Q ./jq --seq . $d/rand >/dev/null 2>&1
|
$VALGRIND $Q $JQ --seq . $d/rand >/dev/null 2>&1
|
||||||
$VALGRIND $Q ./jq --seq --stream . $d/rand >/dev/null 2>&1
|
$VALGRIND $Q $JQ --seq --stream . $d/rand >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
clean=true
|
clean=true
|
||||||
|
|
||||||
@@ -213,12 +183,12 @@ clean=true
|
|||||||
|
|
||||||
# Check handling of ~/.jq; these can't move into jq_test.c yet because
|
# Check handling of ~/.jq; these can't move into jq_test.c yet because
|
||||||
# they depend on $HOME
|
# they depend on $HOME
|
||||||
if [ "`HOME="$mods" $VALGRIND $Q ./jq -nr fg`" != foobar ]; then
|
if [ "`HOME="$mods" $VALGRIND $Q $JQ -nr fg`" != foobar ]; then
|
||||||
echo "Bug #479 appears to be back" 1>&2
|
echo "Bug #479 appears to be back" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ `HOME="$mods" $VALGRIND $Q ./jq --debug-dump-disasm -n fg | grep '^[a-z]' | wc -l` -gt 3 ]; then
|
if [ `HOME="$mods" $VALGRIND $Q $JQ --debug-dump-disasm -n fg | grep '^[a-z]' | wc -l` -gt 3 ]; then
|
||||||
echo "Binding too many defs into program" 1>&2
|
echo "Binding too many defs into program" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
Reference in new issue
Block a user