Skip to content

Commit 7e157e2

Browse files
allow to use multiple global macro files
and test cleanup
1 parent c24b323 commit 7e157e2

File tree

11 files changed

+77
-120
lines changed

11 files changed

+77
-120
lines changed

.travis.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,30 @@ script:
1414
- flake8 argparse2tool --ignore=C901,E2,E3,E4,E5,W3,W505
1515
- PYTHONPATH=$(argparse2tool) python examples/example.py --generate_galaxy_xml -m examples/macros.xml > tmp.xml
1616
- xmldiff tmp.xml examples/example.xml
17-
- planemo lint -skip tests --report_level all --fail_level error --xsd tmp.xml
17+
- planemo lint --skip tests --report_level all --fail_level error --xsd tmp.xml
1818

1919
# Galaxy tool generation for example with subparsers -- generating one large (invalid) tool
2020
- echo '<root>' > tmp-sub.xml # wrap in extra level
2121
- PYTHONPATH=$(argparse2tool) python examples/example-sub.py --generate_galaxy_xml -m examples/macros.xml >> tmp-sub.xml
2222
- echo '</root>' >> tmp-sub.xml
2323
- xmldiff tmp-sub.xml <(echo "<root>"; cat examples/example-sub.xml; echo "</root>")
2424

25-
# Galaxy tool generation for example with subparsers -- generating separate tools
25+
# Galaxy tool generation for example with subparsers -- generating separate tools (this does not generate macro xmls automatically)
2626
- PYTHONPATH=$(argparse2tool) python examples/example-sub.py --generate_galaxy_xml -m examples/macros.xml --command foo > tmp-sub-foo.xml
2727
- PYTHONPATH=$(argparse2tool) python examples/example-sub.py --generate_galaxy_xml -m examples/macros.xml --command bar > tmp-sub-bar.xml
28-
- xmldiff tmp-sub-foo.xml examples/example-sub-foo.xml
29-
- planemo lint --skip tests --report_level all --fail_level error --xsd tmp-sub-foo.xml
30-
- xmldiff tmp-sub-bar.xml examples/example-sub-bar.xml
31-
- planemo lint --skip tests --report_level all --fail_level error --xsd tmp-sub-bar.xml
28+
- xmldiff tmp-sub-foo.xml examples/example-sub/example_sub_foo.xml
29+
- xmldiff tmp-sub-bar.xml examples/example-sub/example_sub_bar.xml
30+
31+
# Galaxy tool generation for example with subparsers -- generating all tools and macros at once also include multiple macro files
32+
- mkdir tmp
33+
- PYTHONPATH=$(argparse2tool) python examples/example-sub.py --generate_galaxy_xml -m examples/macros.xml -m examples/macros_tests.xml --directory tmp
34+
- xmldiff tmp/example_sub_foo.xml examples/example-sub/example_sub_foo.xml
35+
- planemo lint --skip tests --report_level all --fail_level error --xsd tmp/example_sub_foo.xml
36+
- xmldiff tmp/example_sub_foo.xml examples/example-sub/example_sub_foo.xml
37+
- planemo lint --skip tests --report_level all --fail_level error --xsd tmp/example_sub_foo.xml
38+
- xmldiff tmp/example_sub_baz.xml examples/example-sub/example_sub_baz.xml
39+
- xmldiff tmp/example_sub_qux.xml examples/example-sub/example_sub_qux.xml
40+
3241

3342
- PYTHONPATH=$(argparse2tool) python examples/example.py --generate_cwl_tool > tmp.cwl
3443
- PYTHONPATH=$(argparse2tool) python examples/example-sub.py --generate_cwl_tool > tmp-sub.cwl

argparse2tool/cmdline2gxml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def process_arguments(self):
2525
self.parser.add_argument('--generate_galaxy_xml', action='store_true')
2626
self.parser.add_argument('-d', '--directory',
2727
help='Directory to store CWL tool descriptions')
28-
self.parser.add_argument('-m', '--macro',
28+
self.parser.add_argument('-m', '--macro', action="append",
2929
help='A global macro file to include in all tools')
3030
self.parser.add_argument('--command', action='store', default="")
3131
return vars(self.parser.parse_args())

argparse2tool/dropins/argparse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def _parse_args_galaxy_argp(self, argp, macro):
210210
if prog not in macros:
211211
tpe = gxt.Tool
212212
if macro:
213-
mx.append(macro)
213+
mx.extend(macro)
214214
else:
215215
tpe = gxt.MacrosTool
216216

examples/example-sub-bar.xml

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/example-sub-foo.xml

Lines changed: 0 additions & 54 deletions
This file was deleted.

examples/example-sub/example_sub_bar.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
<description/>
33
<macros>
44
<import>example_sub_qux.xml</import>
5+
<import>examples/macros.xml</import>
6+
<import>examples/macros_tests.xml</import>
57
</macros>
6-
<stdio>
7-
<exit_code range="1:" level="fatal"/>
8-
</stdio>
9-
<version_command>python example-sub.py bar --version</version_command>
8+
<expand macro="requirements"/>
9+
<expand macro="stdio"/>
10+
<version_command><![CDATA[python example-sub.py bar --version]]></version_command>
1011
<command><![CDATA[python example-sub.py bar $false
1112
#for $i in $repeat_1:
1213
--append $i.append
@@ -40,5 +41,7 @@
4041
<expand macro="example_sub_qux_outmacro"/>
4142
<data name="default" format="txt" hidden="false"/>
4243
</outputs>
44+
<expand macro="example_sub_bar_tests"/>
4345
<help><![CDATA[TODO: Write help]]></help>
46+
<expand macro="citations"/>
4447
</tool>

examples/example-sub/example_sub_baz.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<macros>
2-
<token name="EXAMPLE_SUB_BAZ_INMACRO"><![CDATA[--baz $baz
2+
<token name="EXAMPLE_SUB_BAZ_INMACRO"><![CDATA[--baz '$baz'
33
@EXAMPLE_SUB_QUX_INMACRO@]]></token>
44
<token name="EXAMPLE_SUB_BAZ_OUTMACRO"><![CDATA[@EXAMPLE_SUB_QUX_OUTMACRO@]]></token>
55
<xml name="example_sub_baz_inmacro">

examples/example-sub/example_sub_foo.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
<macros>
44
<import>example_sub_baz.xml</import>
55
<import>example_sub_qux.xml</import>
6+
<import>examples/macros.xml</import>
7+
<import>examples/macros_tests.xml</import>
68
</macros>
7-
<stdio>
8-
<exit_code range="1:" level="fatal"/>
9-
</stdio>
10-
<version_command>python example-sub.py foo --version</version_command>
9+
<expand macro="requirements"/>
10+
<expand macro="stdio"/>
11+
<version_command><![CDATA[python example-sub.py foo --version]]></version_command>
1112
<command><![CDATA[python example-sub.py foo $keyword
1213
1314
#set repeat_var_2 = '" "'.join([ str($var.integers) for $var in $repeat_2 ])
@@ -16,7 +17,7 @@
1617
$sum
1718
1819
#if $foo and $foo is not None:
19-
--foo $foo
20+
--foo '$foo'
2021
#end if
2122
2223
#set repeat_var_4 = '" "'.join([ str($var.bar) for $var in $repeat_4 ])
@@ -47,5 +48,7 @@ $true
4748
<expand macro="example_sub_qux_outmacro"/>
4849
<data name="default" format="txt" hidden="false"/>
4950
</outputs>
51+
<expand macro="example_sub_foo_tests"/>
5052
<help><![CDATA[TODO: Write help]]></help>
53+
<expand macro="citations"/>
5154
</tool>

examples/example-sub/example_sub_qux.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<macros>
2-
<token name="EXAMPLE_SUB_QUX_INMACRO"><![CDATA[--qux $qux]]></token>
2+
<token name="EXAMPLE_SUB_QUX_INMACRO"><![CDATA[--qux '$qux']]></token>
33
<token name="EXAMPLE_SUB_QUX_OUTMACRO"><![CDATA[]]></token>
44
<xml name="example_sub_qux_inmacro">
55
<param optional="true" label="qux help" type="text" name="qux" argument="--qux"/>

examples/macros.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<macros>
3+
<token name="@TOOL_VERSION@">4.4</token>
4+
<token name="@GALAXY_VERSION@">0</token>
5+
<xml name="requirements">
6+
<requirements>
7+
<requirement type="package" version="@TOOL_VERSION@">bash</requirement>
8+
<yield/>
9+
</requirements>
10+
</xml>
11+
<xml name="stdio">
12+
<stdio>
13+
<regex match="Could not allocate metaspace" level="fatal_oom" description="Java memory Exception"/>
14+
<regex match="Cannot create VM thread" level="fatal_oom" description="Java memory Exception"/>
15+
<regex match="qUncompress: could not allocate enough memory to uncompress data" level="fatal_oom" description="Java memory Exception"/>
16+
</stdio>
17+
</xml>
18+
<xml name="citations">
19+
<citations>
20+
<citation type="doi">doi:10.1093/nar/gkw343</citation>
21+
</citations>
22+
</xml>
23+
<xml name="example_tests">
24+
<tests>
25+
</tests>
26+
</xml>
27+
</macros>

0 commit comments

Comments
 (0)