X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0f0af4e32a4d734209c16282b63f7cb1094e2699..HEAD:/test/prompter/test-prompter diff --git a/test/prompter/test-prompter b/test/prompter/test-prompter index 69eb9dd1..3427790a 100755 --- a/test/prompter/test-prompter +++ b/test/prompter/test-prompter @@ -16,6 +16,8 @@ fi setup_test +check_exit '-eq 1' prompter - + expected=$MH_TEST_DIR/$$.expected expected_err=$MH_TEST_DIR/$$.expected_err actual=$MH_TEST_DIR/$$.actual @@ -23,6 +25,7 @@ actual_err=$MH_TEST_DIR/$$.actual_err # check -help +start_test "-help" cat >$expected <$actual 2>&1 -check $expected $actual +#### Skip nmh intro text. +run_prog prompter -help 2>&1 | sed '/^$/,$d' >"$actual" +check "$expected" "$actual" # check -version +start_test "-version" case `prompter -v` in prompter\ --*) ;; * ) printf '%s: prompter -v generated unexpected output\n' "$0" >&2 @@ -46,13 +51,16 @@ case `prompter -v` in esac # check unknown switch +start_test "unknown switch" run_test 'prompter -nonexistent' 'prompter: -nonexistent unknown' # check with no switches +start_test "with no switches" run_test 'prompter' 'prompter: usage: prompter [switches] file' # check with file +start_test "with file" cat >$expected < /dev/null + run_prog prompter $MH_TEST_DIR/prompter-file >/dev/null check "$expected" "$MH_TEST_DIR/prompter-file" 'keep first' # check -doteof +start_test "-doteof" cat >$MH_TEST_DIR/prompter-file < /dev/null + run_prog prompter -doteof $MH_TEST_DIR/prompter-file >/dev/null check "$expected" "$MH_TEST_DIR/prompter-file" 'keep first' # check -nodoteof +start_test "-nodoteof" cat >$MH_TEST_DIR/prompter-file < /dev/null + run_prog prompter -doteof -nodoteof $MH_TEST_DIR/prompter-file >/dev/null check "$expected" "$MH_TEST_DIR/prompter-file" 'keep first' # check -noprepend +start_test "-noprepend" cat >$MH_TEST_DIR/prompter-file <> "$expected" +printf 'appendage\n' >>"$expected" printf 'recipient@example.com\ncc@example.com\n+outbox\nappendage\n' | \ - prompter -noprepend $MH_TEST_DIR/prompter-file > /dev/null + run_prog prompter -noprepend $MH_TEST_DIR/prompter-file >/dev/null check "$expected" "$MH_TEST_DIR/prompter-file" # check -prepend +start_test "-prepend" cat >$MH_TEST_DIR/prompter-file < /dev/null + run_prog prompter -noprepend -prepend $MH_TEST_DIR/prompter-file >/dev/null check "$MH_TEST_DIR/prompter-file" "$expected" 'keep first' # check -rapid +start_test "-rapid" cat >$expected < "$actual" < /dev/null +run_prog prompter -rapid $MH_TEST_DIR/prompter-file >"$actual" $expected < "$actual" < /dev/null +run_prog prompter -rapid -norapid $MH_TEST_DIR/prompter-file \ + >"$actual" "$actual" + run_prog prompter -erase '' -kill '' $MH_TEST_DIR/prompter-file >"$actual" check "$expected" "$actual" # check -body. It's undocumented but the default, so make sure that +start_test "-body. It's undocumented but the default, so make sure that" # it reverses the effect of -nobody. cat >$expected < "$actual" < /dev/null +run_prog prompter -nobody -body $MH_TEST_DIR/prompter-file >"$actual" \ + $expected < /dev/null +run_prog prompter -nobody $MH_TEST_DIR/prompter-file >/dev/null check "$expected" "$MH_TEST_DIR/prompter-file" +finish_test exit ${failed:-0}