Skip to content

Commit 1e3668a

Browse files
committed
Fix default behavior for planemo lint to use current directory.
Add tests to verify the default behavior when explicit paths are not supplied. Broken with 343902d. Thanks to @nekrut for the bug report.
1 parent ce51241 commit 1e3668a

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

planemo/options.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
""" Click definitions for various shared options and arguments.
22
"""
3+
4+
import os
5+
36
import click
47
from galaxy.tools.deps import docker_util
58

@@ -142,6 +145,13 @@ def required_tool_arg():
142145
return click.argument('path', metavar="TOOL_PATH", type=arg_type)
143146

144147

148+
def _optional_tools_default(ctx, param, value):
149+
if param.name == "paths" and len(value) == 0:
150+
return [os.path.abspath(os.getcwd())]
151+
else:
152+
return value
153+
154+
145155
def optional_tools_arg(multiple=False):
146156
""" Decorate click method as optionally taking in the path to a tool
147157
or directory of tools. If no such argument is given the current working
@@ -159,9 +169,9 @@ def optional_tools_arg(multiple=False):
159169
return click.argument(
160170
name,
161171
metavar="TOOL_PATH",
162-
default=".",
163172
type=arg_type,
164173
nargs=nargs,
174+
callback=_optional_tools_default,
165175
)
166176

167177

tests/data/repos/single_tool/cat.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
cat $input1 #for $q in $queries# ${q.input2} #end for# > $out_file1
55
</command>
66
<inputs>
7-
<param name="input1" type="data" label="Concatenate Dataset"/>
7+
<param name="input1" type="data" label="Concatenate Dataset" format="data" />
88
<repeat name="queries" title="Dataset">
9-
<param name="input2" type="data" label="Select" />
9+
<param name="input2" type="data" label="Select" format="data" />
1010
</repeat>
1111
</inputs>
1212
<outputs>
13-
<data name="out_file1" format="input" metadata_source="input1"/>
13+
<data name="out_file1" format_source="input1" metadata_source="input1"/>
1414
</outputs>
1515
<tests>
1616
<test>
@@ -19,5 +19,6 @@
1919
</test>
2020
</tests>
2121
<help>
22+
Concatenate datasets.
2223
</help>
2324
</tool>

tests/test_lint.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ def test_fail_tools(self):
2222
lint_cmd = ["lint", fail_tool]
2323
self._check_exit_code(lint_cmd, exit_code=1)
2424

25+
def test_lint_default(self):
26+
with self._isolate_repo("single_tool"):
27+
self._check_exit_code(["lint", "--skip", "citations"])
28+
with self._isolate_repo("single_tool"):
29+
self._check_exit_code(["lint"], exit_code=1)
30+
2531
def test_lint_multiple(self):
2632
names = ["fail_citation.xml", "fail_order.xml"]
2733
paths = list(map(lambda p: os.path.join(TEST_TOOLS_DIR, p), names))

0 commit comments

Comments
 (0)