testsuite for --shebang-wrap. :::: is suboptimal.

This commit is contained in:
Ole Tange 2012-11-22 23:19:00 +01:00
parent 007ae78c28
commit 54e3e264a3
3 changed files with 113 additions and 13 deletions

View file

@ -938,9 +938,9 @@ sub read_options {
exec "$0 --skip-first-line -a $argfile @ARGV"; exec "$0 --skip-first-line -a $argfile @ARGV";
} }
if($::opt_shebang_wrap) { if($::opt_shebang_wrap) {
# exec myself to split $ARGV[0] into separate fields
my $parser = shift @ARGV; my $parser = shift @ARGV;
my $scriptfile = shell_quote_scalar(shift @ARGV); my $scriptfile = shell_quote_scalar(shift @ARGV);
# exec myself to split $ARGV[0] into separate fields
exec "$0 $parser $scriptfile ::: @ARGV"; exec "$0 $parser $scriptfile ::: @ARGV";
} }
} }

View file

@ -1,27 +1,63 @@
#!/bin/bash #!/bin/bash
seq 1 2 >/tmp/in12
seq 4 5 >/tmp/in45
echo "### Test basic --shebang-wrap" echo "### Test basic --shebang-wrap"
cat <<EOF > /tmp/test--shebang-wrap cat <<EOF > /tmp/basic--shebang-wrap
#!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl #!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl
print "Shebang from perl with args @ARGV\n"; print "Shebang from perl with args @ARGV\n";
EOF EOF
chmod 755 /tmp/test--shebang-wrap chmod 755 /tmp/basic--shebang-wrap
/tmp/test--shebang-wrap arg1 arg2 /tmp/basic--shebang-wrap arg1 arg2
echo "### Same as" 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" echo "### Test --shebang-wrap with parser options"
cat <<EOF > /tmp/test--shebang-wrap cat <<EOF > /tmp/with-parser--shebang-wrap
#!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl -p #!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl -p
print "Shebang from perl with args @ARGV\n"; print "Shebang from perl with args @ARGV\n";
EOF EOF
chmod 755 /tmp/test--shebang-wrap chmod 755 /tmp/with-parser--shebang-wrap
/tmp/test--shebang-wrap <(seq 2) <(seq 11 12) /tmp/with-parser--shebang-wrap /tmp/in12 /tmp/in45
echo "### Same as" 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 <<EOF > /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

View file

@ -4,21 +4,85 @@ Shebang from perl with args arg2
### Same as ### Same as
Shebang from perl with args arg1 Shebang from perl with args arg1
Shebang from perl with args arg2 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 ### Test --shebang-wrap with parser options
Shebang from perl with args Shebang from perl with args
1 1
Shebang from perl with args Shebang from perl with args
2 2
Shebang from perl with args Shebang from perl with args
11 4
Shebang from perl with args Shebang from perl with args
12 5
### Same as ### Same as
Shebang from perl with args Shebang from perl with args
1 1
Shebang from perl with args Shebang from perl with args
2 2
Shebang from perl with args Shebang from perl with args
11 4
Shebang from perl with args 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