diff grep.xml @ 26:f22a309187a3 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit c2b1677d1c94433f777c2dc28ac8eec0a99cc6a7
author bgruening
date Fri, 16 Aug 2024 10:41:17 +0000
parents 1e974b82380d
children 08cdbfffce67
line wrap: on
line diff
--- a/grep.xml	Sat Oct 08 20:59:15 2022 +0000
+++ b/grep.xml	Fri Aug 16 10:41:17 2024 +0000
@@ -1,12 +1,16 @@
-<tool id="tp_grep_tool" name="Search in textfiles" version="@BASE_VERSION@.1">
+<tool id="tp_grep_tool" name="Search in textfiles" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
     <description>(grep)</description>
     <macros>
         <import>macros.xml</import>
     </macros>
+    <expand macro="creator"/>
     <requirements>
-        <requirement type="package" version="2.14">grep</requirement>
-        <requirement type="package" version="4.4">sed</requirement><!-- for ansi2html.sh -->
+        <requirement type="package" version="3.11">grep</requirement>
+        <requirement type="package" version="4.8">sed</requirement><!-- for ansi2html.sh -->
     </requirements>
+    <stdio>
+        <exit_code range="2:" level="fatal" description="grep failed" />
+    </stdio>
     <version_command>grep --version | head -n 1</version_command>
     <command>
 <![CDATA[
@@ -19,17 +23,18 @@
                 -B $lines_before
                 $invert
                 $case_sensitive
-                -- "${url_paste}"
-                '${infile}' | $__tool_directory__/ansi2html.sh > "${output}"
+                -- '${url_paste}'
+                '${infile}' | '$__tool_directory__/ansi2html.sh' > '${output}'
         #else:
             grep
                 $regex_type
                 -A $lines_after
                 -B $lines_before
+                --no-group-separator
                 $invert
                 $case_sensitive
-                 -- "${url_paste}"
-                '${infile}' | grep -v "^--$" > "${output}"
+                 -- '${url_paste}'
+                '${infile}' > '${output}'
         #end if
 ]]>
     </command>
@@ -42,9 +47,9 @@
         </param>
 
         <param name="regex_type" type="select" label="Type of regex">
-            <option value="-G">Basic</option>
-            <option value="-P" selected="true">Perl</option>
-            <option value="-E">Extended (egrep)</option>
+            <option value="-G">Basic (-G)</option>
+            <option value="-P" selected="true">Perl (-P)</option>
+            <option value="-E">Extended (egrep -E)</option>
         </param>
 
         <param name="url_paste" type="text" label="Regular Expression" help="See below for more details">
@@ -77,8 +82,8 @@
         </data>
     </outputs>
     <tests>
+        <!-- grep a FASTA file for sequences with specific motif -->
         <test>
-            <!-- grep a FASTA file for sequences with specific motif -->
             <param name="infile" value="grep1.txt" />
             <param name="case_sensitive" value="case sensitive" />
             <param name="regex_type" value="-P" />
@@ -89,9 +94,9 @@
             <param name="color" value="NOCOLOR" />
             <output name="output" file="grep_results1.txt" />
         </test>
+        <!-- grep a FASTA file for sequences with specific motif -
+             show highlighed output -->
         <test>
-            <!-- grep a FASTA file for sequences with specific motif -
-             show highlighed output -->
             <param name="infile" value="grep1.txt" />
             <param name="case_sensitive" value="case sensitive" />
             <param name="regex_type" value="-P" />
@@ -102,7 +107,8 @@
             <param name="color" value="COLOR" />
             <output name="output" file="grep_results2.html" />
         </test>
-        <test><!-- tests egrep -->
+        <!-- tests egrep -->
+        <test>
             <param name="infile" value="egrep1.txt" />
             <param name="case_sensitive" value="case sensitive" />
             <param name="regex_type" value="-E" />
@@ -113,16 +119,44 @@
             <param name="color" value="NOCOLOR" />
             <output name="output" file="egrep_results1.txt" />
         </test>
-        <test><!-- same regex as egrep test, but different outcome with basic regex -->
+        <!-- tests basic regex; + must be backslashed to match -->
+        <test>
+            <param name="infile" value="egrep1.txt" />
+            <param name="case_sensitive" value="case sensitive" />
+            <param name="regex_type" value="-G" />
+            <param name="invert" value="" />
+            <param name="url_paste" value="[^ ]\+" />
+            <param name="lines_before" value="0" />
+            <param name="lines_after" value="0" />
+            <param name="color" value="NOCOLOR" />
+            <output name="output" file="egrep_results1.txt" />
+        </test>
+        <!-- tests regex;matching nothing -->
+        <test>
             <param name="infile" value="egrep1.txt" />
             <param name="case_sensitive" value="case sensitive" />
             <param name="regex_type" value="-G" />
             <param name="invert" value="" />
-            <param name="url_paste" value="[^ ]+" />
+            <param name="url_paste" value="not existent pattern" />
             <param name="lines_before" value="0" />
             <param name="lines_after" value="0" />
             <param name="color" value="NOCOLOR" />
-            <output name="output" file="egrep_results2.txt" />
+            <output name="output">
+                <assert_contents>
+                    <has_size value="0"/>
+                </assert_contents>
+            </output>
+        </test>
+        <!-- tests invalid regex; i.e. that we still get exit code 2 -->
+        <test expect_failure="true" expect_exit_code="2">
+            <param name="infile" value="egrep1.txt" />
+            <param name="case_sensitive" value="case sensitive" />
+            <param name="regex_type" value="-G" />
+            <param name="invert" value="" />
+            <param name="url_paste" value="\(" />
+            <param name="lines_before" value="0" />
+            <param name="lines_after" value="0" />
+            <param name="color" value="NOCOLOR" />
         </test>
     </tests>
     <help>
@@ -187,7 +221,6 @@
 - **$** matches the end of a line or string.
 - **\|** Separates alternate possibilities.
 
-@REFERENCES@
 ]]>
     </help>
     <expand macro="citations" />