summaryrefslogtreecommitdiff
path: root/subplot.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-09-27 10:10:56 +0300
committerLars Wirzenius <liw@liw.fi>2020-09-28 10:24:14 +0300
commit6a19cfed49ecd556d24674811fd9e95793f7e262 (patch)
tree91f3eae8c6586bd3c4b3a2b5fab99db2b95ff0cc /subplot.py
parent64345866b3d0fdd9a8835cf1fac88f7db456322e (diff)
downloadsubplot-6a19cfed49ecd556d24674811fd9e95793f7e262.tar.gz
refactor(subplot.{md,py,yaml}): use step functions from lib/runcmd.py
Use the Python functions from lib/runcmd.py instead of the ones from ./runcmd.py. This changes some bindings in subplot.yaml to use functions from lib/runcmd.py, and changes some step functions in subplot.py to be defined in terms of functions in lib/runcmd.py. The actual steps in subplot.md are not changed and no bindings from lib/runcmd.yaml are yet used. Some bindings that used to come from runcmd.yaml are here added to subplot.yaml. This is temporary change that will be undone later by replacing those bindings with ones from lib/runcmd.yaml, but doing that in this commit would make it bigger and harder to follow.
Diffstat (limited to 'subplot.py')
-rw-r--r--subplot.py115
1 files changed, 58 insertions, 57 deletions
diff --git a/subplot.py b/subplot.py
index bb8f407..4ea0dc4 100644
--- a/subplot.py
+++ b/subplot.py
@@ -3,150 +3,151 @@ import os
def try_docgen(ctx, md=None, output=None):
- runcmd = globals()["runcmd"]
+ runcmd_run = globals()["runcmd_run"]
docgen = binary("sp-docgen")
- runcmd(ctx, [docgen, md, "-o", output])
+ runcmd_run(ctx, [docgen, md, "-o", output])
def run_docgen(ctx, md=None, output=None):
- exit_code_is = globals()["exit_code_is"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
try_docgen(ctx, md=md, output=output)
- exit_code_is(ctx, 0)
+ runcmd_exit_code_is(ctx, 0)
def run_docgen_with_date(ctx, md=None, output=None, date=None):
- exit_code_is = globals()["exit_code_is"]
- runcmd = globals()["runcmd"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
+ runcmd_run = globals()["runcmd_run"]
docgen = binary("sp-docgen")
- runcmd(ctx, [docgen, md, "-o", output, "--date", date])
- exit_code_is(ctx, 0)
+ runcmd_run(ctx, [docgen, md, "-o", output, "--date", date])
+ runcmd_exit_code_is(ctx, 0)
def try_codegen_and_program(ctx, filename=None, testprog=None):
- runcmd = globals()["runcmd"]
+ runcmd_run = globals()["runcmd_run"]
srcdir = globals()["srcdir"]
codegen = binary("sp-codegen")
tmpldir = os.path.join(srcdir, "templates")
- runcmd(ctx, [codegen, filename, "-o", testprog, "--run", "--templates", tmpldir])
+ runcmd_run(
+ ctx, [codegen, filename, "-o", testprog, "--run", "--templates", tmpldir]
+ )
def run_codegen_and_program(ctx, filename=None, testprog=None):
- exit_code_is = globals()["exit_code_is"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
try_codegen_and_program(ctx, filename=filename, testprog=testprog)
- exit_code_is(ctx, 0)
+ runcmd_exit_code_is(ctx, 0)
def run_codegen(ctx, filename=None, testprog=None):
- runcmd = globals()["runcmd"]
+ runcmd_run = globals()["runcmd_run"]
srcdir = globals()["srcdir"]
- exit_code_is = globals()["exit_code_is"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
codegen = binary("sp-codegen")
tmpldir = os.path.join(srcdir, "templates")
- runcmd(ctx, [codegen, filename, "-o", testprog, "--templates", tmpldir])
- exit_code_is(ctx, 0)
+ runcmd_run(ctx, [codegen, filename, "-o", testprog, "--templates", tmpldir])
+ runcmd_exit_code_is(ctx, 0)
def run_python_test_program(ctx, testprog=None, pattern=None):
- runcmd = globals()["runcmd"]
- exit_code_is = globals()["exit_code_is"]
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
- runcmd(ctx, ["python3", testprog, pattern])
- exit_code_is(ctx, 0)
+ runcmd_run(ctx, ["python3", testprog, pattern])
+ runcmd_exit_code_is(ctx, 0)
def run_bash_test_program(ctx, testprog=None, pattern=None):
- runcmd = globals()["runcmd"]
- exit_code_is = globals()["exit_code_is"]
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
- runcmd(ctx, ["bash", testprog, pattern])
- exit_code_is(ctx, 0)
+ runcmd_run(ctx, ["bash", testprog, pattern])
+ runcmd_exit_code_is(ctx, 0)
def run_meta(ctx, filename=None):
- runcmd = globals()["runcmd"]
- exit_code_is = globals()["exit_code_is"]
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
meta = binary("sp-meta")
- runcmd(ctx, [meta, filename])
- exit_code_is(ctx, 0)
+ runcmd_run(ctx, [meta, filename])
+ runcmd_exit_code_is(ctx, 0)
def run_meta_json(ctx, filename=None):
- runcmd = globals()["runcmd"]
- exit_code_is = globals()["exit_code_is"]
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
meta = binary("sp-meta")
- runcmd(ctx, [meta, filename, "-o", "json"])
- exit_code_is(ctx, 0)
+ runcmd_run(ctx, [meta, filename, "-o", "json"])
+ runcmd_exit_code_is(ctx, 0)
def run_extract(ctx, filename=None, embedded=None, dirname=None):
- runcmd = globals()["runcmd"]
- exit_code_is = globals()["exit_code_is"]
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
extract = binary("sp-extract")
- runcmd(ctx, [extract, filename, embedded, "-o", dirname])
- exit_code_is(ctx, 0)
+ runcmd_run(ctx, [extract, filename, embedded, "-o", dirname])
+ runcmd_exit_code_is(ctx, 0)
def run_pandoc_with_filter(ctx, filename=None, output=None):
- runcmd = globals()["runcmd"]
- exit_code_is = globals()["exit_code_is"]
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is = globals()["runcmd_exit_code_is"]
sp_filter = binary("sp-filter")
- runcmd(ctx, ["pandoc", "--filter", sp_filter, filename, "-o", output])
- exit_code_is(ctx, 0)
+ runcmd_run(ctx, ["pandoc", "--filter", sp_filter, filename, "-o", output])
+ runcmd_exit_code_is(ctx, 0)
def scenario_was_run(ctx, name=None):
- stdout_contains = globals()["stdout_contains"]
- stdout_contains(ctx, pattern="\nscenario: {}\n".format(name))
+ runcmd_stdout_contains = globals()["runcmd_stdout_contains"]
+ runcmd_stdout_contains(ctx, text="\nscenario: {}\n".format(name))
def scenario_was_not_run(ctx, name=None):
- stdout_does_not_contain = globals()["stdout_does_not_contain"]
- stdout_does_not_contain(ctx, pattern="\nscenario: {}\n".format(name))
+ runcmd_stdout_doesnt_contain = globals()["runcmd_stdout_doesnt_contain"]
+ runcmd_stdout_doesnt_contain(ctx, text="\nscenario: {}\n".format(name))
def step_was_run(ctx, keyword=None, name=None):
- stdout_contains = globals()["stdout_contains"]
- stdout_contains(ctx, pattern="\n step: {} {}\n".format(keyword, name))
+ runcmd_stdout_contains = globals()["runcmd_stdout_contains"]
+ runcmd_stdout_contains(ctx, text="\n step: {} {}\n".format(keyword, name))
def step_was_run_and_then(ctx, keyword1=None, name1=None, keyword2=None, name2=None):
- stdout_contains = globals()["stdout_contains"]
- stdout_contains(
+ runcmd_stdout_contains = globals()["runcmd_stdout_contains"]
+ runcmd_stdout_contains(
ctx,
- pattern="\n step: {} {}\n step: {} {}".format(
- keyword1, name1, keyword2, name2
- ),
+ text="\n step: {} {}\n step: {} {}".format(keyword1, name1, keyword2, name2),
)
def cleanup_was_run(ctx, keyword1=None, name1=None, keyword2=None, name2=None):
- stdout_contains = globals()["stdout_contains"]
- stdout_contains(
+ runcmd_stdout_contains = globals()["runcmd_stdout_contains"]
+ runcmd_stdout_contains(
ctx,
- pattern="\n cleanup: {} {}\n cleanup: {} {}\n".format(
+ text="\n cleanup: {} {}\n cleanup: {} {}\n".format(
keyword1, name1, keyword2, name2
),
)
def cleanup_was_not_run(ctx, keyword=None, name=None):
- stdout_does_not_contain = globals()["stdout_does_not_contain"]
- stdout_does_not_contain(ctx, pattern="\n cleanup: {} {}\n".format(keyword, name))
+ runcmd_stdout_doesnt_contain = globals()["runcmd_stdout_doesnt_contain"]
+ runcmd_stdout_doesnt_contain(ctx, text="\n cleanup: {} {}\n".format(keyword, name))
def json_output_matches_file(ctx, filename=None):
assert_dict_eq = globals()["assert_dict_eq"]
- actual = json.loads(ctx["stdout"])
+ ns = ctx.declare("_runcmd")
+ actual = json.loads(ns["stdout"])
expected = json.load(open(filename))
assert_dict_eq(actual, expected)