diff options
author | Tina Müller <cpan2@tinita.de> | 2017-12-23 20:39:34 +0100 |
---|---|---|
committer | Ingy döt Net <ingy@ingy.net> | 2017-12-28 12:48:04 -0800 |
commit | 816244f4f793a6fd51df785f8d5e6b184284c3df (patch) | |
tree | da34220afed061feb4ac57d4ac90efbbef9e3360 | |
parent | 381014a5ef0b56f92d401b40960937b6f0e9da1b (diff) | |
download | libyaml-git-816244f4f793a6fd51df785f8d5e6b184284c3df.tar.gz |
Add libyaml-parser-error.t to test invalid YAML
Add script to update test lists
-rw-r--r-- | test/libyaml-parser-error.list | 53 | ||||
-rwxr-xr-x | test/libyaml-parser-error.t | 26 | ||||
-rwxr-xr-x | update-test-list.sh | 33 |
3 files changed, 112 insertions, 0 deletions
diff --git a/test/libyaml-parser-error.list b/test/libyaml-parser-error.list new file mode 100644 index 0000000..e556cdc --- /dev/null +++ b/test/libyaml-parser-error.list @@ -0,0 +1,53 @@ +236B: Invalid value after mapping +2CMS: Invalid mapping in plain multiline +3HFZ: Invalid content after document end marker +4H7K: Flow sequence with invalid extra closing bracket +4HVU: Wrong indendation in Sequence +4JVG: Scalar value with two anchors +55WF: Invalid escape in double quoted string +5LLU: Block scalar with wrong indented line after spaces only +5TRB: Invalid document-start marker in doublequoted tring +5U3A: Sequence on same Line as Mapping Key +6JTT: Flow sequence without closing bracket +6S55: Invalid scalar at the end of sequence +7LBH: Multiline double quoted implicit keys +7MNF: Missing colon +8XDJ: Comment in plain multiline value +9CWY: Invalid scalar at the end of mapping +9KBC: Mapping starting at --- line +9MAG: Flow sequence with invalid comma at the beginning +B63P: Directive without document +BD7L: Invalid mapping after sequence +BF9H: Trailing comment in multiline plain scalar +BS4K: Comment between plain scalar lines +C2SP: Flow Mapping Key on two lines +CML9: Missing comma in flow +CQ3W: Double quoted string without closing quote +CTN5: Flow sequence with invalid extra comma +D49Q: Multiline single quoted implicit keys +DMG6: Wrong indendation in Map +EB22: Missing document-end marker before directive +EW3V: Wrong indendation in mapping +G7JE: Multiline implicit keys +G9HC: Invalid anchor in zero indented sequence +GDY7: Comment that looks like a mapping key +GT5M: Node anchor in sequence +H7J7: Node anchor not indented +HRE5: Double quoted scalar with escaped single quote +HU3P: Invalid Mapping in plain scalar +JY7Z: Trailing content that looks like a mapping +LHL4: Invalid tag +N4JP: Bad indentation in mapping +N782: Invalid document markers in flow style +Q4CL: Trailing content after quoted value +QLJ7: Tag shorthand used in documents but only defined in the first +RXY3: Invalid document-end marker in single quoted string +SR86: Anchor plus Alias +SU74: Anchor and alias as mapping key +SY6V: Anchor before sequence entry on same line +TD5N: Invalid scalar after sequence +U44R: Bad indentation in mapping +W9L4: Literal block scalar with more spaces in first line +ZCZ6: Invalid mapping in plain single line value +ZL4Z: Invalid nested mapping +ZVH3: Wrong indented sequence item diff --git a/test/libyaml-parser-error.t b/test/libyaml-parser-error.t new file mode 100755 index 0000000..af48074 --- /dev/null +++ b/test/libyaml-parser-error.t @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -e + +if [[ $# -gt 0 ]]; then + ids=("$@") +else + ids=($(cut -d: -f1 < test/libyaml-parser-error.list)) +fi + +count=0 +for id in "${ids[@]}"; do + dir="data/$id" + label="$id: $(< $dir/===)" + [[ -e "$dir/in.yaml" ]] || continue + ok=true + ../../tests/run-parser-test-suite "$dir/in.yaml" > /tmp/test.out 2>&1 || ok=false + if $ok; then + echo "not ok $((++count)) $label" + sed 's/^/# /' /tmp/test.out + else + echo "ok $((++count)) $label" + fi +done + +echo "1..$count" diff --git a/update-test-list.sh b/update-test-list.sh new file mode 100755 index 0000000..e0c3151 --- /dev/null +++ b/update-test-list.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +test=$1 +type=$2 + +testfiles=tests/run-test-suite/data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9] +testdir=tests/run-test-suite/test + +testline() { + echo `basename $1`": "`cat $1/===` +} + +if [[ "$test" == parser ]]; then + + if [[ "$type" == valid ]]; then + + for i in $testfiles; do + [[ -f $i/error ]] || echo "$(testline $i)" + done > $testdir/libyaml-parser.list + + else + for i in $testfiles; do + [[ -f $i/error ]] && echo "$(testline $i)" + done > $testdir/libyaml-parser-error.list + fi + + +elif [[ "$test" == emitter ]]; then + for i in $testfiles; do + [[ -f $i/error ]] || echo "$(testline $i)" + done > $testdir/libyaml-emitter.list +fi + |