path: root/ftt-codegen
diff options
authorLars Wirzenius <>2019-06-16 14:57:55 +0300
committerLars Wirzenius <>2019-06-16 19:30:22 +0300
commit80858ea67d85800089d7842fc66505fa83103aa0 (patch)
tree2c2143d38eed9f3b17ca87b05cbf9b755ed84665 /ftt-codegen
parentb28e50ac4cf013eb68f6d3a10b07f8683bd60122 (diff)
Change: make generated test program more convenient
Also, the jt fable now works, against my locally modified version of jt (soon to be pushed to The generated program now has options --tempdir (default is something in /tmp). If --tempdir is used, it doesn't removed at the end. Each scenario gets a temporary directory created under the temporary directory. The generated program also has the options --log for specifying a log file, and --scenario to specify which scenarios to run (use once per scenario).
Diffstat (limited to 'ftt-codegen')
1 files changed, 7 insertions, 4 deletions
diff --git a/ftt-codegen b/ftt-codegen
index c54a383..694cc05 100755
--- a/ftt-codegen
+++ b/ftt-codegen
@@ -118,8 +118,10 @@ def codegen(f, step, bindings):
keyword = words[0]
rest = ' '.join(words[1:])
function, args = find_binding(bindings, keyword, rest)
- f.write('args = {}\n'.format(json.dumps(args)))
- f.write('{}(run.get_context(), **args)\n'.format(function))
+ f.write('"step %s", {})\n'.format(json.dumps(step)))
+ f.write(' args = {}\n'.format(json.dumps(args)))
+ f.write(' logging.debug("calling {} with args %s", args)\n'.format(function))
+ f.write(' {}(run.get_context(), **args)\n\n'.format(function))
def debug(msg):
if False:
@@ -134,6 +136,7 @@ debug('reading prelude')
prelude = open(sys.argv[2]).read()
debug('reading inputs')
text = ''.join(open(filename).read() for filename in sys.argv[3:])
@@ -154,9 +157,9 @@ for s in fable.get_scenarios():
f = sys.stdout
for s in scenarios:
name = s.get_name()
- f.write('run.start("{}")\n'.format(name))
+ f.write('\nif run.start("{}"):\n'.format(name))
for step in s.get_steps():
codegen(f, step, bindings)
- f.write('run.end()\n')
+ f.write(' run.end()\n')