Skip to content
Myr

Split man.test to make tests pass without oniguruma (#2722)

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

authored by itchyny · committed by GitHub · parent 4b3090a · Browse files · 11 files+91 added−71 removed
This commit

State

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

Diff stats

11 files+91 added−71 removed

  • tests:+50 added−45 removed
  • other:+41 added−26 removed

11 files+91 added−71 removed

modified:.github/workflows/manpage.yml+8 added-6 removed
modified:docs/build_mantests.py+14 added-6 removed
1#!/usr/bin/env python32import yaml3import re44with open("content/manual/manual.yml") as f:5 manual = yaml.safe_load(f)5regex_program_pattern = re.compile(6 r'\b(?:test|match|capture|scan|split|splits|sub|gsub)\s*\(')78with open('content/manual/manual.yml') as source, \9 open('../tests/man.test', 'w') as man, \10 open('../tests/manonig.test', 'w') as manonig:11 manual = yaml.safe_load(source)12 for section in manual.get('sections', []):13 for entry in section.get('entries', []):14 for example in entry.get('examples', []):9 print(example.get('program', '').replace('\n', ' '))10 print(example.get('input', ''))15 program = example.get('program', '').replace('\n', ' ')16 out = manonig if regex_program_pattern.search(program) else man17 print(program, file=out)18 print(example.get('input', ''), file=out)19 for s in example.get('output', []):12 print(s)13 print('')20 print(s, file=out)21 print('', file=out)
modified:docs/README.md+6 added-6 removed
modified:tests/man.test-44 removed
562 unmodified lines
563implode564[65, 66, 67]565"ABC"566567split(", ")568"a, b,c,d, e, "569["a","b,c,d","e",""]570567join(", ")568["a","b,c,d","e"]569"a, b,c,d, e"570
36 unmodified lines
607walk(if type == "array" then sort else . end)608[[4, 1, 7], [8, 5, 2], [3, 6, 9]]609[[1,4,7],[2,5,8],[3,6,9]]610615walk( if type == "object" then with_entries( .key |= sub( "^_+"; "") ) else . end )616[ { "_a": { "__b": 2 } } ]617[{"a":{"b":2}}]618611$ENV.PAGER612null613"less"614
131 unmodified lines
746[.[] | tonumber?]747["1", "invalid", "3", 4]748[1, 3, 4]749758test("foo")759"foo"760true761762.[] | test("a b c # spaces are ignored"; "ix")763["xabcd", "ABC"]764true765true766767match("(abc)+"; "g")768"abc abc"769{"offset": 0, "length": 3, "string": "abc", "captures": [{"offset": 0, "length": 3, "string": "abc", "name": null}]}770{"offset": 4, "length": 3, "string": "abc", "captures": [{"offset": 4, "length": 3, "string": "abc", "name": null}]}771772match("foo")773"foo bar foo"774{"offset": 0, "length": 3, "string": "foo", "captures": []}775776match(["foo", "ig"])777"foo bar FOO"778{"offset": 0, "length": 3, "string": "foo", "captures": []}779{"offset": 8, "length": 3, "string": "FOO", "captures": []}780781match("foo (?<bar123>bar)? foo"; "ig")782"foo bar foo foo foo"783{"offset": 0, "length": 11, "string": "foo bar foo", "captures": [{"offset": 4, "length": 3, "string": "bar", "name": "bar123"}]}784{"offset": 12, "length": 8, "string": "foo foo", "captures": [{"offset": -1, "length": 0, "string": null, "name": "bar123"}]}785786[ match("."; "g")] | length787"abc"7883789790capture("(?<a>[a-z]+)-(?<n>[0-9]+)")791"xyzzy-14"792{ "a": "xyzzy", "n": "14" }793750.bar as $x | .foo | . + $x751{"foo":10, "bar":200}752210753
109 unmodified lines
added:tests/manonig.test+44 added
1split(", ")2"a, b,c,d, e, "3["a","b,c,d","e",""]45walk( if type == "object" then with_entries( .key |= sub( "^_+"; "") ) else . end )6[ { "_a": { "__b": 2 } } ]7[{"a":{"b":2}}]89test("foo")10"foo"11true1213.[] | test("a b c # spaces are ignored"; "ix")14["xabcd", "ABC"]15true16true1718match("(abc)+"; "g")19"abc abc"20{"offset": 0, "length": 3, "string": "abc", "captures": [{"offset": 0, "length": 3, "string": "abc", "name": null}]}21{"offset": 4, "length": 3, "string": "abc", "captures": [{"offset": 4, "length": 3, "string": "abc", "name": null}]}2223match("foo")24"foo bar foo"25{"offset": 0, "length": 3, "string": "foo", "captures": []}2627match(["foo", "ig"])28"foo bar FOO"29{"offset": 0, "length": 3, "string": "foo", "captures": []}30{"offset": 8, "length": 3, "string": "FOO", "captures": []}3132match("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"}]}35{"offset": 12, "length": 8, "string": "foo foo", "captures": [{"offset": -1, "length": 0, "string": null, "name": "bar123"}]}3637[ match("."; "g")] | length38"abc"3934041capture("(?<a>[a-z]+)-(?<n>[0-9]+)")42"xyzzy-14"43{ "a": "xyzzy", "n": "14" }44
added:tests/manonigtest+5 added
1#!/bin/sh23. "${0%/*}/setup" "$@"45$VALGRIND $Q $JQ -L "$mods" --run-tests $JQBASEDIR/tests/manonig.test
modified:tests/mantest+1 added-1 removed
1 unmodified line
23. "${0%/*}/setup" "$@"45# We set PAGER because there's a mantest for `env` that uses it.6env PAGER=less $VALGRIND $Q $JQ -L "$mods" --run-tests < $JQBASEDIR/tests/man.test6env PAGER=less $VALGRIND $Q $JQ -L "$mods" --run-tests $JQBASEDIR/tests/man.test
modified:.gitattributes+1 added
7 unmodified lines
8# generated files9src/lexer.[ch] linguist-generated=true10src/parser.[ch] linguist-generated=true11tests/man.test linguist-generated=true12tests/manonig.test linguist-generated=true13jq.1.prebuilt linguist-generated=true14docs/Pipfile.lock linguist-generated=true
modified:configure.ac+1 added
286 unmodified lines
287AC_SUBST(onig_CFLAGS)288AC_SUBST(onig_LDFLAGS)289290AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes])291AM_CONDITIONAL([WITH_ONIGURUMA], [test "x$with_oniguruma" != xno])292AC_SUBST([BUNDLER], ["$bundle_cmd"])293294AC_CONFIG_MACRO_DIRS([config/m4 m4])295AC_CONFIG_FILES([Makefile libjq.pc])
2 unmodified lines
modified:Makefile.am+10 added-6 removed
132 unmodified lines
133endif134135### Tests (make check)136137TESTS = tests/optionaltest tests/mantest tests/jqtest tests/onigtest tests/shtest tests/utf8test tests/base64test137TESTS = tests/optionaltest tests/mantest tests/jqtest tests/shtest tests/utf8test tests/base64test138AM_TESTS_ENVIRONMENT = JQ=$(abs_builddir)/jq NO_VALGRIND=$(NO_VALGRIND)139140# This is a magic make variable that causes it to treat tests/man.test as a141# DATA-type dependency for the check target. As a result, it will attempt to
7 unmodified lines
149# As a result, we need to rebuild the tests if the manual has been updated.150# Making changes to the manpage without having the python deps means your151# tests won't run. If you aren't making changes to the examples, you probably152# don't care. But if you are, then you need to run the tests anyway.153tests/man.test: $(srcdir)/docs/content/manual/manual.yml153tests/man.test tests/manonig.test: $(srcdir)/docs/content/manual/manual.yml154if ENABLE_DOCS155 $(AM_V_GEN) ( cd ${abs_srcdir}/docs; $(PIPENV) run python build_mantests.py ) > $@155 $(AM_V_GEN) ( cd ${abs_srcdir}/docs; $(PIPENV) run python build_mantests.py )156else157 @echo Changes to the manual.yml require docs to be enabled to update the manual test.158 @echo As a result, the manual test is out of date.159endif
25 unmodified lines
185endif186187AM_CFLAGS += $(onig_CFLAGS)188189if WITH_ONIGURUMA190TESTS += tests/onigtest tests/manonigtest191endif192193### Packaging194195docs/site.yml: configure.ac196 sed 's/^jq_version: .*/jq_version: "$(VERSION)"/' $@ > $@.new
22 unmodified lines
219 tests/modules/test_bind_order1.jq \220 tests/modules/test_bind_order2.jq \221 tests/onig.supp tests/local.supp \222 tests/setup tests/torture/input0.json \219 tests/optional.test tests/man.test tests/jq.test \220 tests/onig.test tests/base64.test tests/utf8-truncate.jq \221 tests/jq-f-test.sh223 tests/optional.test tests/man.test tests/manonig.test \224 tests/jq.test tests/onig.test tests/base64.test \225 tests/utf8-truncate.jq tests/jq-f-test.sh226227AM_DISTCHECK_CONFIGURE_FLAGS=--disable-maintainer-mode --with-oniguruma=builtin228229# README.md is expected in GitHub projects, good stuff in it, so we'll
14 unmodified lines
modified:README.md+1 added-2 removed
18 unmodified lines
1920If you're building directly from the latest git, you'll need flex,21bison (3.0 or newer), libtool, make, automake, and autoconf installed.22To get regexp support you'll also need to install Oniguruma or clone it as a23git submodule as per the instructions below.24(note that jq's tests require regexp support to pass). To build, run:23git submodule as per the instructions below. To build, run:2425 git submodule update --init # if building from git to get oniguruma26 autoreconf -i # if building from git27 ./configure --with-oniguruma=builtin
46 unmodified lines