From 80858ea67d85800089d7842fc66505fa83103aa0 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 16 Jun 2019 14:57:55 +0300 Subject: 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 git.liw.fi). 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). --- ftt-codegen | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ftt-codegen') 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(' logging.info("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() sys.stdout.write(hardcoded) sys.stdout.write(prelude) +sys.stdout.write('\n') 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') debug('ok') -- cgit v1.2.1