From 54e3e264a389eabf22a03fa99ad9cf7bb4d01897 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Thu, 22 Nov 2012 23:19:00 +0100 Subject: [PATCH] testsuite for --shebang-wrap. :::: is suboptimal. --- src/parallel | 2 +- testsuite/tests-to-run/parallel-local21.sh | 52 +++++++++++++--- testsuite/wanted-results/parallel-local21 | 72 ++++++++++++++++++++-- 3 files changed, 113 insertions(+), 13 deletions(-) diff --git a/src/parallel b/src/parallel index 3d725d7e..7b09d35b 100755 --- a/src/parallel +++ b/src/parallel @@ -938,9 +938,9 @@ sub read_options { exec "$0 --skip-first-line -a $argfile @ARGV"; } if($::opt_shebang_wrap) { - # exec myself to split $ARGV[0] into separate fields my $parser = shift @ARGV; my $scriptfile = shell_quote_scalar(shift @ARGV); + # exec myself to split $ARGV[0] into separate fields exec "$0 $parser $scriptfile ::: @ARGV"; } } diff --git a/testsuite/tests-to-run/parallel-local21.sh b/testsuite/tests-to-run/parallel-local21.sh index 6f0ef792..61b8df22 100644 --- a/testsuite/tests-to-run/parallel-local21.sh +++ b/testsuite/tests-to-run/parallel-local21.sh @@ -1,27 +1,63 @@ #!/bin/bash +seq 1 2 >/tmp/in12 +seq 4 5 >/tmp/in45 + echo "### Test basic --shebang-wrap" -cat < /tmp/test--shebang-wrap +cat < /tmp/basic--shebang-wrap #!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl print "Shebang from perl with args @ARGV\n"; EOF -chmod 755 /tmp/test--shebang-wrap -/tmp/test--shebang-wrap arg1 arg2 +chmod 755 /tmp/basic--shebang-wrap +/tmp/basic--shebang-wrap arg1 arg2 echo "### Same as" -parallel /usr/bin/perl /tmp/test--shebang-wrap ::: arg1 arg2 +parallel /usr/bin/perl /tmp/basic--shebang-wrap ::: arg1 arg2 +echo "### stdin" +(echo arg1; echo arg2) | /tmp/basic--shebang-wrap +echo "### Same as" +(echo arg1; echo arg2) | parallel /usr/bin/perl /tmp/basic--shebang-wrap +rm /tmp/basic--shebang-wrap + echo "### Test --shebang-wrap with parser options" -cat < /tmp/test--shebang-wrap +cat < /tmp/with-parser--shebang-wrap #!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl -p print "Shebang from perl with args @ARGV\n"; EOF -chmod 755 /tmp/test--shebang-wrap -/tmp/test--shebang-wrap <(seq 2) <(seq 11 12) +chmod 755 /tmp/with-parser--shebang-wrap +/tmp/with-parser--shebang-wrap /tmp/in12 /tmp/in45 echo "### Same as" -parallel /usr/bin/perl\ -p /tmp/test--shebang-wrap ::: <(seq 2) <(seq 11 12) +parallel /usr/bin/perl -p /tmp/with-parser--shebang-wrap ::: /tmp/in12 /tmp/in45 +echo "### stdin" +(echo /tmp/in12; echo /tmp/in45) | /tmp/with-parser--shebang-wrap +echo "### Same as" +(echo /tmp/in12; echo /tmp/in45) | parallel /usr/bin/perl /tmp/with-parser--shebang-wrap +rm /tmp/with-parser--shebang-wrap +echo "### Test --shebang-wrap --pipe with parser options" +cat < /tmp/pipe--shebang-wrap +#!/usr/local/bin/parallel --shebang-wrap --pipe /usr/bin/perl -p + +print "Shebang from perl with args @ARGV\n"; +EOF + +chmod 755 /tmp/pipe--shebang-wrap +# Suboptimal +/tmp/pipe--shebang-wrap :::: /tmp/in12 /tmp/in45 +# Optimal +/tmp/pipe--shebang-wrap /tmp/in12 /tmp/in45 +echo "### Same as" +parallel --pipe /usr/bin/perl\ -p /tmp/pipe--shebang-wrap :::: /tmp/in12 /tmp/in45 +echo "### stdin" +cat /tmp/in12 /tmp/in45 | /tmp/pipe--shebang-wrap +echo "### Same as" +cat /tmp/in12 /tmp/in45 | parallel --pipe /usr/bin/perl\ -p /tmp/pipe--shebang-wrap +rm /tmp/pipe--shebang-wrap + +rm /tmp/in12 +rm /tmp/in45 diff --git a/testsuite/wanted-results/parallel-local21 b/testsuite/wanted-results/parallel-local21 index f50e2436..46be55c1 100644 --- a/testsuite/wanted-results/parallel-local21 +++ b/testsuite/wanted-results/parallel-local21 @@ -4,21 +4,85 @@ Shebang from perl with args arg2 ### Same as Shebang from perl with args arg1 Shebang from perl with args arg2 +### stdin +Shebang from perl with args arg1 +Shebang from perl with args arg2 +### Same as +Shebang from perl with args arg1 +Shebang from perl with args arg2 ### Test --shebang-wrap with parser options Shebang from perl with args 1 Shebang from perl with args 2 Shebang from perl with args -11 +4 Shebang from perl with args -12 +5 ### Same as Shebang from perl with args 1 Shebang from perl with args 2 Shebang from perl with args -11 +4 Shebang from perl with args -12 +5 +### stdin +Shebang from perl with args +1 +Shebang from perl with args +2 +Shebang from perl with args +4 +Shebang from perl with args +5 +### Same as +Shebang from perl with args +1 +Shebang from perl with args +2 +Shebang from perl with args +4 +Shebang from perl with args +5 +### Test --shebang-wrap --pipe with parser options +Shebang from perl with args +1 +Shebang from perl with args +2 +Shebang from perl with args +4 +Shebang from perl with args +5 +Shebang from perl with args +/tmp/in12 +Shebang from perl with args +/tmp/in45 +### Same as +Shebang from perl with args +1 +Shebang from perl with args +2 +Shebang from perl with args +4 +Shebang from perl with args +5 +### stdin +Shebang from perl with args +1 +Shebang from perl with args +2 +Shebang from perl with args +4 +Shebang from perl with args +5 +### Same as +Shebang from perl with args +1 +Shebang from perl with args +2 +Shebang from perl with args +4 +Shebang from perl with args +5