@port-labs/jq-node-bindings 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +5 -0
- package/.jshintignore +1 -0
- package/.jshintrc +23 -0
- package/binding.gyp +56 -0
- package/configure +26 -0
- package/deps/jq/.gitattributes +2 -0
- package/deps/jq/.travis.yml +53 -0
- package/deps/jq/AUTHORS +73 -0
- package/deps/jq/COPYING +70 -0
- package/deps/jq/ChangeLog +1349 -0
- package/deps/jq/Makefile.am +198 -0
- package/deps/jq/NEWS +88 -0
- package/deps/jq/README.md +64 -0
- package/deps/jq/builtin.c +1684 -0
- package/deps/jq/builtin.h +10 -0
- package/deps/jq/bytecode.c +161 -0
- package/deps/jq/bytecode.h +92 -0
- package/deps/jq/compile-ios.sh +102 -0
- package/deps/jq/compile.c +1210 -0
- package/deps/jq/compile.h +101 -0
- package/deps/jq/config/m4/check-math-func.m4 +4 -0
- package/deps/jq/config/m4/find-func-no-libs.m4 +8 -0
- package/deps/jq/config/m4/find-func-no-libs2.m4 +62 -0
- package/deps/jq/config/m4/find-func.m4 +9 -0
- package/deps/jq/config/m4/misc.m4 +3 -0
- package/deps/jq/configure.ac +221 -0
- package/deps/jq/docs/Gemfile +7 -0
- package/deps/jq/docs/Gemfile.lock +63 -0
- package/deps/jq/docs/README.md +25 -0
- package/deps/jq/docs/Rakefile +145 -0
- package/deps/jq/docs/content/1.tutorial/default.yml +327 -0
- package/deps/jq/docs/content/2.download/default.yml +117 -0
- package/deps/jq/docs/content/3.manual/manual.yml +2878 -0
- package/deps/jq/docs/content/3.manual/v1.3/manual.yml +1270 -0
- package/deps/jq/docs/content/3.manual/v1.4/manual.yml +1672 -0
- package/deps/jq/docs/content/index/index.yml +51 -0
- package/deps/jq/docs/default_manpage.md +22 -0
- package/deps/jq/docs/public/.htaccess +28 -0
- package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.css +1058 -0
- package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.min.css +9 -0
- package/deps/jq/docs/public/bootstrap/css/bootstrap.css +5224 -0
- package/deps/jq/docs/public/bootstrap/css/bootstrap.min.css +9 -0
- package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings-white.png +0 -0
- package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings.png +0 -0
- package/deps/jq/docs/public/bootstrap/js/bootstrap.js +2027 -0
- package/deps/jq/docs/public/bootstrap/js/bootstrap.min.js +6 -0
- package/deps/jq/docs/public/css/base.scss +99 -0
- package/deps/jq/docs/public/jq.png +0 -0
- package/deps/jq/docs/public/robots.txt +2 -0
- package/deps/jq/docs/site.yml +18 -0
- package/deps/jq/docs/templates/default.liquid +34 -0
- package/deps/jq/docs/templates/index.liquid +60 -0
- package/deps/jq/docs/templates/manual.liquid +122 -0
- package/deps/jq/docs/templates/shared/_footer.liquid +5 -0
- package/deps/jq/docs/templates/shared/_head.liquid +12 -0
- package/deps/jq/docs/templates/shared/_header.liquid +26 -0
- package/deps/jq/exec_stack.h +112 -0
- package/deps/jq/execute.c +1155 -0
- package/deps/jq/inject_errors.c +112 -0
- package/deps/jq/jq.1.default +39 -0
- package/deps/jq/jq.1.prebuilt +3075 -0
- package/deps/jq/jq.h +60 -0
- package/deps/jq/jq.spec +70 -0
- package/deps/jq/jq_parser.h +9 -0
- package/deps/jq/jq_test.c +346 -0
- package/deps/jq/jv.c +1333 -0
- package/deps/jq/jv.h +240 -0
- package/deps/jq/jv_alloc.c +179 -0
- package/deps/jq/jv_alloc.h +27 -0
- package/deps/jq/jv_aux.c +619 -0
- package/deps/jq/jv_dtoa.c +4275 -0
- package/deps/jq/jv_dtoa.h +22 -0
- package/deps/jq/jv_file.c +49 -0
- package/deps/jq/jv_parse.c +852 -0
- package/deps/jq/jv_print.c +348 -0
- package/deps/jq/jv_unicode.c +96 -0
- package/deps/jq/jv_unicode.h +11 -0
- package/deps/jq/jv_utf8_tables.h +37 -0
- package/deps/jq/lexer.c +2442 -0
- package/deps/jq/lexer.h +362 -0
- package/deps/jq/lexer.l +184 -0
- package/deps/jq/libm.h +160 -0
- package/deps/jq/linker.c +393 -0
- package/deps/jq/linker.h +7 -0
- package/deps/jq/locfile.c +91 -0
- package/deps/jq/locfile.h +29 -0
- package/deps/jq/m4/ax_compare_version.m4 +177 -0
- package/deps/jq/m4/ax_prog_bison_version.m4 +68 -0
- package/deps/jq/main.c +566 -0
- package/deps/jq/opcode_list.h +44 -0
- package/deps/jq/parser.c +3914 -0
- package/deps/jq/parser.h +193 -0
- package/deps/jq/parser.y +923 -0
- package/deps/jq/scripts/crosscompile +42 -0
- package/deps/jq/scripts/gen_utf8_tables.py +32 -0
- package/deps/jq/scripts/version +5 -0
- package/deps/jq/setup.sh +33 -0
- package/deps/jq/tests/jq.test +1235 -0
- package/deps/jq/tests/jqtest +5 -0
- package/deps/jq/tests/mantest +7 -0
- package/deps/jq/tests/modules/.jq +5 -0
- package/deps/jq/tests/modules/a.jq +2 -0
- package/deps/jq/tests/modules/b/b.jq +2 -0
- package/deps/jq/tests/modules/c/c.jq +16 -0
- package/deps/jq/tests/modules/c/d.jq +1 -0
- package/deps/jq/tests/modules/data.json +4 -0
- package/deps/jq/tests/modules/lib/jq/e/e.jq +1 -0
- package/deps/jq/tests/modules/lib/jq/f.jq +1 -0
- package/deps/jq/tests/modules/syntaxerror/syntaxerror.jq +1 -0
- package/deps/jq/tests/modules/test_bind_order.jq +4 -0
- package/deps/jq/tests/modules/test_bind_order0.jq +1 -0
- package/deps/jq/tests/modules/test_bind_order1.jq +2 -0
- package/deps/jq/tests/modules/test_bind_order2.jq +2 -0
- package/deps/jq/tests/onig.supp +21 -0
- package/deps/jq/tests/onig.test +85 -0
- package/deps/jq/tests/onigtest +5 -0
- package/deps/jq/tests/setup +36 -0
- package/deps/jq/tests/shtest +205 -0
- package/deps/jq/tests/torture/input0.json +7 -0
- package/deps/jq/util.c +462 -0
- package/deps/jq/util.h +64 -0
- package/deps/jq.gyp +35 -0
- package/index.d.ts +3 -0
- package/jest.config.js +10 -0
- package/lib/index.js +14 -0
- package/package.json +48 -0
- package/reports/jest-port-api.xml +35 -0
- package/src/binding.cc +177 -0
- package/src/binding.h +13 -0
- package/test/santiy.test.js +122 -0
- package/util/configure.js +27 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module {whatever:null};
|
|
2
|
+
import "a" as foo;
|
|
3
|
+
import "d" as d {search:"./"};
|
|
4
|
+
import "d" as d2{search:"./"};
|
|
5
|
+
import "e" as e {search:"./../lib/jq"};
|
|
6
|
+
import "f" as f {search:"./../lib/jq"};
|
|
7
|
+
import "data" as $d;
|
|
8
|
+
def a: 0;
|
|
9
|
+
def c:
|
|
10
|
+
if $d::d[0] != {this:"is a test",that:"is too"} then error("data import is busted")
|
|
11
|
+
elif d2::meh != d::meh then error("import twice doesn't work")
|
|
12
|
+
elif foo::a != "a" then error("foo::a didn't work as expected")
|
|
13
|
+
elif d::meh != "meh" then error("d::meh didn't work as expected")
|
|
14
|
+
elif e::bah != "bah" then error("e::bah didn't work as expected")
|
|
15
|
+
elif f::f != "f is here" then error("f::f didn't work as expected")
|
|
16
|
+
else foo::a + "c" + d::meh + e::bah end;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
def meh: "meh";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
def bah: "bah";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
def f: "f is here";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wat;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
def sym0: 0;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
onig node recycling
|
|
3
|
+
Memcheck:Leak
|
|
4
|
+
...
|
|
5
|
+
fun:onig_parse_make_tree
|
|
6
|
+
...
|
|
7
|
+
}
|
|
8
|
+
{
|
|
9
|
+
onig unicode case insensitivity 1
|
|
10
|
+
Memcheck:Leak
|
|
11
|
+
...
|
|
12
|
+
fun:setup_tree
|
|
13
|
+
...
|
|
14
|
+
}
|
|
15
|
+
{
|
|
16
|
+
onig unicode case insensitivity 2
|
|
17
|
+
Memcheck:Leak
|
|
18
|
+
...
|
|
19
|
+
fun:onig*unicode*
|
|
20
|
+
...
|
|
21
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# match builtin
|
|
2
|
+
[match("( )*"; "g")]
|
|
3
|
+
"abc"
|
|
4
|
+
[{"offset":0, "length":0, "string":"", "captures":[]},{"offset":1, "length":0, "string":"", "captures":[]},{"offset":2, "length":0, "string":"", "captures":[]}]
|
|
5
|
+
|
|
6
|
+
[match("( )*"; "gn")]
|
|
7
|
+
"abc"
|
|
8
|
+
[]
|
|
9
|
+
|
|
10
|
+
[match("a"; "gi")]
|
|
11
|
+
"āáàä"
|
|
12
|
+
[]
|
|
13
|
+
|
|
14
|
+
[match(["(bar)"])]
|
|
15
|
+
"foo bar"
|
|
16
|
+
[{"offset": 4, "length": 3, "string": "bar", "captures":[{"offset": 4, "length": 3, "string": "bar", "name": null}]}]
|
|
17
|
+
|
|
18
|
+
# offsets account for combining codepoints and multi-byte UTF-8
|
|
19
|
+
[match("bar")]
|
|
20
|
+
"ā bar with a combining codepoint U+0304"
|
|
21
|
+
[{"offset": 3, "length": 3, "string": "bar", "captures":[]}]
|
|
22
|
+
|
|
23
|
+
# matches with combining codepoints still count them in their length
|
|
24
|
+
[match("bār")]
|
|
25
|
+
"a bār"
|
|
26
|
+
[{"offset": 2, "length": 4, "string": "bār", "captures":[]}]
|
|
27
|
+
|
|
28
|
+
[match(".+?\\b")]
|
|
29
|
+
"ā two-codepoint grapheme"
|
|
30
|
+
[{"offset": 0, "length": 2, "string": "ā", "captures":[]}]
|
|
31
|
+
|
|
32
|
+
[match(["foo (?<bar123>bar)? foo", "ig"])]
|
|
33
|
+
"foo bar foo foo foo"
|
|
34
|
+
[{"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"}]}]
|
|
35
|
+
|
|
36
|
+
#test builtin
|
|
37
|
+
[test("( )*"; "gn")]
|
|
38
|
+
"abc"
|
|
39
|
+
[false]
|
|
40
|
+
|
|
41
|
+
[test("ā")]
|
|
42
|
+
"ā"
|
|
43
|
+
[true]
|
|
44
|
+
|
|
45
|
+
capture("(?<a>[a-z]+)-(?<n>[0-9]+)")
|
|
46
|
+
"xyzzy-14"
|
|
47
|
+
{"a":"xyzzy","n":"14"}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# jq-coded utilities built on match:
|
|
51
|
+
#
|
|
52
|
+
# The second element in these tests' inputs tests the case where the
|
|
53
|
+
# fromstring matches both the head and tail of the string
|
|
54
|
+
[.[] | sub(", "; ":")]
|
|
55
|
+
["a,b, c, d, e,f", ", a,b, c, d, e,f, "]
|
|
56
|
+
["a,b:c, d, e,f",":a,b, c, d, e,f, "]
|
|
57
|
+
|
|
58
|
+
sub("^(?<head>.)"; "Head=\(.head) Tail=")
|
|
59
|
+
"abcdef"
|
|
60
|
+
"Head=a Tail=bcdef"
|
|
61
|
+
|
|
62
|
+
[.[] | gsub(", "; ":")]
|
|
63
|
+
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
|
64
|
+
["a,b:c:d:e,f",":a,b:c:d:e,f:"]
|
|
65
|
+
|
|
66
|
+
gsub("(?<d>\\d)"; ":\(.d);")
|
|
67
|
+
"a1b2"
|
|
68
|
+
"a:1;b:2;"
|
|
69
|
+
|
|
70
|
+
[.[] | scan(", ")]
|
|
71
|
+
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
|
72
|
+
[", ",", ",", ",", ",", ",", ",", ",", "]
|
|
73
|
+
|
|
74
|
+
[.[]|[[sub(", *";":")], [gsub(", *";":")], [scan(", *")]]]
|
|
75
|
+
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
|
76
|
+
[[["a:b, c, d, e,f"],["a:b:c:d:e:f"],[",",", ",", ",", ",","]],[[":a,b, c, d, e,f, "],[":a:b:c:d:e:f:"],[", ",",",", ",", ",", ",",",", "]]]
|
|
77
|
+
|
|
78
|
+
[.[]|[[sub(", +";":")], [gsub(", +";":")], [scan(", +")]]]
|
|
79
|
+
["a,b, c, d, e,f",", a,b, c, d, e,f, "]
|
|
80
|
+
[[["a,b:c, d, e,f"],["a,b:c:d:e,f"],[", ",", ",", "]],[[":a,b, c, d, e,f, "],[":a,b:c:d:e,f:"],[", ",", ",", ",", ",", "]]]
|
|
81
|
+
|
|
82
|
+
# reference to named captures
|
|
83
|
+
gsub("(?<x>.)[^a]*"; "+\(.x)-")
|
|
84
|
+
"Abcabc"
|
|
85
|
+
"+A-+a-"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# This is meant to be included by each test's shell script driver.
|
|
4
|
+
|
|
5
|
+
set -eu
|
|
6
|
+
|
|
7
|
+
JQTESTDIR=$(cd "$(dirname "$0")" && pwd)
|
|
8
|
+
JQBASEDIR=$JQTESTDIR/..
|
|
9
|
+
JQ=$JQBASEDIR/jq
|
|
10
|
+
|
|
11
|
+
if [ -z "${NO_VALGRIND-}" ] && which valgrind > /dev/null; then
|
|
12
|
+
VALGRIND="valgrind --error-exitcode=1 --leak-check=full \
|
|
13
|
+
--suppressions=$JQTESTDIR/onig.supp"
|
|
14
|
+
Q=-q
|
|
15
|
+
else
|
|
16
|
+
VALGRIND=
|
|
17
|
+
Q=
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
mods=$JQTESTDIR/modules
|
|
21
|
+
|
|
22
|
+
clean=true
|
|
23
|
+
d=
|
|
24
|
+
clean () {
|
|
25
|
+
if ! $clean; then
|
|
26
|
+
echo "See temp files in $d!"
|
|
27
|
+
elif [ -n "$d" ]; then
|
|
28
|
+
rm -rf "$d"
|
|
29
|
+
fi
|
|
30
|
+
}
|
|
31
|
+
trap clean EXIT
|
|
32
|
+
d=`mktemp -d -t jqXXXXX || true`
|
|
33
|
+
if [ -z "$d" ]; then
|
|
34
|
+
echo "Your OS does not support mktemp(1) -d" 1>&2
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
. "${0%/*}/setup"
|
|
4
|
+
|
|
5
|
+
if [ -f "$JQBASEDIR/.libs/libinject_errors.so" ]; then
|
|
6
|
+
# Do some simple error injection tests to check that we're handling
|
|
7
|
+
# I/O errors correctly.
|
|
8
|
+
(
|
|
9
|
+
libinject=$JQBASEDIR/.libs/libinject_errors.so
|
|
10
|
+
cd $d
|
|
11
|
+
LD_PRELOAD=$libinject $JQ . /dev/null
|
|
12
|
+
touch fail_read
|
|
13
|
+
LD_PRELOAD=$libinject $JQ . fail_read && exit 2
|
|
14
|
+
touch fail_close
|
|
15
|
+
LD_PRELOAD=$libinject $JQ . fail_close && exit 2
|
|
16
|
+
true
|
|
17
|
+
)
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
printf 'a\0b\nc\0d\ne' > $d/input
|
|
21
|
+
$VALGRIND $Q $JQ -Rse '. == "a\u0000b\nc\u0000d\ne"' $d/input
|
|
22
|
+
$VALGRIND $Q $JQ -Rne '[inputs] == ["a\u0000b", "c\u0000d", "e"]' $d/input
|
|
23
|
+
|
|
24
|
+
## Test constant folding
|
|
25
|
+
|
|
26
|
+
## XXX If we add a builtin to list the program's disassembly then we can
|
|
27
|
+
## move all of these into tests/all.test
|
|
28
|
+
|
|
29
|
+
# String constant folding (addition only)
|
|
30
|
+
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '"foo"' | wc -l`
|
|
31
|
+
if [ $n -ne 5 ]; then
|
|
32
|
+
echo "Constant expression folding for strings didn't work"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Numeric constant folding (not all ops yet)
|
|
37
|
+
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '1+1' | wc -l`
|
|
38
|
+
if [ $n -ne 5 ]; then
|
|
39
|
+
echo "Constant expression folding for strings didn't work"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '1-1' | wc -l`
|
|
43
|
+
if [ $n -ne 5 ]; then
|
|
44
|
+
echo "Constant expression folding for strings didn't work"
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '2*3' | wc -l`
|
|
48
|
+
if [ $n -ne 5 ]; then
|
|
49
|
+
echo "Constant expression folding for strings didn't work"
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9/3' | wc -l`
|
|
53
|
+
if [ $n -ne 5 ]; then
|
|
54
|
+
echo "Constant expression folding for strings didn't work"
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9==3' | wc -l`
|
|
58
|
+
if [ $n -ne 5 ]; then
|
|
59
|
+
echo "Constant expression folding for strings didn't work"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9!=3' | wc -l`
|
|
63
|
+
if [ $n -ne 5 ]; then
|
|
64
|
+
echo "Constant expression folding for strings didn't work"
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
67
|
+
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9<=3' | wc -l`
|
|
68
|
+
if [ $n -ne 5 ]; then
|
|
69
|
+
echo "Constant expression folding for strings didn't work"
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
n=`$VALGRIND $Q $JQ -n --debug-dump-disasm '9>=3' | wc -l`
|
|
73
|
+
if [ $n -ne 5 ]; then
|
|
74
|
+
echo "Constant expression folding for strings didn't work"
|
|
75
|
+
exit 1
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
## Test JSON sequence support
|
|
79
|
+
|
|
80
|
+
cat > $d/expected <<EOF
|
|
81
|
+
ignoring parse error: Truncated value at line 2, column 5
|
|
82
|
+
ignoring parse error: Truncated value at line 2, column 25
|
|
83
|
+
ignoring parse error: Truncated value at line 2, column 41
|
|
84
|
+
EOF
|
|
85
|
+
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
|
|
86
|
+
cmp $d/out $d/expected
|
|
87
|
+
|
|
88
|
+
cat > $d/expected <<EOF
|
|
89
|
+
ignoring parse error: Truncated value at line 2, column 5
|
|
90
|
+
ignoring parse error: Truncated value at line 2, column 25
|
|
91
|
+
ignoring parse error: Truncated value at line 3, column 1
|
|
92
|
+
EOF
|
|
93
|
+
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
|
|
94
|
+
cmp $d/out $d/expected
|
|
95
|
+
|
|
96
|
+
# Note that here jq sees no inputs at all but it still succeeds because
|
|
97
|
+
# --seq ignores parse errors
|
|
98
|
+
cat > $d/expected <<EOF
|
|
99
|
+
ignoring parse error: Unfinished abandoned text at EOF at line 1, column 4
|
|
100
|
+
EOF
|
|
101
|
+
printf '"foo' | $JQ -ce --seq . > $d/out 2>&1
|
|
102
|
+
cmp $d/out $d/expected
|
|
103
|
+
|
|
104
|
+
# Numeric values truncated by EOF are ignored
|
|
105
|
+
cat > $d/expected <<EOF
|
|
106
|
+
ignoring parse error: Unfinished abandoned text at EOF at line 1, column 1
|
|
107
|
+
EOF
|
|
108
|
+
printf '1' | $JQ -ce --seq . > $d/out 2>&1
|
|
109
|
+
cmp $d/out $d/expected
|
|
110
|
+
|
|
111
|
+
cat > $d/expected <<EOF
|
|
112
|
+
EOF
|
|
113
|
+
printf '1\n' | $JQ -cen --seq '[inputs] == []' >/dev/null 2> $d/out
|
|
114
|
+
cmp $d/out $d/expected
|
|
115
|
+
|
|
116
|
+
## Test streaming parser
|
|
117
|
+
|
|
118
|
+
## If we add an option to stream to the `import ... as $symbol;` directive
|
|
119
|
+
## then we can move these tests into tests/all.test.
|
|
120
|
+
$VALGRIND $Q $JQ -c '. as $d|path(..) as $p|$d|getpath($p)|scalars_or_empty|[$p,.]' < "$JQTESTDIR/torture/input0.json" > $d/out0
|
|
121
|
+
$VALGRIND $Q $JQ --stream -c '.|select(length==2)' < "$JQTESTDIR/torture/input0.json" > $d/out1
|
|
122
|
+
diff $d/out0 $d/out1
|
|
123
|
+
|
|
124
|
+
## XXX This test can be moved to tests/all.test _now_
|
|
125
|
+
clean=false
|
|
126
|
+
if which seq > /dev/null 2>&1; then
|
|
127
|
+
# XXX We should try every prefix of input0.json, but that makes this
|
|
128
|
+
# test very, very slow when run with valgrind, and the whole point
|
|
129
|
+
# is to run it with valgrind.
|
|
130
|
+
#
|
|
131
|
+
#len=`wc -c < "$JQTESTDIR/torture/input0.json"`
|
|
132
|
+
if [ -z "$VALGRIND" ]; then
|
|
133
|
+
start=1
|
|
134
|
+
end=`wc -c < "$JQTESTDIR/torture/input0.json"`
|
|
135
|
+
else
|
|
136
|
+
start=120
|
|
137
|
+
end=151
|
|
138
|
+
fi
|
|
139
|
+
for i in `seq $start $end`; do
|
|
140
|
+
dd "if=tests/torture/input0.json" bs=$i count=1 2>/dev/null |
|
|
141
|
+
$VALGRIND $JQ -c . > $d/out0 2>$d/err || true
|
|
142
|
+
if [ -n "$VALGRIND" ]; then
|
|
143
|
+
grep '^==[0-9][0-9]*== ERROR SUMMARY: 0 errors' $d/err > /dev/null
|
|
144
|
+
else
|
|
145
|
+
tail -1 $d/err | egrep -i 'assert|abort|core' && false
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
dd "if=tests/torture/input0.json" bs=$i count=1 2>/dev/null |
|
|
149
|
+
$VALGRIND $JQ -cn --stream 'fromstream(inputs)' > $d/out1 2>$d/err || true
|
|
150
|
+
if [ -n "$VALGRIND" ]; then
|
|
151
|
+
grep '^==[0-9][0-9]*== ERROR SUMMARY: 0 errors' $d/err > /dev/null
|
|
152
|
+
else
|
|
153
|
+
tail -1 $d/err | egrep -i 'assert|abort|core' && false
|
|
154
|
+
fi
|
|
155
|
+
|
|
156
|
+
diff $d/out0 $d/out1
|
|
157
|
+
done
|
|
158
|
+
else
|
|
159
|
+
echo "Not doing torture tests"
|
|
160
|
+
fi
|
|
161
|
+
|
|
162
|
+
## Fuzz parser
|
|
163
|
+
|
|
164
|
+
## XXX With a `urandom` builtin we could move this test into tests/all.test
|
|
165
|
+
clean=false
|
|
166
|
+
if dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null; then
|
|
167
|
+
# Have a /dev/urandom, good
|
|
168
|
+
$VALGRIND $Q $JQ --seq . $d/rand >/dev/null 2>&1
|
|
169
|
+
$VALGRIND $Q $JQ --seq --stream . $d/rand >/dev/null 2>&1
|
|
170
|
+
dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null
|
|
171
|
+
$VALGRIND $Q $JQ --seq . $d/rand >/dev/null 2>&1
|
|
172
|
+
$VALGRIND $Q $JQ --seq --stream . $d/rand >/dev/null 2>&1
|
|
173
|
+
dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null
|
|
174
|
+
$VALGRIND $Q $JQ --seq . $d/rand >/dev/null 2>&1
|
|
175
|
+
$VALGRIND $Q $JQ --seq --stream . $d/rand >/dev/null 2>&1
|
|
176
|
+
fi
|
|
177
|
+
clean=true
|
|
178
|
+
|
|
179
|
+
## Test library/module system
|
|
180
|
+
|
|
181
|
+
# Check handling of ~/.jq; these can't move into jq_test.c yet because
|
|
182
|
+
# they depend on $HOME
|
|
183
|
+
if [ "`HOME="$mods" $VALGRIND $Q $JQ -nr fg`" != foobar ]; then
|
|
184
|
+
echo "Bug #479 appears to be back" 1>&2
|
|
185
|
+
exit 1
|
|
186
|
+
fi
|
|
187
|
+
|
|
188
|
+
if [ `HOME="$mods" $VALGRIND $Q $JQ --debug-dump-disasm -n fg | grep '^[a-z]' | wc -l` -gt 3 ]; then
|
|
189
|
+
echo "Binding too many defs into program" 1>&2
|
|
190
|
+
exit 1
|
|
191
|
+
fi
|
|
192
|
+
|
|
193
|
+
cd "$JQBASEDIR" # so that relative library paths are guaranteed correct
|
|
194
|
+
if ! $VALGRIND $Q $JQ -L ./tests/modules -ne 'import "test_bind_order" as check; check::check==true'; then
|
|
195
|
+
echo "Issue #817 regression?" 1>&2
|
|
196
|
+
exit 1
|
|
197
|
+
fi
|
|
198
|
+
|
|
199
|
+
cd "$JQBASEDIR"
|
|
200
|
+
if ! $VALGRIND $Q $JQ -L tests/modules -ne 'import "test_bind_order" as check; check::check==true'; then
|
|
201
|
+
echo "Issue #817 regression?" 1>&2
|
|
202
|
+
exit 1
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
exit 0
|