libyaml/tests/ReadMe.md
Tina Müller (tinita) cf53b3b5f9
Add -h and --flow (on|off|keep) to run-*-test-suite (#187)
With `--flow (keep|on)` run-parser-test-suite will output:

    +MAP {}
    +SEQ []

run-emitter-test-suite will then emit flow style collections if requested:

    echo 'foo: [bar, {x: y}]' | ./tests/run-parser-test-suite | ./tests/run-emitter-test-suite
    echo 'foo: [bar, {x: y}]' | ./tests/run-parser-test-suite \
        --flow keep | ./tests/run-emitter-test-suite --flow keep

Also: add that yaml_private.h include again that I had thrown out. Needed
for printing directives.
Wonder if there is a way to create a directive without using the private api.
2020-06-01 00:47:25 +02:00

1.2 KiB

Testing the Parser and Emitter

There are several programs to test the parser and emitter.

Parser

echo 'foo: bar' | ./tests/run-parser-test-suite

This will output the parsing events in yaml-test-suite format:

+STR
+DOC
+MAP
=VAL :foo
=VAL :bar
-MAP
-DOC
-STR

For flow style events, you have to enable it with the --flow option:

echo '{ foo: bar }' | ./tests/run-parser-test-suite --flow keep

...
+MAP {}
...

In the future, this will be the default.

You can also explicitly disable this style with --flow off, or output flow style always, with --flow on.

Emitter

run-emitter-test-suite takes yaml-test-suite event format and emits YAML.

./tests/run-parser-test-suite ... | ./tests/run-emitter-test-suite

Options

  • --directive (1.1|1.2)

    Prints a version directive before every document.

  • --flow on

    Will emit the whole document in flow style.

  • --flow off

    Will emit the whole document in block style.

  • --flow keep

    Will emit block/flow style like in the original document.

Example:

% echo 'foo: [bar, {x: y}]' |
  ./tests/run-parser-test-suite --flow keep |
  ./tests/run-emitter-test-suite --flow keep
foo: [bar, {x: y}]