Add tests for pick
authorPhilipp Takacs <philipp@bureaucracy.de>
Sat, 17 Jan 2015 00:01:57 +0000 (01:01 +0100)
committerPhilipp Takacs <philipp@bureaucracy.de>
Sat, 17 Jan 2015 00:36:52 +0000 (01:36 +0100)
Add two patches for pick. One to test the normale behavior,
and one to test if a ``0'' is print to stdout when no message is
find.

test/tests/pick/test-normal-output [new file with mode: 0644]
test/tests/pick/test-output-on-error [new file with mode: 0644]

diff --git a/test/tests/pick/test-normal-output b/test/tests/pick/test-normal-output
new file mode 100644 (file)
index 0000000..bd1a2e7
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+######################################################
+#
+# Test that all messages are picked and no ``0'' is giving out.
+#
+######################################################
+
+expected_err=$MH_TEST_DIR/$$.expected_err
+expected_out=$MH_TEST_DIR/$$.expected_out
+actual_err=$MH_TEST_DIR/$$.actual_err
+actual_out=$MH_TEST_DIR/$$.actual_out
+
+# All messages should be go to stdout
+cat > $expected_out <<EOF
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+EOF
+# Nothing should to go stderr
+cat /dev/null > $expected_err
+
+pick > $actual_out 2> $actual_err
+diff -u $expected_err $actual_err
+diff -u $expected_out $actual_out
diff --git a/test/tests/pick/test-output-on-error b/test/tests/pick/test-output-on-error
new file mode 100644 (file)
index 0000000..8d96224
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+######################################################
+#
+# Test output is handelt corect and ``0'' is giving to stdout.
+#
+######################################################
+
+expected_err=$MH_TEST_DIR/$$.expected_err
+expected_out=$MH_TEST_DIR/$$.expected_out
+actual_err=$MH_TEST_DIR/$$.actual_err
+actual_out=$MH_TEST_DIR/$$.actual_out
+
+# A zero should go to standard out to protect other programms
+cat > $expected_out <<EOF
+0
+EOF
+# Error message should go to stderr.
+cat > $expected_err <<EOF
+pick: no messages match specification
+EOF
+
+pick -after tomorrow > $actual_out 2> $actual_err
+diff -u $expected_err $actual_err
+diff -u $expected_out $actual_out