Skip to content

Commit

Permalink
Allow setting default_test_output_json in ~/.planemo.yml.
Browse files Browse the repository at this point in the history
Set to null to disable JSON generation forever.
  • Loading branch information
jmchilton committed Jan 12, 2015
1 parent ea02cea commit 21bb463
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions planemo/commands/cmd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@
" functional.test_toolbox"
)

OUTPUT_DFEAULTS = {
"output": "tool_test_output.html",
"output_json": "tool_test_output.json",
"output_xunit": None,
}


@click.command('test')
@options.optional_tools_arg()
@click.option(
"--test_output",
type=click.Path(file_okay=True, resolve_path=True),
help="Output test report (HTML - for humans).",
default="tool_test_output.html",
help=("Output test report (HTML - for humans) defaults to "
"tool_test_output.html."),
default=None,
)
@click.option(
"--test_output_xunit",
Expand All @@ -51,8 +58,9 @@
@click.option(
"--test_output_json",
type=click.Path(file_okay=True, resolve_path=True),
help="Output test report (planemo json).",
default="tool_test_output.json",
help=("Output test report (planemo json) defaults to "
"tool_test_output.json."),
default=None,
)
@click.option(
"--job_output_files",
Expand Down Expand Up @@ -101,6 +109,9 @@ def cli(ctx, path, **kwds):
against that same Galaxy root - but this may not be bullet proof yet so
please careful and do not try this against production Galaxy instances.
"""
for name, default in OUTPUT_DFEAULTS.items():
__populate_default_output(ctx, name, kwds, default)

kwds["for_tests"] = True
with galaxy_config.galaxy_config(ctx, path, **kwds) as config:
config_directory = config.config_directory
Expand Down Expand Up @@ -169,6 +180,22 @@ def cli(ctx, path, **kwds):
sys.exit(1)


def __populate_default_output(ctx, type, kwds, default):
kwd_key = "test_%s" % type
kwd_value = kwds.get(kwd_key, None)
if kwd_value is None:
global_config = ctx.global_config
global_config_key = "default_test_%s" % type
if global_config_key in global_config:
default_value = global_config[global_config_key]
else:
default_value = default

if default_value:
default_value = os.path.abspath(default_value)
kwds[kwd_key] = default_value


def __handle_summary(
test_results,
**kwds
Expand Down

0 comments on commit 21bb463

Please sign in to comment.