diff options
Diffstat (limited to 'ftt-codegen')
-rwxr-xr-x | ftt-codegen | 14 |
1 files changed, 10 insertions, 4 deletions
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') |