Skip to content

Commit a9b907c

Browse files
committed
Implement script to test library against actual tool tests.
Script installs planemo into a virtualenv, setups "a Galaxy package" around a new virtualenv for this library, clones tools-devteam, and runs planemo test against fastq tools and the ad-hoc Galaxy package. This script may be executed with "make tool-tests" or using the tox environment "tool-tests".
1 parent c68932a commit a9b907c

File tree

6 files changed

+74
-2
lines changed

6 files changed

+74
-2
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ env:
88
- TOX_ENV=py27
99
- TOX_ENV=py34
1010
- TOX_ENV=py27-lint-docstrings
11+
- TOX_ENV=tool-tests
1112

1213
install:
1314
# Setup git to allow git operations.

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ lint-readme: ## check README formatting for PyPI
7070
test: ## run tests with the default Python (faster than tox)
7171
$(IN_VENV) nosetests $(NOSE_TESTS)
7272

73-
tox:
73+
tool-tests: ## Run tools-devteam tool tests against library in current state
74+
bash tests/planemo_test.bash
75+
76+
tox: ## run tests with tox in the specified ENV, defaults to py27
7477
$(IN_VENV) tox -e $(ENV) -- $(ARGS)
7578

7679
_coverage-report: ## build coverage report with the default Python

tests/planemo_test.bash

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
shopt -s nullglob
6+
7+
# This directory.
8+
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd )"
9+
10+
# Planemo to install for test.
11+
PLANEMO_INSTALL_TARGET="${PLANEMO_INSTALL_TARGET:-planemo==0.37.0}"
12+
13+
# By default use pyton setup.py install to install the library.
14+
SETUP_COMMAND="${SETUP_COMMAND:-install}"
15+
16+
TOOLS_DEVTEAM="${TOOLS_DEVTEAM:-}"
17+
18+
# Initialize a temp directory for testing.
19+
TEMP_DIR=`mktemp -d`
20+
echo "Setting up test directory $TEMP_DIR"
21+
cd "$TEMP_DIR"
22+
23+
PLANEMO_VIRTUAL_ENV="${PLANEMO_VIRTUAL_ENV:-$TEMP_DIR/planemo-venv}"
24+
virtualenv "$PLANEMO_VIRTUAL_ENV"
25+
. "$PLANEMO_VIRTUAL_ENV/bin/activate"
26+
pip install "$PLANEMO_INSTALL_TARGET"
27+
deactivate
28+
29+
ENV_DIR="$TEMP_DIR/dependencies/galaxy_sequence_utils/dev"
30+
mkdir -p "$ENV_DIR"
31+
cat "$SCRIPT_DIR/planemo_test_env.sh" | sed -e "s#_temp_dir_#/$TEMP_DIR#" > "$ENV_DIR/env.sh"
32+
ln -s dev "$TEMP_DIR/dependencies/galaxy_sequence_utils/default"
33+
34+
virtualenv "$ENV_DIR/venv"
35+
. "$ENV_DIR/venv/bin/activate"
36+
37+
cd $SCRIPT_DIR/..
38+
python setup.py "$SETUP_COMMAND"
39+
40+
## TODO: Add option to test a wheel instead.
41+
# pip install $SCRIPT_DIR/../dist/*whl
42+
43+
cat "$SCRIPT_DIR/planemo_test_dependency_resolvers_conf_template.xml" | sed -e "s#_temp_dir_#$TEMP_DIR#" > "$TEMP_DIR/dependency_resolvers_conf.xml"
44+
45+
46+
. "$PLANEMO_VIRTUAL_ENV/bin/activate"
47+
48+
if [ -z "$TOOLS_DEVTEAM" ];
49+
then
50+
TOOLS_DEVTEAM="$TEMP_DIR/tools-devteam"
51+
git clone https://github.com/galaxyproject/tools-devteam.git "$TOOLS_DEVTEAM"
52+
fi
53+
54+
for tool_dir in tools/fastq_trimmer_by_quality tool_collections/galaxy_sequence_utils/fastq_combiner
55+
do
56+
planemo test --dependency_resolvers_config_file "$TEMP_DIR/dependency_resolvers_conf.xml" "$TOOLS_DEVTEAM/$tool_dir"
57+
done
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<dependency_resolvers>
2+
<galaxy_packages versionless="true" base_path="_temp_dir_/dependencies" />
3+
</dependency_resolvers>

tests/planemo_test_env.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
. "_temp_dir_/dependencies/galaxy_sequence_utils/dev/venv/bin/activate"

tox.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TODO: implement doc linting
22
[tox]
3-
envlist = py34-lint, py27-lint, py27-lint-readme, py27, py34, py27-lint-docstring, py27-lint-docstring-include-list
3+
envlist = py34-lint, py27-lint, py27-lint-readme, py27, py34, py27-lint-docstring, py27-lint-docstring-include-list, tool-tests
44
source_dir = galaxy_utils
55
test_dir = tests
66

@@ -36,3 +36,8 @@ skip_install = True
3636
deps =
3737
flake8
3838
flake8-docstrings
39+
40+
[testenv:tool-tests]
41+
commands = make tool-tests
42+
whitelist_externals = bash
43+
skip_install = True

0 commit comments

Comments
 (0)