comparison env/lib/python3.9/site-packages/planemo/commands/cmd_test.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 """Module describing the planemo ``test`` command."""
2 import click
3
4 from planemo import options
5 from planemo.cli import command_function
6 from planemo.engine.test import (
7 test_runnables,
8 )
9 from planemo.io import temp_directory
10 from planemo.runnable import (
11 RunnableType,
12 )
13 from planemo.runnable_resolve import for_runnable_identifiers
14
15
16 @click.command('test')
17 @options.optional_tools_arg(multiple=True, allow_uris=True)
18 @click.option(
19 "--failed",
20 is_flag=True,
21 help="Re-run only failed tests. This command will read "
22 "tool_test_output.json to determine which tests failed so this "
23 "file must have been produced with the same set of tool ids "
24 "previously.",
25 default=False,
26 )
27 @click.option(
28 "--polling_backoff",
29 type=int,
30 help="Poll resources with an increasing interval between requests. "
31 "Useful when testing against remote and/or production "
32 "instances to limit generated traffic.",
33 default="0",
34 )
35 @options.galaxy_target_options()
36 @options.galaxy_config_options()
37 @options.test_options()
38 @options.engine_options()
39 @command_function
40 def cli(ctx, uris, **kwds):
41 """Run specified tool's tests within Galaxy.
42
43 All referenced tools (by default all the tools in the current working
44 directory) will be tested and the results quickly summarized.
45
46 To run these tests planemo needs a Galaxy instance to utilize, planemo
47 will search parent directories to see if any is a Galaxy instance
48 - but one can pick the Galaxy instance to use with the --galaxy_root
49 option or force planemo to download a disposable instance with the
50 ``--install_galaxy`` flag.
51
52 In addition to to quick summary printed to the console - various detailed
53 output summaries can be configured. ``tool_test_output.html`` (settable
54 via ``--test_output``) will contain a human consumable HTML report
55 describing the test run. A JSON file (settable via ``--test_output_json``
56 and defaulting to ``tool_test_output.json``) will also be created. These
57 files can can be disabled by passing in empty arguments or globally by
58 setting the values ``default_test_output`` and/or
59 ``default_test_output_json`` in ``~/.planemo.yml`` to ``null``. For
60 continuous integration testing a xUnit-style report can be configured using
61 the ``--test_output_xunit``.
62
63 planemo uses temporarily generated config files and environment variables
64 to attempt to shield this execution of Galaxy from manually launched runs
65 against that same Galaxy root - but this may not be bullet proof yet so
66 please careful and do not try this against production Galaxy instances.
67 """
68 with temp_directory(dir=ctx.planemo_directory) as temp_path:
69 # Create temp dir(s) outside of temp, docker can't mount $TEMPDIR on OSX
70 runnables = for_runnable_identifiers(ctx, uris, kwds, temp_path=temp_path)
71
72 # pick a default engine type if needed
73 is_cwl = all(r.type in {RunnableType.cwl_tool, RunnableType.cwl_workflow} for r in runnables)
74 if kwds.get("engine", None) is None:
75 if is_cwl:
76 kwds["engine"] = "cwltool"
77 elif kwds.get('galaxy_url', None):
78 kwds["engine"] = "external_galaxy"
79 else:
80 kwds["engine"] = "galaxy"
81
82 return_value = test_runnables(ctx, runnables, original_paths=uris, **kwds)
83
84 ctx.exit(return_value)