diff --git a/planemo/commands/cmd_test.py b/planemo/commands/cmd_test.py index 9a49d5de1..19f4bede0 100644 --- a/planemo/commands/cmd_test.py +++ b/planemo/commands/cmd_test.py @@ -32,7 +32,8 @@ "instances to limit generated traffic.", default="0", ) -@options.galaxy_target_options() +@options.serve_option() +@options.galaxy_run_options() @options.galaxy_config_options() @options.test_options() @options.engine_options() diff --git a/planemo/engine/test.py b/planemo/engine/test.py index 53a3e5723..d52f05cce 100644 --- a/planemo/engine/test.py +++ b/planemo/engine/test.py @@ -1,8 +1,15 @@ +import os + from planemo.engine import ( engine_context, ) from planemo.galaxy import galaxy_config +from planemo.galaxy import galaxy_serve +from planemo.galaxy.api import ( + DEFAULT_ADMIN_API_KEY +) from planemo.galaxy.config import _find_test_data +from planemo.galaxy.ephemeris_sleep import sleep from planemo.galaxy.test import ( handle_reports_and_summary, run_in_config, @@ -15,6 +22,17 @@ def test_runnables(ctx, runnables, original_paths=None, **kwds): """Return exit code indicating test or failure.""" + if kwds.get("serve"): + kwds["engine"] = "external_galaxy" + kwds["galaxy_url"] = ''.join(("http://", kwds["host"], ":", kwds["port"])) + kwds["galaxy_admin_key"] = kwds["galaxy_admin_key"] or DEFAULT_ADMIN_API_KEY + pid = os.fork() + if pid == 0: + sleep(kwds["galaxy_url"], verbose=ctx.verbose, timeout=500) + else: + galaxy_serve(ctx, runnables, **kwds) + exit(1) + engine_type = kwds["engine"] test_engine_testable = {RunnableType.galaxy_tool, RunnableType.galaxy_datamanager, RunnableType.directory} enable_test_engines = any(r.type not in test_engine_testable for r in runnables) diff --git a/planemo/options.py b/planemo/options.py index 011d702b0..7eef796c7 100644 --- a/planemo/options.py +++ b/planemo/options.py @@ -881,6 +881,15 @@ def no_cleanup_option(): ) +def serve_option(): + return planemo_option( + "--serve", + is_flag=True, + default=False, + help=("Continue serving Galaxy instance after testing.") + ) + + def docker_enable_option(): return planemo_option( "--docker/--no_docker",