From cd91e959daa2c21787c5fe878f1a4072d89b18d1 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 2 Jun 2019 13:25:15 +0300 Subject: Add: fable.py scaffolding for running scenarios --- ftt-codegen | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ftt-codegen') diff --git a/ftt-codegen b/ftt-codegen index ef6e3b9..f8a57b4 100755 --- a/ftt-codegen +++ b/ftt-codegen @@ -8,6 +8,12 @@ import CommonMark_bkrs as CommonMark import yaml +hardcoded = ''' +import fable +run = fable.Run() +''' + + class Scenario: def __init__(self): @@ -113,7 +119,7 @@ def codegen(f, step, bindings): for arg in args: f.write('"{}": "{}"\n'.format(arg, args[arg])) f.write('}\n') - f.write('{}(**args)\n'.format(function)) + f.write('{}(run.get_context(), **args)\n'.format(function)) def debug(msg): if False: @@ -126,6 +132,7 @@ bindings = yaml.safe_load(open(sys.argv[1])) debug('reading prelude') prelude = open(sys.argv[2]).read() +sys.stdout.write(hardcoded) sys.stdout.write(prelude) debug('reading inputs') @@ -147,10 +154,9 @@ for s in fable.get_scenarios(): f = sys.stdout for s in scenarios: name = s.get_name() - debug('scenario: {}'.format(name)) + f.write('run.start("{}")\n'.format(name)) for step in s.get_steps(): - debug(' step: {}'.format(step)) codegen(f, step, bindings) - f.write('print("OK: %s" % "{}")\n'.format(name)) + f.write('run.end()\n') debug('ok') -- cgit v1.2.1