Skip to content
Myr

Drop "any/" in module search; use 1.x-master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nicolas Williams · committed by Nicolas Williams · parent 287e2c9 · Browse files · 9 files+30 added−47 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

9 files+30 added−47 removed

  • tests:+26 added−43 removed
  • other:+4 added−4 removed

9 files+30 added−47 removed

added:tests/modules/1.4-master/b/b.jq+2 added
1def a: "b";2def b: "c";
added:tests/modules/1.4-master/a.jq+2 added
1module a {version:1.7};2def a: "a";
added:tests/modules/c/c.jq+5 added
1module c {whatever:null};2import a as foo;3import d as d {search:"$ORIGIN/"};4def a: 0;5def c: foo::a + "c" + d::meh;
added:tests/modules/c/d.jq+1 added
1def meh: "meh";
added:tests/modules/syntaxerror/syntaxerror.jq+1 added
1wat;
added:tests/modules/.jq+5 added
1def foo: "baz";2def f: "wat";3def f: "foo";4def g: "bar";5def fg: f+g;
modified:tests/run+10 added-43 removed
18 unmodified lines
19 echo "Your OS does not support mktemp(1) -d" 1>&220 exit 021fi222324## Test constant folding2526# String constant folding (addition only)27n=`$VALGRIND $Q ./jq -n --debug-dump-disasm '"foo"' | wc -l`
45 unmodified lines
73fi7475v=`scripts/version`76case "$v" in76*-*) v=next;;77*-*) v=`echo $v|sed -e 's/-.*$/-master/'`;;78*) true;;79esac8081## Test library/module system8282cat > "$d/.jq" <<EOF83def foo: "baz";84def f: "wat";85def f: "foo";86def g: "bar";87def fg: f+g;88EOF83mods=$PWD/tests/modules8490mkdir -p "$d/$v/b" "$d/any/c" "$d/any/syntaxerror"9192cat > "$d/$v/a.jq" <<EOF93module a {version:1.7};94def a: "a";95EOF9697cat > "$d/$v/b/b.jq" <<EOF98def a: "b";99def b: "c";100EOF101102cat > "$d/any/c/d.jq" <<EOF103def meh: "meh";104EOF105106cat > "$d/any/c/c.jq" <<"EOF"107module c {whatever:null};108import a as foo;109import d as d {search:"$ORIGIN/"};110def a: 0;111def c: foo::a + "c" + d::meh;112EOF113114cat > "$d/any/syntaxerror/syntaxerror.jq" <<EOF115wat;116EOF117118if [ "`HOME=$d $VALGRIND $Q ./jq -nr fg`" != foobar ]; then85if [ "`HOME=$mods $VALGRIND $Q ./jq -nr fg`" != foobar ]; then86 echo "Bug #479 appears to be back" 1>&287 exit 188fi89123if [ `HOME=$d $VALGRIND $Q ./jq --debug-dump-disasm -n fg | grep '^[a-z]' | wc -l` -gt 3 ]; then90if [ `HOME=$mods $VALGRIND $Q ./jq --debug-dump-disasm -n fg | grep '^[a-z]' | wc -l` -gt 3 ]; then91 echo "Binding too many defs into program" 1>&292 exit 193fi94128if ! $VALGRIND $Q ./jq -ner -L $d 'import a as foo; import b as bar; import a; def fooa: foo::a; [fooa, bar::a, bar::b, foo::a, a] | . == ["a","b","c","a","a"]' > /dev/null; then95if ! $VALGRIND $Q ./jq -ner -L $mods 'import a as foo; import b as bar; import a; def fooa: foo::a; [fooa, bar::a, bar::b, foo::a, a] | . == ["a","b","c","a","a"]' > /dev/null; then96 echo "Module system appears to be broken" 1>&297 exit 198fi99133if ! $VALGRIND $Q ./jq -ner -L $d 'import c as foo; [foo::a, foo::c] | . == [0,"acmeh"]' > /dev/null; then100if ! $VALGRIND $Q ./jq -ner -L $mods 'import c as foo; [foo::a, foo::c] | . == [0,"acmeh"]' > /dev/null; then101 echo "Module system appears to be broken" 1>&2102 exit 1103fi104138if [ "`$VALGRIND $Q ./jq -cner -L $d '\"c\" | modulemeta'`" != '{"whatever":null,"name":"c","deps":[{"as":"foo","name":"a"},{"search":"$ORIGIN/","as":"d","name":"d"}]}' ]; then105if [ "`$VALGRIND $Q ./jq -cner -L $mods '\"c\" | modulemeta'`" != '{"whatever":null,"name":"c","deps":[{"as":"foo","name":"a"},{"search":"$ORIGIN/","as":"d","name":"d"}]}' ]; then106 echo "modulemeta builtin appears to be broken" 1>&2107 exit 1108fi109 143if $VALGRIND ./jq -ner -L $d 'import syntaxerror; .' > $d/out 2>&1; then110if $VALGRIND ./jq -ner -L $mods 'import syntaxerror; .' > $d/out 2>&1; then111 echo "Module system appears to be broken" 1>&2112 exit 1113fi114if [ -n "$VALGRIND" ] && ! grep 'ERROR SUMMARY: 0 errors from 0 contexts' $d/out > /dev/null; then
5 unmodified lines
120 echo "Module system not detecting syntax errors in modules correctly" 1>&2121 exit 1122fi123157if $VALGRIND ./jq -ner -L $d '%::wat' > $d/out 2>&1 ||124if $VALGRIND ./jq -ner -L $mods '%::wat' > $d/out 2>&1 ||125 ! grep '^jq: error: syntax error,' $d/out > /dev/null; then126 echo "Syntax errors not detected?" 1>&2127 exit 1128fi
5 unmodified lines
modified:linker.c+3 added-3 removed
86 unmodified lines
87 }8889 jv version_dirs;90 if (use_vers_dir) {91 version_dirs = JV_ARRAY(jv_string("any/"),92 jv_string_concat(jq_get_version_dir(jq),93 jv_string("/")));91 jv vdir = jq_get_version_dir(jq);92 assert(strchr(jv_string_value(vdir), '.') != NULL);93 version_dirs = JV_ARRAY(jv_string(""), jv_string_concat(vdir, jv_string("/")));94 } else {95 version_dirs = JV_ARRAY(jv_string(""));96 }97
190 unmodified lines
modified:main.c+1 added-1 removed
363 unmodified lines
364365 if (strchr(JQ_VERSION, '-') == NULL)366 jq_set_attr(jq, jv_string("VERSION_DIR"), jv_string(JQ_VERSION));367 else368 jq_set_attr(jq, jv_string("VERSION_DIR"), jv_string("next"));368 jq_set_attr(jq, jv_string("VERSION_DIR"), jv_string_fmt("%.*s-master", strchr(JQ_VERSION, '-') - JQ_VERSION, JQ_VERSION));369370#if (!defined(WIN32) && defined(HAVE_ISATTY)) || defined(HAVE__ISATTY)371372#if defined(HAVE__ISATTY) && defined(isatty)
129 unmodified lines