Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shed-tools test options #169

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/ephemeris/shed_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import json
import os
import re
import sys
import time
from collections import namedtuple
from concurrent.futures import thread, ThreadPoolExecutor
Expand Down Expand Up @@ -233,6 +234,8 @@ def test_tools(self,
parallel_tests=1,
test_all_versions=False,
client_test_config_path=None,
cleanup_histories=False,
fail_on_error=False,
):
"""Run tool tests for all tools in each repository in supplied tool list or ``self.installed_repositories()``.
"""
Expand Down Expand Up @@ -309,6 +312,13 @@ def test_tools(self,
[t[0] for t in test_exceptions])
)
log.info("Total tool test time: {0}".format(dt.datetime.now() - tool_test_start))
if n_failed == 0 and cleanup_histories:
galaxy_interactor.delete_history(test_history)
if log:
log.info("Cleaned up testing history")
if fail_on_error and n_failed > 0:
log.info("Found errors, exiting with failure")
sys.exit(1)

def _get_interactor(self, test_user, test_user_api_key):
if test_user_api_key is None:
Expand Down Expand Up @@ -627,10 +637,16 @@ def main():
parallel_tests=args.parallel_tests,
test_all_versions=args.test_all_versions,
client_test_config_path=args.client_test_config,
cleanup_histories=args.cleanup_histories,
fail_on_error=args.fail_on_error,
)
else:
raise NotImplementedError("This point in the code should not be reached. Please contact the developers.")

# Validate if all tools installed correctly
if args.fail_on_error and install_results and install_results.errored_repositories > 0:
log.info("The %s of a tool has failed. Exiting." % args.action)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.error would be more appropriate.
Alternatively: since log + exit is usted. It may be better to use raise an error instead.

sys.exit(1)
# Run tests on the install results if required.
if install_results and args.test or args.test_existing:
to_be_tested_repositories = install_results.installed_repositories
Expand Down
14 changes: 14 additions & 0 deletions src/ephemeris/shed_tools_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ def parser():
help="The Tool Shed URL where to install the tool from. "
"This is applicable only if the tool info is "
"provided as an option vs. in the tools file.")
command_parser.add_argument(
"--fail_on_error",
dest="fail_on_error",
default=False,
action="store_true",
help="Fail the execution when an errored repository has been found"
)

# OPTIONS COMMON FOR UPDATE AND INSTALL

Expand Down Expand Up @@ -247,5 +254,12 @@ def parser():
help="Annotate expectations about tools in client testing YAML "
"configuration file."
)
test_command_parser.add_argument(
"--cleanup",
action="store_true",
dest="cleanup_histories",
help="Cleanup histories after test has finished successfully",
default=False
)

return shed_parser