diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-06-02 13:25:15 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-06-02 13:25:15 +0300 |
commit | cd91e959daa2c21787c5fe878f1a4072d89b18d1 (patch) | |
tree | 79125b3d45316677602d5e135090549269459727 /ftt-codegen | |
parent | 05a197f96867a1b41dc8446d3bbcd9c0f5cdfc08 (diff) | |
download | fable-poc-cd91e959daa2c21787c5fe878f1a4072d89b18d1.tar.gz |
Add: fable.py scaffolding for running scenarios
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') |