summaryrefslogtreecommitdiff
path: root/subplot.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-02-26 07:46:24 +0200
committerLars Wirzenius <liw@liw.fi>2020-02-26 09:25:08 +0200
commit403353fee1719301c9f64a3766bc6f3b198b0f34 (patch)
treebadf6e9a6e8a1bfe5bd86ddc622e8e8d9446e5a7 /subplot.py
parentd22b5295981cfb80de6117fe73f361eb947d2ba9 (diff)
downloadsubplot-403353fee1719301c9f64a3766bc6f3b198b0f34.tar.gz
Add: scenarios for testing document date
Diffstat (limited to 'subplot.py')
-rw-r--r--subplot.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/subplot.py b/subplot.py
index 57b0fa5..34c1968 100644
--- a/subplot.py
+++ b/subplot.py
@@ -1,11 +1,19 @@
import os
import re
import subprocess
+import time
def create_file(ctx, filename=None):
with open(filename, 'wb') as f:
f.write(get_file(filename))
+def touch_file(
+ ctx, filename=None, y=None, mon=None, d=None,
+ h=None, min=None, s=None):
+ t = (int(y), int(mon), int(d), int(h), int(min), int(s), -1, -1, -1)
+ ts = time.mktime(t)
+ os.utime(filename, times=(ts, ts))
+
def try_docgen(ctx, md=None, output=None):
docgen = binary('sp-docgen')
runcmd(ctx, [docgen, md, '-o', output])
@@ -14,6 +22,11 @@ def run_docgen(ctx, md=None, output=None):
try_docgen(ctx, md=md, output=output)
exit_code_zero(ctx)
+def run_docgen_with_date(ctx, md=None, output=None, date=None):
+ docgen = binary('sp-docgen')
+ runcmd(ctx, [docgen, md, '-o', output, '--date', date])
+ exit_code_zero(ctx)
+
def try_codegen(ctx, filename=None):
codegen = binary('sp-codegen')
tmpldir = os.path.join(srcdir, 'templates')
@@ -45,6 +58,11 @@ def file_matches(ctx, filename=None, regex=None):
print('regex:', repr(regex))
assert_eq(bool(m), True)
+def file_contains(ctx, filename=None, pattern=None):
+ with open(filename) as f:
+ content = f.read()
+ assert_eq(pattern in content, True)
+
def scenario_was_run(ctx, name=None):
stdout_matches(ctx, '\nrunning scenario: {}\n'.format(name))