diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-05-06 08:10:22 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-05-06 08:10:43 +0300 |
commit | c4a2d56fd712c29665043d7700c21a8bbadd934c (patch) | |
tree | 2b38104de2ccedec0f42716153f47a01250307e0 | |
parent | b7063dc7c0b77912d081632c9908911222ad9215 (diff) | |
download | vmdb2-c4a2d56fd712c29665043d7700c21a8bbadd934c.tar.gz |
tests: use Subplot
Sponsored-by: author
-rwxr-xr-x | check | 8 | ||||
-rwxr-xr-x | format.sh | 1 | ||||
-rw-r--r-- | vmdb2.md | 40 | ||||
-rw-r--r-- | vmdb2.subplot | 12 | ||||
-rw-r--r-- | vmdb2.yaml | 13 |
5 files changed, 32 insertions, 42 deletions
@@ -22,9 +22,13 @@ for file in vmdb/plugins/*.py; do done echo -if false && command -v subplot >/dev/null; then +if command -v subplot >/dev/null; then echo Running Subplot ============================================ - subplot vmdb2.md -o test.py --run + subplot codegen vmdb2.subplot -o test.py + rm -f test.log + if ! python3 test.py --log test.log; then + cat test.log + fi echo fi @@ -21,5 +21,6 @@ pandoc \ --css vmdb2.css \ --toc \ --number-sections \ + --metadata-file=vmdb2.subplot \ -o vmdb2.html \ tmp.md @@ -258,12 +258,10 @@ kind of testing, and that the teardown field in the step is implemented by the echo step. It's not a generic feature. ~~~scenario -given a specification file called happy.vmdb -when user runs vmdb2 -v happy.vmdb --output=happy.img +given file happy.vmdb +when I run vmdb2 -v happy.vmdb --output=happy.img then exit code is 0 -and stdout contains "foo" followed by "bar" -and stdout contains "bar" followed by "bar_teardown" -and stdout contains "bar_teardown" followed by "foo_teardown" +then stdout contains "foo\nbar\nbar_teardown\n" ~~~ ~~~{.file #happy.vmdb .yaml .numberLines} @@ -285,10 +283,10 @@ outputs the image file name given by the user. A more realistic specification file would instead do thing like create the file. ~~~scenario -given a specification file called j2.vmdb -when user runs vmdb2 -v j2.vmdb --output=foo.img +given file j2.vmdb +when I run vmdb2 -v j2.vmdb --output=foo.img then exit code is 0 -and stdout contains "image is foo.img" followed by "bar" +then stdout contains "image is foo.img\nbar" ~~~ ~~~{.file #j2.vmdb .yaml .numberLines} @@ -305,14 +303,14 @@ in the right order then? This scenario uses the "error" step provided for testing this kind of thing. ~~~scenario -given a specification file called unhappy.vmdb -when user runs vmdb2 -v unhappy.vmdb --output=unhappy.img +given file unhappy.vmdb +when I try to run vmdb2 -v unhappy.vmdb --output=unhappy.img then exit code is 1 -and stdout contains "foo" followed by "yikes" -and stdout contains "yikes" followed by "WAT?!" -and stdout contains "WAT?!" followed by "foo_teardown" -and stdout does NOT contain "bar_step" -and stdout does NOT contain "bar_teardown" +then stdout contains "foo\nyikes\n" +then stdout contains "WAT?!\n" +then stdout contains "foo_teardown\n" +then stdout doesn't contain "bar_step" +then stdout doesn't contain "bar_teardown" ~~~ ~~~{.file #unhappy.vmdb .yaml .numberLines} @@ -326,15 +324,3 @@ steps: ~~~ -# Step reference manual - - ---- -title: Building Debian system images with vmdb2 -author: Lars Wirzenius -bindings: vmdb2.yaml -functions: vmdb2.py -template: python -documentclass: report -... - diff --git a/vmdb2.subplot b/vmdb2.subplot new file mode 100644 index 0000000..909164c --- /dev/null +++ b/vmdb2.subplot @@ -0,0 +1,12 @@ +title: Building Debian system images with vmdb2 +authors: + - Lars Wirzenius +markdowns: + - vmdb2.md +bindings: + - lib/files.yaml + - lib/runcmd.yaml +impls: + python: + - lib/files.py + - lib/runcmd.py @@ -1,16 +1,3 @@ -- given: a specification file called {filename} - function: given_file - -- when: user runs vmdb2 -v {filename} --output={output} - function: run_vmdb2 - -- then: exit code is {exit_code} - function: exit_code_is - - then: stdout contains "(?P<pat1>.+)" followed by "(?P<pat2>.+)" regex: true function: stdout_contains - -- then: stdout does NOT contain "(?P<pat1>.+)" - regex: true - function: stdout_does_not_contain |