From 76a22e7053c8be6db3cbf1ec6cec085ba6f49898 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 9 Apr 2021 18:23:19 +0100 Subject: testing: Rework sp-{doc,code}gen into subplot {doc,code}gen in tests Signed-off-by: Daniel Silverstone --- stress | 4 +- subplot.md | 130 ++++++++++++++++++++++++++++++------------------------------- subplot.py | 6 +-- 3 files changed, 70 insertions(+), 70 deletions(-) diff --git a/stress b/stress index e70984a..acda0ed 100755 --- a/stress +++ b/stress @@ -18,11 +18,11 @@ ts() { } docgen() { - cargo run -q --bin sp-docgen -- "$1" -o "$2" + cargo run -q --bin subplot -- docgen "$1" -o "$2" } codegen() { - cargo run -q --bin sp-codegen -- "$1" -o "$2" -t templates + cargo run -q --bin subplot -- codegen "$1" -o "$2" } start="$(ts 0)" diff --git a/subplot.md b/subplot.md index 2db50f6..bc744b1 100644 --- a/subplot.md +++ b/subplot.md @@ -72,7 +72,7 @@ use, for example, LaTeX. Subplot interprets parts of the Markdown input file itself. Subplot actually consists mainly of two separate programs: -**sp-docgen** for generating output documents, and **sp-codegen** for +**subplot docgen** for generating output documents, and **subplot codegen** for generating the test program. There are a couple of additional tools (**sp-meta** for reporting meta data about a Subplot document, and **sp-filter** for doing the document generation as a Pandoc filter). @@ -90,10 +90,10 @@ bindings [shape=box]; impl [label="foo.py \n (step implemenations, Python)"] impl [shape=box]; -docgen [label="sp-docgen"]; +docgen [label="subplot docgen"]; docgen [shape=ellipse]; -codegen [label="sp-codegen"]; +codegen [label="subplot codegen"]; codegen [shape=ellipse]; pdf [label="foo.pdf \n PDF (generated)"] @@ -224,7 +224,7 @@ using itself: ~~~sh $ cargo build -q -$ cargo run --bin sp-codegen -- subplot.md -o test.py +$ cargo run --bin subplot codegen -- subplot.md -o test.py $ python3 test.py ... much output OK, all scenarios finished successfully @@ -237,7 +237,7 @@ tree: ~~~sh $ cargo build -q -$ cargo run --bin sp-codegen -- subplot.md -o test.py +$ cargo run --bin subplot codegen -- subplot.md -o test.py $ python3 test.py --env SUBPLOT_DIR=/usr/local/bin ... much output OK, all scenarios finished successfully @@ -248,7 +248,7 @@ You can do this with an installed Subplot as well: ~~~sh $ cargo clean -$ /usr/local/bin/sp-codegen subplot.md -o test.py +$ /usr/local/bin/subplot codegen subplot.md -o test.py $ python3 test.py --env SUBPLOT_DIR=/usr/local/bin ... much output OK, all scenarios finished successfully @@ -611,8 +611,8 @@ load the binding. Typically the type map is used by the code generators to, for example, distinguish between `"12"` and `12` (i.e. between a string and what should be a number). This permits the generated test suites to use native language types directly. The -`file` type, if used, must refer to an embedded file in the document; sp-docgen -will emit a warning if the file is not found, and sp-codegen will emit an error. +`file` type, if used, must refer to an embedded file in the document; subplot docgen +will emit a warning if the file is not found, and subplot codegen will emit an error. ### Embedded file name didn't match @@ -621,9 +621,9 @@ given file badfilename.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen badfilename.md -o foo.pdf +when I run subplot docgen badfilename.md -o foo.pdf then file foo.pdf exists -when I try to run sp-codegen --run badfilename.md -o test.py +when I try to run subplot codegen --run badfilename.md -o test.py then command fails ``` @@ -848,11 +848,11 @@ given file simple.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen simple.md -o simple.pdf +when I run subplot docgen simple.md -o simple.pdf then file simple.pdf exists -when I run sp-docgen simple.md -o simple.html +when I run subplot docgen simple.md -o simple.html then file simple.html exists -when I run sp-codegen --run simple.md -o test.py +when I run subplot codegen --run simple.md -o test.py then scenario "Simple" was run and step "given precondition foo" was run and step "when I do bar" was run @@ -876,9 +876,9 @@ given file allkeywords.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen allkeywords.md -o foo.pdf +when I run subplot docgen allkeywords.md -o foo.pdf then file foo.pdf exists -when I run sp-codegen --run allkeywords.md -o test.py +when I run subplot codegen --run allkeywords.md -o test.py then scenario "All keywords" was run and step "given precondition foo" was run and step "when I do bar" was run @@ -914,7 +914,7 @@ given file aliases.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen aliases.md -o aliases.html +when I run subplot docgen aliases.md -o aliases.html then file aliases.html matches regex /given<[^>]*> precondition foo/ and file aliases.html matches regex /when<[^>]*> I do bar/ and file aliases.html matches regex /and<[^>]*> I do foobar/ @@ -953,9 +953,9 @@ given file continuationmisuse.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen continuationmisuse.md -o foo.pdf +when I run subplot docgen continuationmisuse.md -o foo.pdf then file foo.pdf exists -when I try to run sp-codegen --run continuationmisuse.md -o test.py +when I try to run subplot codegen --run continuationmisuse.md -o test.py then command fails ~~~ @@ -989,11 +989,11 @@ given file emptylines.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen emptylines.md -o emptylines.pdf +when I run subplot docgen emptylines.md -o emptylines.pdf then file emptylines.pdf exists -when I run sp-docgen emptylines.md -o emptylines.html +when I run subplot docgen emptylines.md -o emptylines.html then file emptylines.html exists -when I run sp-codegen --run emptylines.md -o test.py +when I run subplot codegen --run emptylines.md -o test.py then scenario "Simple" was run and step "given precondition foo" was run and step "when I do bar" was run @@ -1086,7 +1086,7 @@ given file cleanup-success-python.md and file cleanup.yaml and file cleanup.py and an installed subplot -when I run sp-codegen --run cleanup-success-python.md -o test.py +when I run subplot codegen --run cleanup-success-python.md -o test.py then scenario "Cleanup" was run and step "given foo" was run, and then step "given bar" and cleanup for "given bar" was run, and then for "given foo" @@ -1118,7 +1118,7 @@ given file cleanup-fail-python.md and file cleanup.yaml and file cleanup.py and an installed subplot -when I try to run sp-codegen --run cleanup-fail-python.md -o test.py +when I try to run subplot codegen --run cleanup-fail-python.md -o test.py then scenario "Cleanup" was run and step "given foo" was run, and then step "given bar" and cleanup for "given bar" was run, and then for "given foo" @@ -1151,7 +1151,7 @@ given file cleanup-success-bash.md and file cleanup.yaml and file cleanup.sh and an installed subplot -when I run sp-codegen --run cleanup-success-bash.md -o test.sh +when I run subplot codegen --run cleanup-success-bash.md -o test.sh then scenario "Cleanup" was run and step "given foo" was run, and then step "given bar" and cleanup for "given bar" was run, and then for "given foo" @@ -1185,7 +1185,7 @@ given file cleanup-fail-bash.md and file cleanup.yaml and file cleanup.sh and an installed subplot -when I try to run sp-codegen --run cleanup-fail-bash.md -o test.sh +when I try to run subplot codegen --run cleanup-fail-bash.md -o test.sh then scenario "Cleanup" was run and step "given foo" was run, and then step "given bar" and cleanup for "given bar" was run, and then for "given foo" @@ -1227,7 +1227,7 @@ given file tmpdir.md and file tmpdir.yaml and file tmpdir.py and an installed subplot -when I run sp-codegen --run tmpdir.md -o test.py +when I run subplot codegen --run tmpdir.md -o test.py then command is successful and scenario "TMPDIR" was run and step "then TMPDIR is set" was run @@ -1276,7 +1276,7 @@ given file simplepattern.md and file simplepattern.yaml and file capture.py and an installed subplot -when I run sp-codegen --run simplepattern.md -o test.py +when I run subplot codegen --run simplepattern.md -o test.py then scenario "Simple pattern" was run and step "given I am Tomjon" was run and stdout contains "function got argument name as Tomjon" @@ -1320,7 +1320,7 @@ given file confusedpattern.md and file confusedpattern.yaml and file capture.py and an installed subplot -when I try to run sp-codegen --run confusedpattern.md -o test.py +when I try to run subplot codegen --run confusedpattern.md -o test.py then command fails and stderr contains "simple pattern contains regex" ~~~ @@ -1352,7 +1352,7 @@ given file confusedbutok.md and file confusedbutok.yaml and file capture.py and an installed subplot -when I run sp-codegen --run confusedbutok.md -o test.py +when I run subplot codegen --run confusedbutok.md -o test.py then command is successful ~~~ @@ -1384,7 +1384,7 @@ given file regex.md and file regex.yaml and file capture.py and an installed subplot -when I run sp-codegen --run regex.md -o test.py +when I run subplot codegen --run regex.md -o test.py then scenario "Regex" was run and step "given I am Tomjon" was run and stdout contains "function got argument name as Tomjon" @@ -1432,7 +1432,7 @@ given file values.md and file values.yaml and file values.py and an installed subplot -when I run sp-codegen values.md -o test.py +when I run subplot codegen values.md -o test.py when I run python3 test.py then command is successful ~~~ @@ -1488,7 +1488,7 @@ installation directory should be added to the PATH variable so that scenarios can invoke the scripts easily. The scenario in this section verifies that the Python test program -generated by `sp-codegen` accepts the option `--env NAME=VALUE`. +generated by `subplot codegen` accepts the option `--env NAME=VALUE`. There is currently no equivalent functionality for the generated Bash test program. Patches for that are welcome. @@ -1498,7 +1498,7 @@ given file env.md and file env.yaml and file env.py and an installed subplot -when I run sp-codegen env.md -o test.py +when I run subplot codegen env.md -o test.py when I try to run python3 test.py then command fails when I try to run python3 test.py --env FOO=foo @@ -1549,10 +1549,10 @@ given file simple.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen simple.md -o simple.pdf +when I run subplot docgen simple.md -o simple.pdf then file simple.pdf exists when I remember metadata for file simple.pdf -and I run sp-docgen simple.md -o simple.pdf +and I run subplot docgen simple.md -o simple.pdf then file simple.pdf has same metadata as before and only files simple.md, b.yaml, f.py, simple.pdf exist ~~~ @@ -1564,11 +1564,11 @@ given file simple.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen simple.md -o simple.pdf +when I run subplot docgen simple.md -o simple.pdf then file simple.pdf exists when I remember metadata for file simple.pdf and I touch file simple.md -and I run sp-docgen simple.md -o simple.pdf +and I run subplot docgen simple.md -o simple.pdf then file simple.pdf has changed from before ~~~ @@ -1579,11 +1579,11 @@ given file simple.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen simple.md -o simple.pdf +when I run subplot docgen simple.md -o simple.pdf then file simple.pdf exists when I remember metadata for file simple.pdf and I touch file f.py -and I run sp-docgen simple.md -o simple.pdf +and I run subplot docgen simple.md -o simple.pdf then file simple.pdf has changed from before ~~~ @@ -1594,11 +1594,11 @@ given file simple.md and file b.yaml and file f.py and an installed subplot -when I run sp-docgen simple.md -o simple.pdf +when I run subplot docgen simple.md -o simple.pdf then file simple.pdf exists when I remember metadata for file simple.pdf and I touch file b.yaml -and I run sp-docgen simple.md -o simple.pdf +and I run subplot docgen simple.md -o simple.pdf then file simple.pdf has changed from before ~~~ @@ -1618,7 +1618,7 @@ given file scenarioislowest.md and file b.yaml and file f.py and an installed subplot -when I run sp-codegen --run scenarioislowest.md -o test.py +when I run subplot codegen --run scenarioislowest.md -o test.py then scenario "heading 1.1.1" was run and command is successful ~~~ @@ -1648,7 +1648,7 @@ given file subisnotnewscenario.md and file b.yaml and file f.py and an installed subplot -when I run sp-codegen --run subisnotnewscenario.md -o test.py +when I run subplot codegen --run subisnotnewscenario.md -o test.py then scenario "heading 1.1a" was run and command is successful ~~~ @@ -1681,7 +1681,7 @@ given file samelevelisnewscenario.md and file b.yaml and file f.py and an installed subplot -when I run sp-codegen --run samelevelisnewscenario.md -o test.py +when I run subplot codegen --run samelevelisnewscenario.md -o test.py then scenario "heading 1.1.1" was run and scenario "heading 1.1.2" was run and command is successful @@ -1718,7 +1718,7 @@ given file higherisnewscenario.md and file b.yaml and file f.py and an installed subplot -when I run sp-codegen --run higherisnewscenario.md -o test.py +when I run subplot codegen --run higherisnewscenario.md -o test.py then scenario "heading 1.1.1" was run and scenario "heading 1.2" was run and command is successful @@ -1761,7 +1761,7 @@ ikiwiki, and ikiwiki has a different way of specifying page titles. ~~~scenario given file notitle.md and an installed subplot -when I try to run sp-docgen notitle.md -o foo.md +when I try to run subplot docgen notitle.md -o foo.md then command fails ~~~ @@ -1788,7 +1788,7 @@ then bar was done ~~~scenario given file notitle.md and an installed subplot -when I try to run sp-codegen --run notitle.md -o test.py +when I try to run subplot codegen --run notitle.md -o test.py then command fails ~~~ @@ -1803,9 +1803,9 @@ given file fancytitle.md and file b.yaml and file f.py and an installed subplot -when I try to run sp-docgen fancytitle.md -o foo.md +when I try to run subplot docgen fancytitle.md -o foo.md then command is successful -when I try to run sp-codegen fancytitle.md -o foo.md +when I try to run subplot codegen fancytitle.md -o foo.md then command is successful ~~~ @@ -1850,7 +1850,7 @@ given file twoscenarios-python.md and file b.yaml and file f.py and an installed subplot -when I run sp-codegen twoscenarios-python.md -o test.py +when I run subplot codegen twoscenarios-python.md -o test.py and I run python3 test.py on then scenario "One" was run and scenario "Two" was not run @@ -1892,7 +1892,7 @@ given file twoscenarios-bash.md and file b.yaml and file f.sh and an installed subplot -when I run sp-codegen twoscenarios-bash.md -o test.sh +when I run subplot codegen twoscenarios-bash.md -o test.sh and I run bash test.sh on then scenario "One" was run and scenario "Two" was not run @@ -1982,7 +1982,7 @@ specified. ~~~scenario given file metadate.md and an installed subplot -when I run sp-docgen metadate.md -o metadate.html +when I run subplot docgen metadate.md -o metadate.html then file metadate.html exists and file metadate.html contains "The Fabulous Title" and file metadate.html contains "Alfred Pennyworth" @@ -2009,7 +2009,7 @@ This scenario tests that the `--date` command line option is used. ~~~scenario given file dateless.md and an installed subplot -when I run sp-docgen dateless.md -o dateoption.html --date=FANCYDATE +when I run subplot docgen dateless.md -o dateoption.html --date=FANCYDATE then file dateoption.html exists and file dateoption.html contains "The Fabulous Title" and file dateoption.html contains "Alfred Pennyworth" @@ -2039,7 +2039,7 @@ modification time of the input file, and shall have the date in ISO given file dateless.md and file dateless.md has modification time 2020-02-26 07:53:17 and an installed subplot -when I run sp-docgen dateless.md -o mtime.html +when I run subplot docgen dateless.md -o mtime.html then file mtime.html exists and file mtime.html contains "The Fabulous Title" and file mtime.html contains "Alfred Pennyworth" @@ -2055,7 +2055,7 @@ missing file. ~~~scenario given file missing-binding.md and an installed subplot -when I try to run sp-docgen missing-binding.md -o foo.htmlh +when I try to run subplot docgen missing-binding.md -o foo.htmlh then command fails and stderr contains ": missing-binding.yaml:" ~~~ @@ -2076,7 +2076,7 @@ missing file. given file missing-functions.md and file b.yaml and an installed subplot -when I try to run sp-codegen --run missing-functions.md -o foo.py +when I try to run subplot codegen --run missing-functions.md -o foo.py then command fails and stderr contains ": missing-functions.py:" ~~~ @@ -2236,7 +2236,7 @@ in a subplot. ~~~scenario given file embedded.md and an installed subplot -when I run sp-docgen embedded.md -o foo.html +when I run subplot docgen embedded.md -o foo.html then file foo.html exists and file foo.html matches regex /embedded\.txt/ ~~~ @@ -2364,7 +2364,7 @@ This file does not end in a newline. ~~~scenario given file onefiletwice.md and an installed subplot -when I try to run sp-docgen onefiletwice.md -o onefiletwice.html +when I try to run subplot docgen onefiletwice.md -o onefiletwice.html then command fails and file onefiletwice.html does not exist ~~~ @@ -2389,7 +2389,7 @@ This is another embedded file, and has the same name. ~~~scenario given file casediff.md and an installed subplot -when I try to run sp-docgen casediff.md -o casediff.html +when I try to run subplot docgen casediff.md -o casediff.html then command fails and file casediff.html does not exist ~~~ @@ -2446,7 +2446,7 @@ then nothing works given file nobinding.md and file badbindings.yaml and an installed subplot -when I try to run sp-codegen --run nobinding.md -o test.py +when I try to run subplot codegen --run nobinding.md -o test.py then command fails ``` @@ -2470,7 +2470,7 @@ given a capitalised binding given file casemismatch.md and file badbindings.yaml and an installed subplot -when I try to run sp-codegen --run casemismatch.md -o test.py +when I try to run subplot codegen --run casemismatch.md -o test.py then command fails ``` @@ -2494,7 +2494,7 @@ given a binding given file twobindings.md and file badbindings.yaml and an installed subplot -when I try to run sp-codegen --run twobindings.md -o test.py +when I try to run subplot codegen --run twobindings.md -o test.py then command fails ``` @@ -2538,7 +2538,7 @@ into SVGs such as this one. ~~~pikchr arrow right 200% "Markdown" "Source" -box rad 10px "Subplot" "Document Generator" "(sp-docgen)" fit +box rad 10px "Subplot" "Document Generator" "(subplot docgen)" fit arrow right 200% "HTML+SVG/PDF" "Output" arrow <-> down 70% from last box.s box same "Pikchr" "Formatter" "(docs.rs/pikchr)" fit @@ -2781,11 +2781,11 @@ given file unknown-class-name.md and file known-class-name.md and file b.yaml and an installed subplot -when I try to run sp-docgen unknown-class-name.md -o unknown-class-name.html +when I try to run subplot docgen unknown-class-name.md -o unknown-class-name.html then command fails and file unknown-class-name.html does not exist and stderr contains "Unknown classes found in the document: foobar" -when I run sp-docgen known-class-name.md -o known-class-name.html +when I run subplot docgen known-class-name.md -o known-class-name.html then file known-class-name.html exists ~~~ diff --git a/subplot.py b/subplot.py index 975b579..40678c2 100644 --- a/subplot.py +++ b/subplot.py @@ -4,7 +4,7 @@ import shutil import tempfile -# A shell script to run the sp-codegen binary from the source directory's Rust +# A shell script to run the subplot binary from the source directory's Rust # build target directory, adding the -t option to use the source directory's # template directory. # @@ -12,7 +12,7 @@ import tempfile wrapper = """\ #!/bin/sh set -eu -exec '{srcdir}/target/debug/{prog}' "$@" --resources '{srcdir}/share' +exec '{srcdir}/target/debug/{prog}' --resources '{srcdir}/share' "$@" """ @@ -33,7 +33,7 @@ def install_subplot(ctx): # Create a "bin" directory for the wrapper. Can't put this into datadir, as # some of Subplot's scenarios make assumptions on what files exist there. bindir = ctx["bin-dir"] = tempfile.mkdtemp() - for prog in ["sp-codegen", "sp-docgen"]: + for prog in ["subplot"]: filename = os.path.join(bindir, prog) with open(filename, "w") as f: f.write(wrapper.format(prog=prog, srcdir=srcdir)) -- cgit v1.2.1