From 9f6447e2cb96d19f0243214d0e68dada3c794169 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Wed, 8 Feb 2012 23:26:29 -0500 Subject: [PATCH] Add a test for --shuffle option. --- t/140-shuffle/.gitignore | 1 + t/140-shuffle/all.do | 19 +++++++++++++++++++ t/140-shuffle/clean.do | 1 + t/140-shuffle/default.x.do | 1 + 4 files changed, 22 insertions(+) create mode 100644 t/140-shuffle/.gitignore create mode 100644 t/140-shuffle/all.do create mode 100644 t/140-shuffle/clean.do create mode 100644 t/140-shuffle/default.x.do diff --git a/t/140-shuffle/.gitignore b/t/140-shuffle/.gitignore new file mode 100644 index 0000000..397b4a7 --- /dev/null +++ b/t/140-shuffle/.gitignore @@ -0,0 +1 @@ +*.log diff --git a/t/140-shuffle/all.do b/t/140-shuffle/all.do new file mode 100644 index 0000000..fd88405 --- /dev/null +++ b/t/140-shuffle/all.do @@ -0,0 +1,19 @@ +exec >&2 +. ../skip-if-minimal-do.sh + +# Need to repeat this several times, on the off chance that shuffling the +# input happens to give us the same output (probability 1/factorial(9)) +x=0 +while [ "$x" -lt 10 ]; do + x=$(($x + 1)) + rm -f out.log + redo --shuffle 1.x 2.x 3.x 4.x 5.x 6.x 7.x 8.x 9.x + sort out.log >sort.log + if ! diff -q out.log sort.log >/dev/null; then + exit 0 + fi + echo "retry: #$x" +done + +# still not shuffled? +exit 22 diff --git a/t/140-shuffle/clean.do b/t/140-shuffle/clean.do new file mode 100644 index 0000000..880a5b1 --- /dev/null +++ b/t/140-shuffle/clean.do @@ -0,0 +1 @@ +rm -f *.log *~ .*~ diff --git a/t/140-shuffle/default.x.do b/t/140-shuffle/default.x.do new file mode 100644 index 0000000..2e904cd --- /dev/null +++ b/t/140-shuffle/default.x.do @@ -0,0 +1 @@ +echo $1 >>out.log