Skip to content

Commit

Permalink
Fix default behavior for planemo lint to use current directory.
Browse files Browse the repository at this point in the history
Add tests to verify the default behavior when explicit paths are not supplied. Broken with 343902d.

Thanks to @nekrut for the bug report.
  • Loading branch information
jmchilton committed May 12, 2015
1 parent ce51241 commit 1e3668a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
12 changes: 11 additions & 1 deletion planemo/options.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
""" Click definitions for various shared options and arguments.
"""

import os

import click
from galaxy.tools.deps import docker_util

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


def _optional_tools_default(ctx, param, value):
if param.name == "paths" and len(value) == 0:
return [os.path.abspath(os.getcwd())]
else:
return value


def optional_tools_arg(multiple=False):
""" Decorate click method as optionally taking in the path to a tool
or directory of tools. If no such argument is given the current working
Expand All @@ -159,9 +169,9 @@ def optional_tools_arg(multiple=False):
return click.argument(
name,
metavar="TOOL_PATH",
default=".",
type=arg_type,
nargs=nargs,
callback=_optional_tools_default,
)


Expand Down
7 changes: 4 additions & 3 deletions tests/data/repos/single_tool/cat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
cat $input1 #for $q in $queries# ${q.input2} #end for# > $out_file1
</command>
<inputs>
<param name="input1" type="data" label="Concatenate Dataset"/>
<param name="input1" type="data" label="Concatenate Dataset" format="data" />
<repeat name="queries" title="Dataset">
<param name="input2" type="data" label="Select" />
<param name="input2" type="data" label="Select" format="data" />
</repeat>
</inputs>
<outputs>
<data name="out_file1" format="input" metadata_source="input1"/>
<data name="out_file1" format_source="input1" metadata_source="input1"/>
</outputs>
<tests>
<test>
Expand All @@ -19,5 +19,6 @@
</test>
</tests>
<help>
Concatenate datasets.
</help>
</tool>
6 changes: 6 additions & 0 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def test_fail_tools(self):
lint_cmd = ["lint", fail_tool]
self._check_exit_code(lint_cmd, exit_code=1)

def test_lint_default(self):
with self._isolate_repo("single_tool"):
self._check_exit_code(["lint", "--skip", "citations"])
with self._isolate_repo("single_tool"):
self._check_exit_code(["lint"], exit_code=1)

def test_lint_multiple(self):
names = ["fail_citation.xml", "fail_order.xml"]
paths = list(map(lambda p: os.path.join(TEST_TOOLS_DIR, p), names))
Expand Down

0 comments on commit 1e3668a

Please sign in to comment.