Skip to content

Commit c92eb2c

Browse files
authored
Merge pull request #699 from jmchilton/doc_tests
Implement some ad-hoc documentation tests.
2 parents 44317f4 + 4209bee commit c92eb2c

7 files changed

+266
-2
lines changed

docs/_writing_testing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ install BWA - but however you obtain it should be fine.
1010

1111
::
1212

13-
$ conda install -c bioconda bwa
13+
$ conda install --force -c bioconda bwa
1414
... bwa installation ...
1515
$ bwa
1616
Program: bwa (alignment via Burrows-Wheeler transformation)

docs/_writing_using_seqtk.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ install Seqtk - but however you obtain it should be fine.
77

88
::
99

10-
$ conda install -c bioconda seqtk=1.2
10+
$ conda install --force -c bioconda seqtk=1.2
1111
... seqtk installation ...
1212
$ seqtk seq
1313
Usage: seqtk seq [options] <in.fq>|<in.fa>

docs/tests/tests_all.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -o xtrace
4+
5+
set -e
6+
7+
DOC_TESTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8+
9+
bash "${DOC_TESTS_DIRECTORY}/tests_building.sh"
10+
11+
bash "${DOC_TESTS_DIRECTORY}/tests_tdd.sh"
12+
13+
bash "${DOC_TESTS_DIRECTORY}/tests_conda.sh"
14+
15+
bash "${DOC_TESTS_DIRECTORY}/tests_docker.sh"

docs/tests/tests_building.sh

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
set -o xtrace
4+
5+
set -e
6+
7+
# Preconditions - tool init directory doesn't exist and in home directory.
8+
cd
9+
rm -rf tool_init_exercise
10+
11+
# Tests
12+
13+
conda install --force -c bioconda seqtk=1.2
14+
15+
seqtk seq
16+
17+
mkdir tool_init_exercise
18+
19+
cd tool_init_exercise
20+
21+
wget https://raw.githubusercontent.com/galaxyproject/galaxy-test-data/master/2.fastq
22+
23+
seqtk seq -A 2.fastq > 2.fasta
24+
25+
cat 2.fasta
26+
27+
planemo tool_init --id 'seqtk_seq' --name 'Convert to FASTA (seqtk)'
28+
29+
cat seqtk_seq.xml
30+
31+
planemo tool_init --force \
32+
--id 'seqtk_seq' \
33+
--name 'Convert to FASTA (seqtk)' \
34+
--requirement [email protected] \
35+
--example_command 'seqtk seq -a 2.fastq > 2.fasta' \
36+
--example_input 2.fastq \
37+
--example_output 2.fasta
38+
39+
cat seqtk_seq.xml
40+
41+
planemo tool_init --force \
42+
--id 'seqtk_seq' \
43+
--name 'Convert to FASTA (seqtk)' \
44+
--requirement [email protected] \
45+
--example_command 'seqtk seq -a 2.fastq > 2.fasta' \
46+
--example_input 2.fastq \
47+
--example_output 2.fasta \
48+
--test_case \
49+
--cite_url 'https://github.com/lh3/seqtk' \
50+
--help_from_command 'seqtk seq'
51+
52+
planemo l
53+
54+
planemo t
55+
56+
planemo shed_init --name=seqtk_seq \
57+
--owner=planemo \
58+
--description=seqtk_seq \
59+
--long_description="Tool that converts FASTQ to FASTA files using seqtk" \
60+
--category="Fastq Manipulation"
61+
62+
planemo shed_lint --tools
63+
64+
planemo shed_create --shed_target local
65+
66+
planemo shed_update --shed_target local
67+
68+
planemo tool_init --force \
69+
--macros \
70+
--id 'seqtk_seq' \
71+
--name 'Convert to FASTA (seqtk)' \
72+
--requirement [email protected] \
73+
--example_command 'seqtk seq -A 2.fastq > 2.fasta' \
74+
--example_input 2.fastq \
75+
--example_output 2.fasta \
76+
--test_case \
77+
--help_from_command 'seqtk seq'
78+
79+
cat seqtk_seq.xml
80+

docs/tests/tests_conda.sh

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
3+
set -o xtrace
4+
5+
set -e
6+
7+
shopt -s expand_aliases # Needed for conda_env test
8+
9+
# Preconditions:
10+
# - seqtk_example doesn't exist and in home directory
11+
# - conda_exercises doesn't exist in home directory.
12+
# - seqtk environment is absent
13+
14+
cd
15+
16+
rm -rf seqtk_example
17+
rm -rf conda_exercises
18+
echo "Remove existing seqtk environment - it is fine if it doesn't exist."
19+
conda remove --force --name '[email protected]' --all || true
20+
21+
# Tests
22+
23+
echo "Try planemo conda_init - this may fail and will always fail on planemo-machine"
24+
echo "still good to see a decent error message though."
25+
planemo conda_init || true
26+
27+
echo "Setup completed seqtk example"
28+
planemo project_init --template=seqtk_complete seqtk_example
29+
cd seqtk_example
30+
31+
echo "Check conda_requirements - should see them linting properly"
32+
planemo lint --conda_requirements seqtk_seq.xml
33+
34+
35+
planemo conda_install seqtk_seq.xml
36+
37+
echo "Checking for seqtk - shouldn't be present"
38+
which seqtk || true
39+
40+
echo "Simulating '. <(planemo conda_env seqtk_seq.xml)', subshell-ism doesn't seem to work in script"
41+
planemo conda_env seqtk_seq.xml > .conda_env
42+
. .conda_env
43+
44+
echo "Inside conda_env I should see seqtk"
45+
which seqtk
46+
47+
conda_env_deactivate
48+
49+
sleep 5 # Need to wait for the package to get cleaned up.
50+
51+
planemo test seqtk_seq.xml
52+
53+
echo "Doing a search - should see seqtk in bioconda results along with versions"
54+
planemo conda_search seqt
55+
56+
cd
57+
58+
planemo project_init --template conda_exercises conda_exercises
59+
cd conda_exercises/exercise_1
60+
ls
61+
62+
echo "Running test wrong - this should fail"
63+
planemo test pear.xml || true
64+
echo "Linting pear without requirements - this should fail"
65+
planemo lint --conda_requirements pear.xml || true
66+
67+
echo "Should see pear from bioconda at 0.9.6"
68+
planemo conda_search pear
69+
70+
wget https://raw.githubusercontent.com/galaxyproject/planemo/master/project_templates/conda_answers/exercise_1/pear.xml -O pear.xml
71+
planemo lint --conda_requirements pear.xml || true
72+
73+
planemo test pear.xml
74+
75+
cd ../exercise_2
76+
77+
# Fetch and build recipe.
78+
79+
mkdir fleeqtk
80+
cd fleeqtk
81+
82+
wget https://raw.githubusercontent.com/galaxyproject/planemo/master/project_templates/conda_answers/exercise_2/fleeqtk/build.sh
83+
wget https://raw.githubusercontent.com/galaxyproject/planemo/master/project_templates/conda_answers/exercise_2/fleeqtk/meta.yaml
84+
85+
cd ..
86+
conda build fleeqtk
87+
88+
# Update to fix tool and see it work.
89+
90+
wget https://raw.githubusercontent.com/galaxyproject/planemo/master/project_templates/conda_answers/exercise_2/fleeqtk_seq.xml -O fleeqtk_seq.xml
91+
planemo conda_install --conda_use_local fleeqtk_seq.xml
92+
planemo test fleeqtk_seq.xml

docs/tests/tests_docker.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -o xtrace
4+
5+
set -e
6+
7+
# Preconditions - seqtk_example directory doesn't exist and in home directory.
8+
cd
9+
rm -rf seqtk_example
10+
rm -rf conda_testing
11+
12+
13+
echo "Setup completed seqtk example"
14+
planemo project_init --template=seqtk_complete seqtk_example
15+
cd seqtk_example
16+
17+
echo "We should see biocontainer found for this tool"
18+
planemo lint --biocontainers seqtk_seq.xml
19+
20+
echo "This should pass and we should see container was used."
21+
planemo test --biocontainers seqtk_seq.xml
22+
23+
cd ..
24+
25+
planemo project_init --template=conda_testing conda_testing
26+
cd conda_testing/
27+
echo "Should show quay.io/biocontainers/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:03dc1d2818d9de56938078b8b78b82d967c1f820-0 is built"
28+
planemo mull bwa_and_samtools.xml
29+
30+
31+
echo "Should see quay.io/biocontainers/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:03dc1d2818d9de56938078b8b78b82d967c1f820-0. "
32+
docker images
33+
34+
echo "Should see cached container was used for this"
35+
planemo test --biocontainers bwa_and_samtools.xml

docs/tests/tests_tdd.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
set -o xtrace
4+
5+
set -e
6+
7+
# Preconditions - bwa directory doesn't exist and in home directory.
8+
cd
9+
rm -rf bwa
10+
11+
# Tests
12+
conda install -c bioconda bwa
13+
14+
echo "Executing bwa to see help - should see output, but it has a non-zero exit code."
15+
bwa | true
16+
17+
planemo project_init --template bwa bwa
18+
cd bwa
19+
20+
cd test-data
21+
bwa index -a is bwa-mem-mt-genome.fa
22+
bwa mem bwa-mem-mt-genome.fa bwa-mem-fastq1.fq bwa-mem-fastq2.fq | \
23+
samtools view -Sb - > temporary_bam_file.bam && \
24+
(samtools sort -f temporary_bam_file.bam bwa-aln-test2.bam || samtools sort -o bwa-aln-test2.bam temporary_bam_file.bam)
25+
26+
cd ..
27+
28+
wget https://raw.githubusercontent.com/galaxyproject/planemo/master/docs/writing/bwa-mem_v2.xml -O bwa-mem.xml
29+
30+
echo "Running test we expect to fail..."
31+
32+
planemo t || true
33+
34+
echo "Fixing tool"
35+
36+
wget https://raw.githubusercontent.com/galaxyproject/planemo/master/docs/writing/bwa-mem_v3.xml -O bwa-mem.xml
37+
38+
echo "Running test we expect to be fixed."
39+
40+
planemo t --failed
41+
42+
# TODO: Finish remaining BWA examples if time.

0 commit comments

Comments
 (0)