Home | History | Annotate | Download | only in tests
      1 #!/bin/bash
      2 
      3 [ -f testing.sh ] && . testing.sh
      4 
      5 #testing "name" "command" "result" "infile" "stdin"
      6 
      7 testing "xargs" "xargs && echo yes" "hello\nyes\n" "" "hello"
      8 testing "spaces" "xargs" \
      9 	"one two three four\n" "" "one two\tthree  \nfour\n\n"
     10 
     11 testing "-n 0" "xargs -n 0 2>/dev/null || echo ok" "ok\n" \
     12 	"" "one \ntwo\n three"
     13 testing "-n 2" "xargs -n 2" "one two\nthree\n" "" "one \ntwo\n three"
     14 testing "-n exact match" "xargs -n 3" "one two three\n" "" "one two three"
     15 testing "xargs2" "xargs -n2" "one two\nthree four\nfive\n" "" \
     16 	"one two three four five"
     17 testing "-s too long" "xargs -s 9 echo 2>/dev/null || echo ok" \
     18 	"one\ntwo\nok\n" "" "one two three"
     19 testing "-s 13" "xargs -s 13 echo" "one two\nthree\n" "" "one \ntwo\n three"
     20 testing "-s 12" "xargs -s 12 echo" "one\ntwo\nthree\n" "" "one \ntwo\n three"
     21 
     22 touch one two three
     23 testing "command -opt" "xargs -n2 ls -1" "one\ntwo\nthree\n" "" \
     24 	"one two three"
     25 rm one two three
     26 
     27 #testing "-n exact match"
     28 #testing "-s exact match"
     29 #testing "-s 0"
     30 #testing "-s impossible"
     31 
     32 # xargs command_not_found - returns 127
     33 # xargs false - returns 1
     34