Files
vx/tests/test_xargs.sh

36 lines
960 B
Bash
Executable File

#!/bin/sh
# tests/test_xargs.sh - Tests for xargs applet
_test_name="xargs"
. "$(dirname "$0")/harness.sh"
setup_tmpdir
XARGS="$VX xargs"
echo "Running xargs tests..."
out="$(printf 'a\nb\n' | $XARGS echo ITEM:)"
check_eq "$out" "ITEM: a b" "basic: appends stdin items"
out="$(printf 'a\nb\nc\n' | $XARGS -n 2 echo CHUNK:)"
check_eq "$out" "CHUNK: a b
CHUNK: c" "nflag: max args"
out="$(printf 'one\ntwo\n' | $XARGS -I '{}' echo X{}Y)"
check_eq "$out" "XoneY
XtwoY" "Iflag: replacement"
out="$(printf 'one\ntwo\n' | $XARGS -J '{}' echo PRE POST '{}')"
check_eq "$out" "PRE POST one two" "Jflag: replacement at custom position"
printf 'aa\0bb cc\0' > nul
out="$(cat nul | $XARGS -0 echo Z:)"
check_eq "$out" "Z: aa bb cc" "0flag: NUL-delimited input"
out="$(printf 'a\nb\n' | $XARGS -L 1 echo LINE:)"
check_eq "$out" "LINE: a
LINE: b" "Lflag: one line per command"
check_exit "exit: bad option exits 1" 1 $XARGS --definitely-not-a-real-option
summary