Skip to content

Commit 4cf125c

Browse files
committed
fix: conform with existing pattern of handling oniguruma in tests
1 parent fdc3e2f commit 4cf125c

File tree

7 files changed

+27
-51
lines changed

7 files changed

+27
-51
lines changed

Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ endif
202202
AM_CFLAGS += $(onig_CFLAGS)
203203

204204
if WITH_ONIGURUMA
205-
TESTS += tests/onigtest tests/manonigtest
205+
TESTS += tests/jqonigtest tests/onigtest tests/manonigtest
206206
endif
207207

208208
### Packaging
@@ -232,7 +232,8 @@ EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \
232232
tests/onig.supp tests/local.supp \
233233
tests/setup tests/torture/input0.json \
234234
tests/optional.test tests/man.test tests/manonig.test \
235-
tests/jq.test tests/onig.test tests/base64.test tests/uri.test \
235+
tests/jq.test tests/jqonig.test tests/onig.test \
236+
tests/base64.test tests/uri.test \
236237
tests/utf8-truncate.jq tests/jq-f-test.sh \
237238
tests/no-main-program.jq tests/yes-main-program.jq
238239

docs/content/manual/v1.8/manual.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,6 +2188,11 @@ sections:
21882188
backslash (ascii `0x5c`) will be output as escape sequences
21892189
`\n`, `\r`, `\t`, `\\` respectively.
21902190
2191+
* `@table`:
2192+
2193+
The input must be an array of objects or values, and it is
2194+
rendered as an ASCII table.
2195+
21912196
* `@sh`:
21922197
21932198
The input is escaped suitable for use in a command-line
@@ -2236,6 +2241,10 @@ sections:
22362241
input: '"VGhpcyBpcyBhIG1lc3NhZ2U="'
22372242
output: ['"This is a message"']
22382243

2244+
- program: '@table'
2245+
input: '[{"a": 1, "b": 2}, {"a": "one", "b": "two"}]'
2246+
output: ['"TESTING FAILURE CASE: NOT THE TABLE YOU WERE LOOKING FOR"']
2247+
22392248
- title: "Dates"
22402249
body: |
22412250

tests/jq.test

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,15 @@ null
8282
"ISgpPD4mJyIJ"
8383
"!()<>&'\"\t"
8484

85-
# table with headings, rows & color_words
85+
# table from array of values
8686
@table
87-
{"headings":["false","bartrue","baz"],"rows":[["true","false","TRUE"],[1,null,0],["true false","FALSE TRUE","falsetrue"]],"color_words":["(no|NO|false|FALSE)","(yes|YES|true|TRUE)","null"]}
88-
# jqtest oniguruma:enabled
89-
"┌──────────┬──────────┬─────────┐\n│\u001b[1mfalse\u001b[0m │\u001b[1mbartrue\u001b[0m │\u001b[1mbaz\u001b[0m │\n├──────────┼──────────┼─────────┤\n│\u001b[1;32mtrue\u001b[0m │\u001b[1;31mfalse\u001b[0m │\u001b[1;32mTRUE\u001b[0m │\n│1 │\u001b[1;33mnull\u001b[0m │0 │\n│\u001b[1;32mtrue\u001b[0m \u001b[1;31mfalse\u001b[0m│\u001b[1;31mFALSE\u001b[0m \u001b[1;32mTRUE\u001b[0m│falsetrue│\n└──────────┴──────────┴─────────┘"
90-
# jqtest oniguruma:disabled
91-
"┌──────────┬──────────┬─────────┐\n│\u001b[1mfalse\u001b[0m │\u001b[1mbartrue\u001b[0m │\u001b[1mbaz\u001b[0m │\n├──────────┼──────────┼─────────┤\n│true │false │TRUE │\n│1 │null │0 │\n│true false│FALSE TRUE│falsetrue│\n└──────────┴──────────┴─────────┘"
87+
[["one","two", "three"],[1, null, "Three"],["", 2,false]]
88+
"┌───┬────┬─────┐\n│\u001b[1mone\u001b[0m│\u001b[1mtwo\u001b[0m │\u001b[1mthree\u001b[0m│\n│1 │null│Three│\n│ │2 │false│\n└───┴────┴─────┘"
9289

9390
# table from array of objects
9491
@table
95-
[{"false":"true","bartrue":"false","baz":"TRUE"},{"false":1,"bartrue":null,"baz":0},{"false":"true false","bartrue":"FALSE TRUE","baz":"falsetrue"}]
96-
"┌──────────┬──────────┬─────────┐\n│\u001b[1mfalse\u001b[0m │\u001b[1mbartrue\u001b[0m │\u001b[1mbaz\u001b[0m │\n├──────────┼──────────┼─────────┤\n│true │false │TRUE │\n│1 │null │0 │\n│true false│FALSE TRUE│falsetrue│\n└──────────┴──────────┴─────────┘"
92+
[{"one":1,"two":null,"three":"Three"},{"two":2,"three":false}]
93+
"┌────┬────┬─────┐\n│\u001b[1mone\u001b[0m │\u001b[1mtwo\u001b[0m │\u001b[1mthree\u001b[0m│\n├────┼────┼─────┤\n│1 │null│Three│\n│null│2 false│\n└────┴─────────┘"
9794

9895
# regression test for #436
9996
@base64

tests/jqonig.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# table with headings, rows & color_words
2+
@table
3+
{"headings":["false","bartrue","baz"],"rows":[["true","false","TRUE"],[1,null,0],["true false","FALSE TRUE","falsetrue"]],"color_words":["(no|NO|false|FALSE)","(yes|YES|true|TRUE)","null"]}
4+
"┌──────────┬──────────┬─────────┐\n│\u001b[1mfalse\u001b[0m │\u001b[1mbartrue\u001b[0m │\u001b[1mbaz\u001b[0m │\n├──────────┼──────────┼─────────┤\n│\u001b[1;32mtrue\u001b[0m │\u001b[1;31mfalse\u001b[0m │\u001b[1;32mTRUE\u001b[0m │\n│1 │\u001b[1;33mnull\u001b[0m │0 │\n│\u001b[1;32mtrue\u001b[0m \u001b[1;31mfalse\u001b[0m│\u001b[1;31mFALSE\u001b[0m \u001b[1;32mTRUE\u001b[0m│falsetrue│\n└──────────┴──────────┴─────────┘"

tests/jqonigtest

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
. "${0%/*}/setup" "$@"
4+
5+
$VALGRIND $Q $JQ -L "$mods" --run-tests $JQTESTDIR/jqonig.test

tests/jqtest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
. "${0%/*}/setup" "$@"
44

5-
test_file | $VALGRIND $Q $JQ -L "$mods" --run-tests
5+
$VALGRIND $Q $JQ -L "$mods" --run-tests $JQTESTDIR/jq.test

tests/setup

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,43 +45,3 @@ if [ -z "$d" ]; then
4545
echo "Your OS does not support mktemp(1) -d" 1>&2
4646
exit 1
4747
fi
48-
49-
jq_oniguruma_installed() {
50-
$JQ --exit-status --null-input '"" | test("")' > /dev/null 2>&1
51-
}
52-
53-
if ! command -v awk > /dev/null; then
54-
echo "awk is required but not found in PATH."
55-
exit 1
56-
else
57-
echo "XXXXXXXXXXXX awk was found"
58-
fi
59-
60-
if [ ! -f "$JQTESTDIR/${TESTFILE:-jq.test}" ]; then
61-
echo "Test file '$JQTESTDIR/${TESTFILE:-jq.test}' not found."
62-
exit 1
63-
else
64-
echo "XXXXXXXXXXXX jq.test was found"
65-
fi
66-
test_file() {
67-
status="$(jq_oniguruma_installed && echo enabled || echo disabled)"
68-
skip=0
69-
while IFS= read -r line; do
70-
if [ "$skip" -eq 1 ]; then skip=0; continue; fi
71-
case "$line" in
72-
"# jqtest oniguruma:"*)
73-
marker_status="${line#\# jqtest oniguruma:}"
74-
# Remove leading and trailing whitespace (POSIX shell way)
75-
marker_status="${marker_status#"${marker_status%%[![:space:]]*}"}"
76-
marker_status="${marker_status%"${marker_status##*[![:space:]]}"}"
77-
if [ "$marker_status" = "$status" ]; then
78-
continue
79-
else
80-
skip=1
81-
continue
82-
fi
83-
;;
84-
esac
85-
printf "%s\n" "$line"
86-
done < "$JQTESTDIR/${TESTFILE:-jq.test}"
87-
}

0 commit comments

Comments
 (0)