2013-12-19 01:19:19 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Simple jobs that never fails
|
|
|
|
|
# Each should be taking 0.3-1s and be possible to run in parallel
|
|
|
|
|
# I.e.: No race conditions, no logins
|
2015-07-22 06:28:05 +00:00
|
|
|
|
|
2016-08-03 21:45:13 +00:00
|
|
|
|
stdsort() {
|
2018-10-22 22:46:38 +00:00
|
|
|
|
"$@" 2>&1 | LC_ALL=C sort;
|
2016-08-03 21:45:13 +00:00
|
|
|
|
}
|
|
|
|
|
export -f stdsort
|
2015-10-17 14:54:15 +00:00
|
|
|
|
|
2016-05-17 00:11:38 +00:00
|
|
|
|
# Test amount of parallelization
|
|
|
|
|
# parallel --shuf --jl /tmp/myjl -j1 'export JOBS={1};'bash tests-to-run/parallel-local-0.3s.sh ::: {1..16} ::: {1..5}
|
2015-10-17 14:54:15 +00:00
|
|
|
|
|
2020-11-22 15:22:54 +00:00
|
|
|
|
par_replacement_string_on_utf8() {
|
|
|
|
|
echo '### test {} {.} on UTF8 input'
|
|
|
|
|
inputlist() {
|
|
|
|
|
echo "中国 (Zhōngguó)/China's (中国) road.jpg"
|
|
|
|
|
echo "中国.(中国)"
|
|
|
|
|
echo /tmp/test-of-{.}-parallel/subdir/file
|
|
|
|
|
echo '/tmp/test-of-{.}-parallel/subdir/file{.}.funkyextension}}'
|
|
|
|
|
}
|
|
|
|
|
inputlist | parallel -k echo {} {.}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_compress_stdout_stderr() {
|
|
|
|
|
echo '### Test compress - stdout'
|
|
|
|
|
parallel --compress echo ::: OK
|
|
|
|
|
echo '### Test compress - stderr'
|
|
|
|
|
parallel --compress ls /{} ::: OK-if-missing-file 2>&1 >/dev/null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_regexp_chars_in_template() {
|
|
|
|
|
echo '### Test regexp chars in template'
|
|
|
|
|
seq 1 6 | parallel -j1 -I :: -X echo 'a::b::^c::[.}c'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_test_m_X() {
|
|
|
|
|
echo '### Test -m vs -X'
|
|
|
|
|
(echo foo;echo bar;echo joe.gif) | parallel -j1 -km echo 1{}2{.}3 A{.}B{.}C
|
|
|
|
|
(echo foo;echo bar;echo joe.gif) | parallel -j1 -kX echo 1{}2{.}3 A{.}B{.}C
|
|
|
|
|
seq 1 6 | parallel -k printf '{}.gif\\n' | parallel -j1 -km echo a{}b{.}c{.}
|
|
|
|
|
seq 1 6 | parallel -k printf '{}.gif\\n' | parallel -j1 -kX echo a{}b{.}c{.}
|
|
|
|
|
|
|
|
|
|
echo '### Test -q {.}'
|
|
|
|
|
echo a | parallel -qX echo "'"{.}"' "
|
|
|
|
|
echo a | parallel -qX echo "'{.}'"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_i_t() {
|
|
|
|
|
echo '### Test -i'
|
|
|
|
|
(echo a; echo END; echo b) | parallel -k -i -eEND echo repl{.}ce
|
|
|
|
|
|
|
|
|
|
echo '### Test --replace'
|
|
|
|
|
(echo a; echo END; echo b) | parallel -k --replace -eEND echo repl{.}ce
|
|
|
|
|
|
|
|
|
|
echo '### Test -t'
|
|
|
|
|
(echo b; echo c; echo f) | parallel -k -t echo {.}ar 2>&1 >/dev/null
|
|
|
|
|
|
|
|
|
|
echo '### Test --verbose'
|
|
|
|
|
(echo b; echo c; echo f) | parallel -k --verbose echo {.}ar 2>&1 >/dev/null
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 22:18:13 +00:00
|
|
|
|
par_pipe_float_blocksize() {
|
|
|
|
|
echo '### Test --block <<non int>>'
|
|
|
|
|
seq 5 | parallel --block 3.1 --pipe wc
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-22 19:47:01 +00:00
|
|
|
|
par_opt_gnu() {
|
|
|
|
|
echo '### Test --tollef'
|
|
|
|
|
stdout parallel -k --tollef echo -- 1 2 3 ::: a b c | LC_ALL=C sort
|
|
|
|
|
|
|
|
|
|
echo '### Test --tollef --gnu'
|
|
|
|
|
stdout parallel -k --tollef --gnu echo ::: 1 2 3 -- a b c
|
|
|
|
|
|
|
|
|
|
echo '### Test --gnu'
|
|
|
|
|
parallel -k --gnu echo ::: 1 2 3 -- a b c
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_colsep_default() {
|
|
|
|
|
echo "bug #37956: --colsep does not default to '\t' as specified in the man page."
|
|
|
|
|
printf "A\tB\n1\tone" | parallel --header : echo {B} {A}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_tmux_command_not_found() {
|
|
|
|
|
echo '### PARALLEL_TMUX not found'
|
|
|
|
|
PARALLEL_TMUX=not-existing parallel --tmux echo ::: 1
|
|
|
|
|
}
|
2014-10-14 20:56:03 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_echo_jobseq() {
|
|
|
|
|
echo '### bug #44995: parallel echo {#} ::: 1 2 ::: 1 2'
|
2014-10-14 20:56:03 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
parallel -k echo {#} ::: 1 2 ::: 1 2
|
|
|
|
|
}
|
2014-12-12 12:30:54 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_no_joblog_with_dryrun() {
|
|
|
|
|
echo 'bug #46016: --joblog should not log when --dryrun'
|
2014-12-14 08:44:32 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
parallel --dryrun --joblog - echo ::: Only_this
|
|
|
|
|
}
|
2014-12-14 08:44:32 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_tagstring_with_d() {
|
|
|
|
|
echo 'bug #47002: --tagstring with -d \n\n'
|
2015-03-16 18:51:08 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
(seq 3; echo; seq 4) |
|
|
|
|
|
parallel -k -d '\n\n' --tagstring {%} echo ABC';'echo
|
|
|
|
|
}
|
2015-03-16 18:51:08 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_xargs_nul_char_in_input() {
|
|
|
|
|
echo 'bug #47290: xargs: Warning: a NUL character occurred in the input'
|
2014-12-14 08:44:32 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
perl -e 'print "foo\0not printed"' | parallel echo
|
|
|
|
|
}
|
2015-03-17 19:44:09 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_maxproc() {
|
|
|
|
|
echo '### Test --max-procs and -P: Number of processes'
|
2015-03-22 00:51:30 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
seq 1 10 | parallel -k --max-procs +0 echo max proc
|
|
|
|
|
seq 1 10 | parallel -k -P 200% echo 200% proc
|
|
|
|
|
}
|
2015-03-28 11:14:30 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_maxchar_s() {
|
|
|
|
|
echo '### Test --max-chars and -s: Max number of chars in a line'
|
2015-05-06 22:40:36 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k --max-chars 25 -X echo
|
|
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k -s 25 -X echo
|
|
|
|
|
}
|
2015-05-06 22:40:36 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_no_run_if_empty() {
|
|
|
|
|
echo '### Test --no-run-if-empty and -r: This should give no output'
|
2015-05-06 22:40:36 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo " " | parallel -r echo
|
|
|
|
|
echo " " | parallel --no-run-if-empty echo
|
|
|
|
|
}
|
2015-05-25 20:07:37 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_help() {
|
|
|
|
|
echo '### Test --help and -h: Help output (just check we get the same amount of lines)'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo Output from -h and --help
|
|
|
|
|
parallel -h | wc -l
|
|
|
|
|
parallel --help | wc -l
|
|
|
|
|
}
|
2015-09-21 23:35:52 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_version() {
|
|
|
|
|
echo '### Test --version: Version output (just check we get the same amount of lines)'
|
2015-09-18 20:28:47 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
parallel --version | wc -l
|
|
|
|
|
}
|
2016-01-28 22:45:11 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_verbose_t() {
|
|
|
|
|
echo '### Test --verbose and -t'
|
2016-01-28 22:45:11 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
(echo b; echo c; echo f) | parallel -k -t echo {}ar 2>&1 >/dev/null
|
|
|
|
|
(echo b; echo c; echo f) | parallel -k --verbose echo {}ar 2>&1 >/dev/null
|
|
|
|
|
}
|
2016-01-28 22:45:11 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_show_limits() {
|
|
|
|
|
echo '### Test --show-limits'
|
2020-04-22 18:15:59 +00:00
|
|
|
|
(
|
|
|
|
|
(echo b; echo c; echo f) | parallel -k --show-limits echo {}ar
|
|
|
|
|
(echo b; echo c; echo f) | parallel -j1 -kX --show-limits -s 100 echo {}ar
|
|
|
|
|
echo "### BUG: empty lines with --show-limit"
|
|
|
|
|
echo | stdout parallel --show-limits
|
|
|
|
|
) | perl -pe 's/131\d\d\d/131xxx/'
|
2019-05-05 23:06:48 +00:00
|
|
|
|
}
|
2016-03-26 09:35:13 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_test_zero_args() {
|
|
|
|
|
echo '### Test 0-arguments'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
seq 1 2 | parallel -k -n0 echo n0
|
|
|
|
|
seq 1 2 | parallel -k -L0 echo L0
|
|
|
|
|
seq 1 2 | parallel -k -N0 echo N0
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_l0_is_l1() {
|
|
|
|
|
echo '### Because of --tollef -l, then -l0 == -l1, sorry'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
seq 1 2 | parallel -k -l0 echo l0
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_replace_replacementstring() {
|
|
|
|
|
echo '### Test replace {}'
|
|
|
|
|
|
|
|
|
|
seq 1 2 | parallel -k -N0 echo replace {} curlies
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_arguments_on_cmdline() {
|
|
|
|
|
echo '### Test arguments on commandline'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
parallel -k -N0 echo args on cmdline ::: 1 2
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_nice_locally() {
|
|
|
|
|
echo '### Test --nice locally'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
parallel --nice 1 -vv 'PAR=a bash -c "echo \$PAR {}"' ::: b
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_disk_full() {
|
|
|
|
|
echo '### Disk full'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
SMALLDISK=${SMALLDISK:-/mnt/ram}
|
|
|
|
|
export SMALLDISK
|
|
|
|
|
(
|
|
|
|
|
cd /tmp
|
|
|
|
|
sudo umount -l smalldisk.img
|
|
|
|
|
dd if=/dev/zero of=smalldisk.img bs=100k count=1k
|
|
|
|
|
yes|mkfs smalldisk.img
|
|
|
|
|
sudo mkdir -p /mnt/ram
|
|
|
|
|
sudo mount smalldisk.img /mnt/ram
|
|
|
|
|
sudo chmod 777 /mnt/ram
|
|
|
|
|
) >/dev/null 2>/dev/null
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
cat /dev/zero >$SMALLDISK/out
|
|
|
|
|
parallel --tmpdir $SMALLDISK echo ::: OK
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
rm $SMALLDISK/out
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
sudo umount -l /tmp/smalldisk.img
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-02-22 18:00:42 +00:00
|
|
|
|
par_delimiter() {
|
|
|
|
|
echo '### Test --delimiter and -d: Delimiter instead of newline'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-02-22 18:00:42 +00:00
|
|
|
|
echo '# Yes there is supposed to be an extra newline for -d N'
|
|
|
|
|
echo line 1Nline 2Nline 3 | parallel -k -d N echo This is
|
|
|
|
|
echo line 1Nline 2Nline 3 | parallel -k --delimiter N echo This is
|
|
|
|
|
printf "delimiter NUL line 1\0line 2\0line 3" | parallel -k -d '\0' echo
|
|
|
|
|
printf "delimiter TAB line 1\tline 2\tline 3" | parallel -k --delimiter '\t' echo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_argfile() {
|
|
|
|
|
echo '### Test -a and --arg-file: Read input from file instead of stdin'
|
|
|
|
|
|
|
|
|
|
seq 1 10 >/tmp/parallel_$$-1; parallel -k -a /tmp/parallel_$$-1 echo; rm /tmp/parallel_$$-1
|
|
|
|
|
seq 1 10 >/tmp/parallel_$$-2; parallel -k --arg-file /tmp/parallel_$$-2 echo; rm /tmp/parallel_$$-2
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_pipe_unneeded_procs() {
|
|
|
|
|
echo '### Test bug #34241: --pipe should not spawn unneeded processes'
|
|
|
|
|
seq 3 | parallel -j30 --pipe --block-size 10 cat\;echo o 2> >(grep -Ev 'Warning: Starting|Warning: Consider')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_results_arg_256() {
|
|
|
|
|
echo '### bug #42089: --results with arg > 256 chars (should be 1 char shorter)'
|
|
|
|
|
parallel --results parallel_test_dir echo ::: 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
|
|
|
|
|
ls parallel_test_dir/1/
|
|
|
|
|
rm -rf parallel_test_dir
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-22 18:00:42 +00:00
|
|
|
|
par_pipe_to_func() {
|
|
|
|
|
echo '### bug #45998: --pipe to function broken'
|
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
myfunc() { echo $1; cat; }
|
|
|
|
|
export -f myfunc
|
|
|
|
|
echo pipefunc OK | parallel --pipe myfunc {#}
|
2019-02-22 18:00:42 +00:00
|
|
|
|
echo pipefunc and more OK | parallel --pipe 'myfunc {#};echo and more OK'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_pipepart_roundrobin() {
|
|
|
|
|
echo '### bug #45769: --round-robin --pipepart gives wrong results'
|
|
|
|
|
|
|
|
|
|
seq 10000 >/tmp/seq10000
|
|
|
|
|
parallel -j2 --pipepart -a /tmp/seq10000 --block 14 --round-robin wc | wc -l
|
|
|
|
|
rm /tmp/seq10000
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_pipepart_header() {
|
|
|
|
|
echo '### bug #44614: --pipepart --header off by one'
|
|
|
|
|
|
|
|
|
|
seq 10 >/tmp/parallel_44616
|
|
|
|
|
parallel --pipepart -a /tmp/parallel_44616 -k --block 5 'echo foo; cat'
|
|
|
|
|
parallel --pipepart -a /tmp/parallel_44616 -k --block 2 --regexp --recend 3'\n' 'echo foo; cat'
|
|
|
|
|
rm /tmp/parallel_44616
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_quote() {
|
|
|
|
|
echo '### Test -q'
|
|
|
|
|
parallel -kq perl -e '$ARGV[0]=~/^\S+\s+\S+$/ and print $ARGV[0],"\n"' ::: "a b" c "d e f" g "h i"
|
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo '### Test -q {#}'
|
2019-02-22 18:00:42 +00:00
|
|
|
|
parallel -kq echo {#} ::: a b
|
|
|
|
|
parallel -kq echo {\#} ::: a b
|
|
|
|
|
parallel -kq echo {\\#} ::: a b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_read_from_stdin() {
|
|
|
|
|
echo '### Test empty line as input'
|
|
|
|
|
echo | parallel echo empty input line
|
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo '### Tests if (cat | sh) works'
|
2019-02-22 18:00:42 +00:00
|
|
|
|
perl -e 'for(1..25) {print "echo a $_; echo b $_\n"}' | parallel 2>&1 | sort
|
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo '### Test if xargs-mode works'
|
2019-02-22 18:00:42 +00:00
|
|
|
|
perl -e 'for(1..25) {print "a $_\nb $_\n"}' | parallel echo 2>&1 | sort
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_total_from_joblog() {
|
|
|
|
|
echo 'bug #47086: [PATCH] Initialize total_completed from joblog'
|
|
|
|
|
rm -f /tmp/parallel-47086
|
|
|
|
|
parallel -j1 --joblog /tmp/parallel-47086 --halt now,fail=1 echo '{= $_=$Global::total_completed =};exit {}' ::: 0 0 0 1 0 0
|
|
|
|
|
parallel -j1 --joblog /tmp/parallel-47086 --halt now,fail=1 --resume echo '{= $_=$Global::total_completed =};exit {}' ::: 0 0 0 1 0 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_xapply() {
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo '### Test bug #43284: {%} and {#} with --xapply'
|
|
|
|
|
parallel --xapply 'echo {1} {#} {%} {2}' ::: a ::: b
|
2019-02-22 18:00:42 +00:00
|
|
|
|
parallel -N2 'echo {%}' ::: a b
|
|
|
|
|
|
|
|
|
|
echo '### bug #47501: --xapply for some input sources'
|
|
|
|
|
# Wrapping does not work yet
|
|
|
|
|
parallel -k echo ::: a b c aWRAP :::+ aa bb cc ::: A B :::+ AA BB AAwrap
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_exit_val() {
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo '### Test bug #45619: "--halt" erroneous error exit code (should give 0)'
|
|
|
|
|
seq 10 | parallel --halt now,fail=1 true
|
2019-02-22 18:00:42 +00:00
|
|
|
|
echo $?
|
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo '### Test exit val - true'
|
|
|
|
|
echo true | parallel
|
2019-02-22 18:00:42 +00:00
|
|
|
|
echo $?
|
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo '### Test exit val - false'
|
|
|
|
|
echo false | parallel
|
2019-02-22 18:00:42 +00:00
|
|
|
|
echo $?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_long_cmd_mem_use() {
|
|
|
|
|
echo '### Test long commands do not take up all memory'
|
|
|
|
|
|
|
|
|
|
seq 1 100 |
|
|
|
|
|
parallel -j0 -qv perl -e '$r=rand(shift); for($f = 0; $f < $r; $f++){ $a = "a"x100 } print shift,"\n"' 10000 2>/dev/null |
|
|
|
|
|
sort
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_test_L_context_replace() {
|
|
|
|
|
echo '### Test -N context replace'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-02-22 18:00:42 +00:00
|
|
|
|
seq 19 | parallel -k -N 10 echo a{}b
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-02-22 18:00:42 +00:00
|
|
|
|
echo '### Test -L context replace'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-02-22 18:00:42 +00:00
|
|
|
|
seq 19 | parallel -k -L 10 echo a{}b
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-02-22 18:00:42 +00:00
|
|
|
|
par_test_r_with_pipe() {
|
|
|
|
|
echo '### Test of -r with --pipe - the first should give an empty line. The second should not.'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2019-02-22 18:00:42 +00:00
|
|
|
|
echo | parallel -j2 -N1 --pipe cat | wc -l
|
|
|
|
|
echo | parallel -r -j2 -N1 --pipe cat | wc -l
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_test_tty() {
|
|
|
|
|
echo '### Test --tty'
|
|
|
|
|
|
|
|
|
|
seq 0.1 0.1 0.5 | parallel -j1 --tty tty\;sleep
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
par_no_command_given() {
|
|
|
|
|
echo '### Test bugfix if no command given'
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
(echo echo; seq 1 5; perl -e 'print "z"x1000000'; seq 12 15) |
|
|
|
|
|
stdout parallel -j1 -km -s 10
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2016-06-27 19:00:19 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
par_inefficient_L() {
|
|
|
|
|
echo "bug #37325: Inefficiency of --pipe -L"
|
2016-06-28 16:13:35 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
seq 2000 | parallel -k --pipe --block 1k -L 4 wc\;echo FOO | uniq
|
|
|
|
|
}
|
2016-05-17 00:11:38 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
par_pipe_record_size_in_lines() {
|
|
|
|
|
echo "bug #34958: --pipe with record size measured in lines"
|
2016-08-13 17:11:15 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
seq 10 | parallel -k --pipe -L 4 cat\;echo bug 34958-1
|
|
|
|
|
seq 10 | parallel -k --pipe -l 4 cat\;echo bug 34958-2
|
|
|
|
|
}
|
2016-08-13 17:11:15 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
par_pipe_no_command() {
|
|
|
|
|
echo '### --pipe without command'
|
2016-08-27 21:24:30 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
seq -w 10 | stdout parallel --pipe
|
|
|
|
|
}
|
2016-08-27 21:24:30 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
par_expansion_in_colsep() {
|
|
|
|
|
echo '### bug #36260: {n} expansion in --colsep files fails for empty fields if all following fields are also empty'
|
2016-08-27 21:24:30 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
echo A,B,, | parallel --colsep , echo {1}{3}{2}
|
|
|
|
|
}
|
2016-11-05 17:58:46 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
par_extglob() {
|
|
|
|
|
bash -O extglob -c '. `which env_parallel.bash`;
|
|
|
|
|
_longopt () {
|
|
|
|
|
case "$prev" in
|
|
|
|
|
--+([-a-z0-9_]))
|
|
|
|
|
echo foo;;
|
|
|
|
|
esac;
|
|
|
|
|
};
|
|
|
|
|
env_parallel echo ::: env_parallel 2>&1
|
|
|
|
|
'
|
|
|
|
|
}
|
2016-11-06 11:29:48 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
par_tricolonplus() {
|
|
|
|
|
echo '### bug #48745: :::+ bug'
|
2016-11-06 11:29:48 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
parallel -k echo ::: 11 22 33 ::::+ <(seq 3) <(seq 21 23) ::: a b c :::+ aa bb cc
|
|
|
|
|
parallel -k echo :::: <(seq 3) <(seq 21 23) :::+ a b c ::: aa bb cc
|
|
|
|
|
parallel -k echo :::: <(seq 3) :::: <(seq 21 23) :::+ a b c ::: aa bb cc
|
|
|
|
|
}
|
2016-11-06 11:29:48 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
par_colsep_0() {
|
|
|
|
|
echo 'bug --colsep 0'
|
2015-04-20 22:08:08 +00:00
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
parallel --colsep 0 echo {2} ::: a0OK0c
|
|
|
|
|
parallel --header : --colsep 0 echo {ok} ::: A0ok0B a0OK0b
|
|
|
|
|
}
|
2016-12-18 10:14:06 +00:00
|
|
|
|
|
|
|
|
|
par_empty() {
|
|
|
|
|
echo "bug #:"
|
|
|
|
|
|
|
|
|
|
parallel echo ::: true
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-01 11:42:52 +00:00
|
|
|
|
par_empty_line() {
|
|
|
|
|
echo '### Test bug: empty line for | sh with -k'
|
|
|
|
|
(echo echo a ; echo ; echo echo b) | parallel -k
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_append_joblog() {
|
|
|
|
|
echo '### can you append to a joblog using +'
|
|
|
|
|
parallel --joblog /tmp/parallel_append_joblog echo ::: 1
|
|
|
|
|
parallel --joblog +/tmp/parallel_append_joblog echo ::: 1
|
|
|
|
|
wc -l /tmp/parallel_append_joblog
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_file_ending_in_newline() {
|
|
|
|
|
echo '### Hans found a bug giving unitialized variable'
|
|
|
|
|
echo >/tmp/parallel_f1
|
|
|
|
|
echo >/tmp/parallel_f2'
|
|
|
|
|
'
|
|
|
|
|
echo /tmp/parallel_f1 /tmp/parallel_f2 |
|
|
|
|
|
stdout parallel -kv --delimiter ' ' gzip
|
|
|
|
|
rm /tmp/parallel_f*
|
|
|
|
|
}
|
2016-12-18 10:14:06 +00:00
|
|
|
|
|
2017-01-01 16:51:14 +00:00
|
|
|
|
par_python_children() {
|
|
|
|
|
echo '### bug #49970: Python child process dies if --env is used'
|
|
|
|
|
fu() { echo joe; }
|
|
|
|
|
export -f fu
|
2017-01-06 18:10:20 +00:00
|
|
|
|
echo foo | stdout parallel --env fu python -c \
|
|
|
|
|
\""import os; f = os.popen('uname -p'); output = f.read(); rc = f.close()"\"
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-21 17:09:01 +00:00
|
|
|
|
par_pipepart_block_bigger_2G() {
|
|
|
|
|
echo '### Test that --pipepart can have blocks > 2GB'
|
|
|
|
|
tmp=$(mktemp)
|
|
|
|
|
echo foo >$tmp
|
|
|
|
|
parallel --pipepart -a $tmp --block 3G wc
|
|
|
|
|
rm $tmp
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-04 15:01:42 +00:00
|
|
|
|
par_retries_replacement_string() {
|
|
|
|
|
tmp=$(mktemp)
|
|
|
|
|
parallel --retries {//} "echo {/} >>$tmp;exit {/}" ::: 1/11 2/22 3/33
|
|
|
|
|
sort $tmp
|
|
|
|
|
rm $tmp
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-05 01:46:29 +00:00
|
|
|
|
par_tee() {
|
|
|
|
|
export PARALLEL='-k --tee --pipe --tag'
|
2018-10-22 22:46:38 +00:00
|
|
|
|
seq 1000000 | parallel 'echo {%};LC_ALL=C wc' ::: {1..5} ::: {a..b}
|
|
|
|
|
seq 300000 | parallel 'grep {1} | LC_ALL=C wc {2}' ::: {1..5} ::: -l -c
|
2017-02-05 01:46:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-05 02:24:23 +00:00
|
|
|
|
par_tagstring_pipe() {
|
|
|
|
|
echo 'bug #50228: --pipe --tagstring broken'
|
2018-10-22 22:46:38 +00:00
|
|
|
|
seq 3000 | parallel -j4 --pipe -N1000 -k --tagstring {%} LC_ALL=C wc
|
2017-02-05 02:24:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-01 02:04:47 +00:00
|
|
|
|
par_link_files_as_only_arg() {
|
|
|
|
|
echo 'bug #50685: single ::::+ does not work'
|
2017-04-22 20:42:11 +00:00
|
|
|
|
parallel -k echo ::::+ <(seq 10) <(seq 3) <(seq 4)
|
2017-04-01 02:04:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-22 11:35:58 +00:00
|
|
|
|
par_basic_halt() {
|
|
|
|
|
cpuburn=$(tempfile)
|
|
|
|
|
cpuburn2=$(tempfile)
|
|
|
|
|
(echo '#!/usr/bin/perl'
|
|
|
|
|
echo "eval{setpriority(0,0,9)}; while(1){}") > $cpuburn
|
|
|
|
|
chmod 700 $cpuburn
|
|
|
|
|
cp -a $cpuburn $cpuburn2
|
2017-08-19 23:15:28 +00:00
|
|
|
|
|
2017-06-22 11:35:58 +00:00
|
|
|
|
parallel -j4 --halt 2 ::: 'sleep 1' $cpuburn false;
|
|
|
|
|
killall $(basename $cpuburn) 2>/dev/null &&
|
|
|
|
|
echo ERROR: cpuburn should already have been killed
|
|
|
|
|
parallel -j4 --halt -2 ::: 'sleep 1' $cpuburn2 true;
|
|
|
|
|
killall $(basename $cpuburn2) 2>/dev/null &&
|
|
|
|
|
echo ERROR: cpuburn2 should already have been killed
|
|
|
|
|
rm $cpuburn $cpuburn2
|
2017-08-19 23:15:28 +00:00
|
|
|
|
|
2017-06-22 11:35:58 +00:00
|
|
|
|
parallel --halt error echo ::: should not print
|
|
|
|
|
parallel --halt soon echo ::: should not print
|
|
|
|
|
parallel --halt now echo ::: should not print
|
|
|
|
|
}
|
2017-06-05 09:29:04 +00:00
|
|
|
|
|
2017-07-06 12:36:06 +00:00
|
|
|
|
par_newline_in_command() {
|
|
|
|
|
echo Command with newline and positional replacement strings
|
|
|
|
|
parallel "
|
|
|
|
|
echo {1
|
|
|
|
|
} {2}
|
|
|
|
|
" ::: O ::: K
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-21 19:43:34 +00:00
|
|
|
|
par_wd_3dot_local() {
|
|
|
|
|
echo 'bug #45993: --wd ... should also work when run locally'
|
|
|
|
|
|
2019-09-22 05:30:08 +00:00
|
|
|
|
(
|
|
|
|
|
parallel --wd /bi 'pwd; echo $OLDPWD; echo' ::: fail
|
|
|
|
|
parallel --wd /bin 'pwd; echo $OLDPWD; echo' ::: OK
|
|
|
|
|
parallel --wd / 'pwd; echo $OLDPWD; echo' ::: OK
|
|
|
|
|
parallel --wd /tmp 'pwd; echo $OLDPWD; echo' ::: OK
|
|
|
|
|
parallel --wd ... 'pwd; echo $OLDPWD; echo' ::: OK
|
|
|
|
|
parallel --wd . 'pwd; echo $OLDPWD; echo' ::: OK
|
|
|
|
|
) |
|
2018-01-03 08:03:16 +00:00
|
|
|
|
perl -pe 's:/mnt/4tb::; s:/home/tange:~:;' |
|
2019-09-22 05:30:08 +00:00
|
|
|
|
perl -pe 's:parallel./:parallel/:;' |
|
2018-01-03 08:03:16 +00:00
|
|
|
|
perl -pe 's/'`hostname`'/hostname/g; s/\d+/0/g'
|
2017-07-21 19:43:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_X_eta_div_zero() {
|
|
|
|
|
echo '### bug #34422: parallel -X --eta crashes with div by zero'
|
|
|
|
|
|
|
|
|
|
# We do not care how long it took
|
|
|
|
|
seq 2 | stdout parallel -X --eta echo |
|
|
|
|
|
grep -E -v 'ETA:.*AVG' |
|
2018-12-28 11:47:25 +00:00
|
|
|
|
perl -pe 's/\d+/0/g' |
|
|
|
|
|
perl -pe 's/Comp.* to complete//' |
|
|
|
|
|
perl -ne '/../ and print'
|
2017-07-21 19:43:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-12 16:37:52 +00:00
|
|
|
|
par_parcat_args_stdin() {
|
|
|
|
|
echo 'bug #51690: parcat: read args from stdin'
|
|
|
|
|
tmp1=$(tempfile)
|
|
|
|
|
tmp2=$(tempfile)
|
|
|
|
|
echo OK1 > $tmp1
|
|
|
|
|
echo OK2 > $tmp2
|
|
|
|
|
(echo $tmp1
|
2017-11-26 15:18:55 +00:00
|
|
|
|
echo $tmp2) | parcat | sort
|
2017-08-12 16:37:52 +00:00
|
|
|
|
rm $tmp1 $tmp2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_parcat_rm() {
|
|
|
|
|
echo 'bug #51691: parcat --rm remove fifo when opened'
|
|
|
|
|
tmp1=$(tempfile)
|
|
|
|
|
echo OK1 > $tmp1
|
|
|
|
|
parcat --rm $tmp1
|
|
|
|
|
rm $tmp1 2>/dev/null || echo OK file removed
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-19 23:15:28 +00:00
|
|
|
|
par_linebuffer_files() {
|
|
|
|
|
echo '### bug #48658: --linebuffer --files'
|
|
|
|
|
|
|
|
|
|
stdout parallel --files --linebuffer 'sleep .1;seq {};sleep .1' ::: {1..10} | wc -l
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-21 17:40:03 +00:00
|
|
|
|
par_halt_one_job() {
|
|
|
|
|
echo '# Halt soon if there is a single job'
|
|
|
|
|
echo should run 0 1 = job 1 2
|
|
|
|
|
parallel -j1 --halt now,fail=1 'echo {#};exit {}' ::: 0 1 0
|
|
|
|
|
echo should run 1 = job 1
|
|
|
|
|
parallel -j1 --halt now,fail=1 'echo {#};exit {}' ::: 1 0 1
|
|
|
|
|
echo should run 0 1 = job 1 2
|
|
|
|
|
parallel -j1 --halt soon,fail=1 'echo {#};exit {}' ::: 0 1 0
|
|
|
|
|
echo should run 1 = job 1
|
|
|
|
|
parallel -j1 --halt soon,fail=1 'echo {#};exit {}' ::: 1 0 1
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 14:46:00 +00:00
|
|
|
|
par_blocking_redir() {
|
|
|
|
|
(
|
2018-10-22 22:46:38 +00:00
|
|
|
|
echo 'bug #52740: Bash redirection with process substitution blocks'
|
|
|
|
|
echo Test stdout
|
|
|
|
|
echo 3 | parallel seq > >(echo stdout;wc) 2> >(echo stderr >&2; wc >&2)
|
|
|
|
|
echo Test stderr
|
|
|
|
|
echo nOfilE | parallel ls > >(echo stdout;wc) 2> >(echo stderr >&2; wc >&2)
|
|
|
|
|
) 2>&1 | LC_ALL=C sort
|
2017-12-26 14:46:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-03 08:03:16 +00:00
|
|
|
|
par_pipepart_recend_recstart() {
|
|
|
|
|
echo 'bug #52343: --recend/--recstart does wrong thing with --pipepart'
|
|
|
|
|
tmp1=$(tempfile)
|
|
|
|
|
seq 10 > $tmp1
|
|
|
|
|
parallel -k --pipepart -a $tmp1 --recend '\n' --recstart '6' --block 1 'echo a; cat'
|
|
|
|
|
parallel -k --pipe < $tmp1 --recend '\n' --recstart '6' --block 1 'echo a; cat'
|
|
|
|
|
rm $tmp1 2>/dev/null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_pipe_tag_v() {
|
|
|
|
|
echo 'pipe with --tag -v'
|
|
|
|
|
seq 3 | parallel -v --pipe --tagstring foo cat
|
|
|
|
|
# This should only give the filename
|
|
|
|
|
seq 3 | parallel -v --pipe --tagstring foo --files cat |
|
|
|
|
|
perl -pe 's:/tmp/par.*.par:/tmp/tmpfile.par:'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_dryrun_append_joblog() {
|
|
|
|
|
echo '--dry-run should not append to joblog'
|
|
|
|
|
rm -f /tmp/jl.$$
|
2018-01-06 18:58:01 +00:00
|
|
|
|
parallel -k --jl /tmp/jl.$$ echo ::: 1 2 3
|
|
|
|
|
parallel --dryrun -k --jl +/tmp/jl.$$ echo ::: 1 2 3 4
|
2018-01-03 08:03:16 +00:00
|
|
|
|
# Job 4 should not show up: 3 lines + header = 4
|
|
|
|
|
wc -l < /tmp/jl.$$
|
|
|
|
|
}
|
2017-12-26 14:46:00 +00:00
|
|
|
|
|
2018-04-21 19:50:42 +00:00
|
|
|
|
par_0_no_newline() {
|
|
|
|
|
echo 'A single zero without \n should not be ignored'
|
2019-05-05 23:06:48 +00:00
|
|
|
|
echo -n 0 | parallel echo
|
2018-04-21 19:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_csv() {
|
|
|
|
|
(echo '"col1""x3""","new'
|
|
|
|
|
echo 'line col2","new2'
|
|
|
|
|
echo 'line col3",col 4') |
|
|
|
|
|
parallel --csv echo {1}-{2}-{3}-{4}
|
|
|
|
|
echo '"2""x3"" board","Value with ,",Column 3' |
|
|
|
|
|
parallel --csv echo {1}-{2}-{3}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-22 14:28:01 +00:00
|
|
|
|
par_csv_pipe() {
|
|
|
|
|
echo 'Only pass full records to tail'
|
|
|
|
|
echo 'Too small block size'
|
|
|
|
|
perl -e 'for $b(1..10) {
|
|
|
|
|
print join",", map {"\"$_\n$_\""} $b*1000..$b*1000+1000;
|
|
|
|
|
print "\n"
|
|
|
|
|
}' |
|
2018-05-21 08:04:31 +00:00
|
|
|
|
stdout parallel --pipe --csv -k --block 10k tail -n1 |
|
|
|
|
|
sort -n
|
2018-04-22 14:28:01 +00:00
|
|
|
|
|
|
|
|
|
echo 'More records in single block'
|
|
|
|
|
perl -e 'for $b(1..10) {
|
|
|
|
|
print join",", map {"\"$_\n$_\""} $b*1000..$b*1000+1000;
|
|
|
|
|
print "\n"
|
|
|
|
|
}' |
|
2018-05-21 08:04:31 +00:00
|
|
|
|
stdout parallel --pipe --csv -k --block 100k tail -n1 |
|
|
|
|
|
sort -n
|
2018-04-22 14:28:01 +00:00
|
|
|
|
}
|
2018-04-23 21:45:16 +00:00
|
|
|
|
|
|
|
|
|
par_slow_pipe_regexp() {
|
|
|
|
|
echo "### bug #53718: --pipe --regexp -N blocks"
|
|
|
|
|
echo This should take a few ms, but took more than 2 hours
|
|
|
|
|
seq 54000 80000 |
|
2018-12-28 11:47:25 +00:00
|
|
|
|
parallel -N1000 --regexp --pipe --recstart 4 --recend 5 -k wc
|
|
|
|
|
echo "### These should give same output"
|
|
|
|
|
seq 54000 80000 |
|
|
|
|
|
parallel -N1000 --regexp --pipe --recstart 4 --recend 5 -k cat |
|
|
|
|
|
md5sum
|
|
|
|
|
seq 54000 80000 | md5sum
|
2018-04-23 21:45:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-21 08:04:31 +00:00
|
|
|
|
par_results() {
|
|
|
|
|
echo "### --results test.csv"
|
|
|
|
|
parallel -k --results /tmp/$$.csv echo ::: a b c
|
|
|
|
|
rm /tmp/$$.csv
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-22 19:02:10 +00:00
|
|
|
|
par_testquote() {
|
|
|
|
|
testquote() {
|
|
|
|
|
printf '"#&/\n()*=?'"'" |
|
|
|
|
|
PARALLEL_SHELL=$1 parallel -0 echo
|
|
|
|
|
}
|
|
|
|
|
export -f testquote
|
|
|
|
|
parallel --tag -k testquote ::: ash bash csh dash fdsh fish fizsh ksh ksh93 mksh posh rbash rc rzsh sash sh static-sh tcsh yash zsh
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-10 15:07:24 +00:00
|
|
|
|
par_locale_quoting() {
|
|
|
|
|
echo "### quoting in different locales"
|
|
|
|
|
printf '\243`/tmp/test\243`\n'
|
|
|
|
|
printf '\243`/tmp/test\243`\n' | LC_ALL=zh_HK.big5hkscs xargs echo '$LC_ALL'
|
|
|
|
|
# LC_ALL should be zh_HK.big5hkscs, but that makes quoting hard.
|
|
|
|
|
printf '\243`/tmp/test\243`\n' | LC_ALL=zh_HK.big5hkscs parallel -v echo '$LC_ALL'
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-08 18:45:39 +00:00
|
|
|
|
par_PARALLEL_ENV() {
|
|
|
|
|
echo '### PARALLEL_ENV as variable'
|
|
|
|
|
PARALLEL_ENV="v='OK as variable'" parallel {} '$v' ::: echo
|
|
|
|
|
PARALLEL_ENV=$(mktemp)
|
|
|
|
|
echo '### PARALLEL_ENV as file'
|
|
|
|
|
echo "v='OK as file'" > $PARALLEL_ENV
|
|
|
|
|
PARALLEL_ENV="$PARALLEL_ENV" parallel {} '$v' ::: echo
|
|
|
|
|
echo '### PARALLEL_ENV as fifo'
|
|
|
|
|
rm $PARALLEL_ENV
|
|
|
|
|
mkfifo $PARALLEL_ENV
|
|
|
|
|
# () needed to avoid [1]+ Done
|
|
|
|
|
(echo "v='OK as fifo'" > $PARALLEL_ENV &) 2>/dev/null
|
|
|
|
|
PARALLEL_ENV="$PARALLEL_ENV" parallel {} '$v' ::: echo
|
|
|
|
|
rm $PARALLEL_ENV
|
|
|
|
|
}
|
2018-05-22 19:02:10 +00:00
|
|
|
|
|
2018-07-18 07:49:24 +00:00
|
|
|
|
par_pipe_recend() {
|
|
|
|
|
echo 'bug #54328: --pipe --recend '' blocks'
|
|
|
|
|
seq 3 | parallel -k --pipe --regexp --recend '' -n 1 xxd
|
|
|
|
|
seq 3 | parallel -k --pipe --recend '' -n 1 xxd
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-18 12:36:04 +00:00
|
|
|
|
par_perlexpr_with_newline() {
|
|
|
|
|
echo 'Perl expression spanning 2 lines'
|
2018-07-22 06:58:32 +00:00
|
|
|
|
mkdir -p tmp
|
2018-07-18 12:36:04 +00:00
|
|
|
|
cd tmp
|
|
|
|
|
touch "Dad's \"famous\" 1' pizza"
|
|
|
|
|
# Important with newline in perl expression:
|
|
|
|
|
parallel mv {} '{= $a=pQ($_); $b=$_;
|
|
|
|
|
$_=qx{date -r "$a" +%FT%T}; chomp; $_="$_ $b" =}' \
|
|
|
|
|
::: "Dad's \"famous\" 1' pizza"
|
|
|
|
|
rm *"Dad's \"famous\" 1' pizza"
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-20 22:15:14 +00:00
|
|
|
|
par_empty_command() {
|
|
|
|
|
echo 'bug #54647: parset ignores empty lines'
|
|
|
|
|
# really due to this. Should give an empty line due to -v:
|
|
|
|
|
parallel -v :::: <(echo)
|
|
|
|
|
. `which env_parallel.bash`
|
|
|
|
|
parset a,b,c :::: <(echo echo A; echo; echo echo C)
|
|
|
|
|
echo Empty: $b
|
|
|
|
|
parset a,b,c :::: <(echo echo A; echo echo B; echo echo C)
|
|
|
|
|
echo B: $b
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-22 22:46:38 +00:00
|
|
|
|
par_empty_input_on_stdin() {
|
|
|
|
|
echo 'https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=910470'
|
|
|
|
|
echo 'This should give no output'
|
|
|
|
|
true | stdout parallel --shuf echo
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-25 18:06:06 +00:00
|
|
|
|
par_tee_too_many_args() {
|
|
|
|
|
echo '### Fail if there are more arguments than --jobs'
|
2019-02-22 18:00:42 +00:00
|
|
|
|
seq 11 | parallel -k --tag --pipe -j4 --tee grep {} ::: {1..4}
|
|
|
|
|
seq 11 | parallel -k --tag --pipe -j4 --tee grep {} ::: {1..5}
|
2018-11-25 18:06:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_space_envvar() {
|
|
|
|
|
echo "### bug: --gnu was ignored if env var started with space: PARALLEL=' --gnu'"
|
|
|
|
|
export PARALLEL=" -v" && parallel echo ::: 'space in envvar OK'
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-28 11:47:25 +00:00
|
|
|
|
par_pipe_N1_regexp() {
|
|
|
|
|
echo 'bug #55131: --regexp --recstart hangs'
|
|
|
|
|
echo "These should give the same"
|
|
|
|
|
printf 'begin\n%send\n' '' a b c |
|
|
|
|
|
parallel -kN1 --recstart 'begin\n' --pipe --regexp echo JOB{#}\;cat\;echo END
|
|
|
|
|
printf 'begin\n%send\n' '' a b c |
|
|
|
|
|
parallel -kN1 --recstart 'begin\n' --pipe echo JOB{#}\;cat\;echo END
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 21:33:50 +00:00
|
|
|
|
par_sem_quote() {
|
|
|
|
|
echo '### sem --quote should not add empty argument'
|
2019-05-22 19:57:08 +00:00
|
|
|
|
sem --id sem_quote --fg --quote -v echo
|
2018-12-29 21:33:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 22:21:46 +00:00
|
|
|
|
par_halt_on_error_division_by_zero() {
|
|
|
|
|
echo '### --halt-on-error soon,fail=100% with no input should not give division by zero'
|
|
|
|
|
stdout parallel --halt-on-error soon,fail=100% echo </dev/null
|
|
|
|
|
echo $?
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-06 12:45:43 +00:00
|
|
|
|
par_wd_dotdotdot() {
|
|
|
|
|
echo '### parallel --wd ... should clean up'
|
|
|
|
|
parallel --wd ... 'pwd;true' ::: foo | parallel ls 2>/dev/null
|
|
|
|
|
echo $? == 1
|
|
|
|
|
echo '### $OLDPWD should be the dir in which parallel starts'
|
|
|
|
|
cd /tmp
|
|
|
|
|
parallel --wd ... 'echo $OLDPWD' ::: foo
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-17 22:07:32 +00:00
|
|
|
|
par_fish() {
|
|
|
|
|
echo '### https://github.com/fish-shell/fish-shell/issues/5582'
|
|
|
|
|
echo OK | stdout fish -c 'parallel --pipe cat'
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-05 23:06:48 +00:00
|
|
|
|
par_jobslot_jobnumber_pipe() {
|
|
|
|
|
echo '### Test bug #43376: {%} and {#} with --pipe'
|
|
|
|
|
echo foo | parallel -q --pipe -k echo {#}
|
|
|
|
|
echo foo | parallel --pipe -k echo {%}
|
|
|
|
|
echo foo | parallel -q --pipe -k echo {%}
|
|
|
|
|
echo foo | parallel --pipe -k echo {#}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_replacement_string_as_part_of_command() {
|
|
|
|
|
echo '### {} as part of the command'
|
|
|
|
|
echo p /bin/ls | parallel l{= s/p/s/ =}
|
|
|
|
|
echo /bin/ls-p | parallel --colsep '-' l{=2 s/p/s/ =} {1}
|
|
|
|
|
echo s /bin/ls | parallel l{}
|
|
|
|
|
echo /bin/ls | parallel ls {}
|
|
|
|
|
echo ls /bin/ls | parallel {}
|
|
|
|
|
echo ls /bin/ls | parallel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_japanese_chars_in_replacement_string() {
|
|
|
|
|
echo '### bug #43817: Some JP char cause problems in positional replacement strings'
|
|
|
|
|
parallel -k echo ::: '<27><<3C>>' '<27><1 $_=2<>>' 'ワ'
|
|
|
|
|
parallel -k echo {1} ::: '<27><<3C>>' '<27><1 $_=2<>>' 'ワ'
|
|
|
|
|
parallel -Xj1 echo ::: '<27><<3C>>' '<27><1 $_=2<>>' 'ワ'
|
|
|
|
|
parallel -Xj1 echo {1} ::: '<27><<3C>>' '<27><1 $_=2<>>' 'ワ'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_rpl_that_is_substring_of_longer_rpl() {
|
|
|
|
|
echo '### --rpl % that is a substring of longer --rpl %D'
|
|
|
|
|
parallel --rpl '{+.} s:.*\.::' --rpl '%' \
|
|
|
|
|
--rpl '%D $_=::shell_quote(::dirname($_));' \
|
|
|
|
|
--rpl '%B s:.*/::;s:\.[^/.]+$::;' \
|
|
|
|
|
--rpl '%E s:.*\.::' \
|
|
|
|
|
'echo {}=%;echo %D={//};echo %B={/.};echo %E={+.};echo %D/%B.%E={}' ::: a.b/c.d/e.f
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-23 06:31:28 +00:00
|
|
|
|
par_unquote_replacement_string() {
|
|
|
|
|
echo '### Can part of the replacement string be unquoted using uq()?'
|
|
|
|
|
parallel echo '{}{=uq()=}' ::: '`echo foo`'
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-26 11:46:29 +00:00
|
|
|
|
par_delimiter_space() {
|
|
|
|
|
echo '### Does space as delimiter work?'
|
2020-04-22 18:15:59 +00:00
|
|
|
|
parallel -k -d " " echo ::: "1 done"
|
2019-06-26 11:46:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-26 21:11:33 +00:00
|
|
|
|
par_recend_not_regexp() {
|
|
|
|
|
echo '### bug #56558: --rrs with --recend that is not regexp'
|
|
|
|
|
echo 'a+b' | parallel -k --pipe --rrs --recend '+' -N1 'cat;echo end'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par_profile() {
|
|
|
|
|
echo '### Test -J profile, -J /dir/profile, -J ./profile'
|
|
|
|
|
echo --tag > testprofile_local
|
|
|
|
|
parallel -J ./testprofile_local echo ::: local
|
|
|
|
|
rm testprofile_local
|
|
|
|
|
echo --tag > testprofile_abs
|
|
|
|
|
parallel -J `pwd`/testprofile_abs echo ::: abs
|
|
|
|
|
rm testprofile_abs
|
|
|
|
|
echo --tag > ~/.parallel/testprofile_config
|
|
|
|
|
parallel -J testprofile_config echo ::: config
|
|
|
|
|
rm ~/.parallel/testprofile_config
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 20:38:30 +00:00
|
|
|
|
par_cr_newline_header() {
|
|
|
|
|
echo '### --header : should set named replacement string if input line ends in \r\n'
|
|
|
|
|
printf "foo\r\nbar\r\n" |
|
|
|
|
|
parallel --colsep , --header : echo {foo}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-23 16:44:42 +00:00
|
|
|
|
par_plus_slot_replacement() {
|
|
|
|
|
echo '### show {slot}'
|
|
|
|
|
parallel -k --plus echo '{slot}=$PARALLEL_JOBSLOT={%}' ::: A B C
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-18 10:14:06 +00:00
|
|
|
|
export -f $(compgen -A function | grep par_)
|
2018-10-22 22:46:38 +00:00
|
|
|
|
compgen -A function | grep par_ | LC_ALL=C sort |
|
2020-06-22 22:34:52 +00:00
|
|
|
|
parallel --timeout 1000% -j6 --tag -k --joblog /tmp/jl-`basename $0` '{} 2>&1' |
|
|
|
|
|
perl -pe 's:/usr/bin:/bin:g'
|