Skip to content

Commit 6638caa

Browse files
committed
Make lint --conda_requirements check that an actual requirement is found.
Add test cases .
1 parent 8faf661 commit 6638caa

File tree

5 files changed

+90
-4
lines changed

5 files changed

+90
-4
lines changed

planemo/linters/conda_requirements.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
def lint_requirements_in_conda(tool_source, lint_ctx):
1111
"""Check requirements of tool source against best practice Conda channels."""
1212
conda_targets = tool_source_conda_targets(tool_source)
13+
if not conda_targets:
14+
lint_ctx.warn("No valid package requirement tags found to check against Conda.")
15+
return
16+
1317
for conda_target in conda_targets:
1418
(best_hit, exact) = best_search_result(conda_target, channels_override=BEST_PRACTICE_CHANNELS)
1519
conda_target_str = conda_target.package
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<tool id="bwa" name="BWA" version="0.1.0">
2+
<requirements>
3+
<requirement type="package" version="0.4.12">bwa</requirement>
4+
</requirements>
5+
<stdio>
6+
<exit_code range="2:" />
7+
</stdio>
8+
<command><![CDATA[
9+
bwa > $output_1 2>&1
10+
]]></command>
11+
<inputs>
12+
<param name="ignored" type="text" value="the default" />
13+
</inputs>
14+
<outputs>
15+
<data name="output_1" format="txt" />
16+
</outputs>
17+
<tests>
18+
<test>
19+
<output name="output_1">
20+
<assert_contents>
21+
<has_text text="Version: 0.7.10" />
22+
</assert_contents>
23+
</output>
24+
</test>
25+
</tests>
26+
<help><![CDATA[
27+
BWA is a mapper.
28+
]]></help>
29+
<citations>
30+
<citation type="doi">10.1093/bioinformatics/btp324</citation>
31+
<citation type="doi">10.1093/bioinformatics/btp698</citation>
32+
</citations>
33+
</tool>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<tool id="bwa" name="BWA" version="0.1.0">
2+
<stdio>
3+
<exit_code range="2:" />
4+
</stdio>
5+
<command><![CDATA[
6+
bwa > $output_1 2>&1
7+
]]></command>
8+
<inputs>
9+
<param name="ignored" type="text" value="the default" />
10+
</inputs>
11+
<outputs>
12+
<data name="output_1" format="txt" />
13+
</outputs>
14+
<tests>
15+
<test>
16+
<output name="output_1">
17+
<assert_contents>
18+
<has_text text="Version: 0.7.10" />
19+
</assert_contents>
20+
</output>
21+
</test>
22+
</tests>
23+
<help><![CDATA[
24+
BWA is a mapper.
25+
]]></help>
26+
<citations>
27+
<citation type="doi">10.1093/bioinformatics/btp324</citation>
28+
<citation type="doi">10.1093/bioinformatics/btp698</citation>
29+
</citations>
30+
</tool>

tests/data/tools/bwa_wrong_version.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
bwa > $output_1 2>&1
1010
]]></command>
1111
<inputs>
12+
<param name="ignored" type="text" value="the default" />
1213
</inputs>
1314
<outputs>
14-
<data name="output_1" />
15+
<data name="output_1" format="txt" />
1516
</outputs>
16-
<help><![CDATA[
17-
TODO: Fill in help.
18-
]]></help>
1917
<tests>
2018
<test>
2119
<output name="output_1">
@@ -25,4 +23,11 @@
2523
</output>
2624
</test>
2725
</tests>
26+
<help><![CDATA[
27+
BWA is a mapper.
28+
]]></help>
29+
<citations>
30+
<citation type="doi">10.1093/bioinformatics/btp324</citation>
31+
<citation type="doi">10.1093/bioinformatics/btp698</citation>
32+
</citations>
2833
</tool>

tests/test_lint.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,17 @@ def test_lint_doi(self):
6969
fail_doi = os.path.join(TEST_TOOLS_DIR, "invalid_doi.xml")
7070
lint_cmd = ["lint", "--doi", fail_doi]
7171
self._check_exit_code(lint_cmd, exit_code=1)
72+
73+
def test_lint_conda_requirements_empty(self):
74+
bwa_no_reqs = os.path.join(TEST_TOOLS_DIR, "bwa_without_requirements.xml")
75+
lint_cmd = ["lint", bwa_no_reqs]
76+
self._check_exit_code(lint_cmd)
77+
lint_cmd = ["lint", "--conda_requirements", bwa_no_reqs]
78+
self._check_exit_code(lint_cmd, exit_code=1)
79+
80+
def test_lint_conda_requirements_wrong_version(self):
81+
bwa_wrong_version = os.path.join(TEST_TOOLS_DIR, "bwa_invalid_version.xml")
82+
lint_cmd = ["lint", bwa_wrong_version]
83+
self._check_exit_code(lint_cmd)
84+
lint_cmd = ["lint", "--conda_requirements", bwa_wrong_version]
85+
self._check_exit_code(lint_cmd, exit_code=1)

0 commit comments

Comments
 (0)