summaryrefslogtreecommitdiff
path: root/subplot.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-05-16 10:04:53 +0300
committerLars Wirzenius <liw@liw.fi>2020-05-17 12:11:02 +0300
commitf276c028dd4869a97129140cea28f02f3889ac47 (patch)
treef354dde229b1cd41e75e3aaa76c9487766bce7c6 /subplot.py
parent0402565f12623fb56da54e9a9a764edb39129186 (diff)
downloadsubplot-f276c028dd4869a97129140cea28f02f3889ac47.tar.gz
feat(subplot.md): add acceptance criteria for cleanup functionality
Add acceptance checks for the cleanup functionality, for Python and Bash templates.
Diffstat (limited to 'subplot.py')
-rw-r--r--subplot.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/subplot.py b/subplot.py
index 1495553..e586b53 100644
--- a/subplot.py
+++ b/subplot.py
@@ -35,14 +35,14 @@ def run_docgen_with_date(ctx, md=None, output=None, date=None):
exit_code_zero(ctx)
-def try_codegen_and_program(ctx, filename=None):
+def try_codegen_and_program(ctx, filename=None, testprog=None):
codegen = binary("sp-codegen")
tmpldir = os.path.join(srcdir, "templates")
- runcmd(ctx, [codegen, filename, "-o", "test.py", "--run", "--templates", tmpldir])
+ runcmd(ctx, [codegen, filename, "-o", testprog, "--run", "--templates", tmpldir])
-def run_codegen_and_program(ctx, filename=None):
- try_codegen_and_program(ctx, filename=filename)
+def run_codegen_and_program(ctx, filename=None, testprog=None):
+ try_codegen_and_program(ctx, filename=filename, testprog=testprog)
exit_code_zero(ctx)
@@ -111,6 +111,28 @@ def step_was_run(ctx, keyword=None, name=None):
stdout_matches(ctx, pattern="\n step: {} {}\n".format(keyword, name))
+def step_was_run_and_then(ctx, keyword1=None, name1=None, keyword2=None, name2=None):
+ stdout_matches(
+ ctx,
+ pattern="\n step: {} {}\n step: {} {}".format(
+ keyword1, name1, keyword2, name2
+ ),
+ )
+
+
+def cleanup_was_run(ctx, keyword1=None, name1=None, keyword2=None, name2=None):
+ stdout_matches(
+ ctx,
+ pattern="\n cleanup: {} {}\n cleanup: {} {}\n".format(
+ keyword1, name1, keyword2, name2
+ ),
+ )
+
+
+def cleanup_was_not_run(ctx, keyword=None, name=None):
+ stdout_does_not_match(ctx, pattern="\n cleanup: {} {}\n".format(keyword, name))
+
+
def exit_code_zero(ctx):
if ctx.get("exit") != 0:
print("context:", ctx.as_dict())