diff --git a/planemo/commands/cmd_test.py b/planemo/commands/cmd_test.py index 9a49d5de1..980dc5ef5 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() @@ -65,6 +66,7 @@ def cli(ctx, uris, **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. """ + print(kwds) with temp_directory(dir=ctx.planemo_directory) as temp_path: # Create temp dir(s) outside of temp, docker can't mount $TEMPDIR on OSX runnables = for_runnable_identifiers(ctx, uris, kwds, temp_path=temp_path) diff --git a/planemo/engine/test.py b/planemo/engine/test.py index 53a3e5723..06ddc092e 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,16 @@ 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"] = 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) + 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",