Commit e67b0ecf authored by Lucas Bourneuf's avatar Lucas Bourneuf

bugfixes + export test are now passing

parent b82e0714
......@@ -134,7 +134,7 @@ def _standalone_export_pipeline(scripts:[Script], options:dict={}, default_conte
yield f' return {new_context}'
# informations about the script, for biseau
yield f'NAME = {name}'
yield f'NAME = "{name}"'
yield f'TAGS = {repr(set.union(*(script.tags for script in scripts)))}'
outputs = set.union(*(set(script.outputs()) for script in scripts))
inputs = set.union(*(set(script.inputs()) for script in scripts))
......@@ -147,7 +147,8 @@ def _standalone_export_pipeline(scripts:[Script], options:dict={}, default_conte
ctype, default, help = options_as_dict(scripts[idx].options)[name]
main_args.append(f"{final_name}:{repr_argument_type(ctype)}={repr(default)}")
main_args = ', '.join(main_args)
yield f'def run_on(context:str, *, {main_args}):'
if main_args: main_args = ', *, ' + main_args
yield f'def run_on(context:str{main_args}):'
# call each *_run_on inside the run_on, taking care to provide its arguments
for runon, script in runons:
......
......@@ -41,9 +41,12 @@ def test_standalone_export_pipeline_with_different_script_format():
}),
*build_scripts_from_asp_code('link(X,Y) :- node(X) ; node(Y) ; X<Y.'),
))
assert scripts[0].options == (('nodename', str, 'b', ''),)
assert 'nodename' not in scripts[0].options_values
scripts[0].options_values['nodename'] = 'bb'
final_context = biseau.run(scripts)
print('FINAL CONTEXT:', final_context)
code = standalone_export_pipeline.without_formatting(scripts)
code = standalone_export_pipeline.without_formatting(scripts, options={'nodename': True})
print('\nCODE:', code)
env = {}
module = exec(code, env)
......@@ -51,7 +54,7 @@ def test_standalone_export_pipeline_with_different_script_format():
assert callable(env['run_on'])
assert callable(env['cli'])
assert biseau.__version__ in env['__doc__']
found_context = env['run_on']('', args=None)
found_context = env['run_on']('', nodename='bb')
print('FOUND CONTEXT:', found_context)
assert found_context == final_context
os.unlink(pyfile)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment