Enable inc(1) to read from stdin
[mmh] / test / tests / inc / test-read-stdin
1 #!/bin/sh
2 ##########################################################
3 # Test incorporating mail from stdin with `inc -file -`. #
4 ##########################################################
5 . "$MH_TEST_COMMON"
6
7 # Test empty stdin from a pipe.
8 runandcheck "printf '' |inc -file -" <<!
9 Incorporating new mail into inbox...
10
11 inc: no messages incorporated, continuing...
12 !
13
14 # Test empty stdin from redirected regular file.
15 cd "$MMH_TEST_DIR"
16 f=mbox
17 runandcheck "printf '' >$f && inc -file - <$f" <<!
18 Incorporating new mail into inbox...
19
20 inc: no messages incorporated, continuing...
21 !
22 rm "$f"
23 unset f
24
25 # Test empty stdin from character device.
26 runandcheck "inc -file - </dev/null" <<!
27 Incorporating new mail into inbox...
28
29 inc: no messages incorporated, continuing...
30 !
31
32 # Test nonempty pipe.
33 runandcheck "packf +inbox |inc -file -" <<!
34 Incorporating new mail into inbox...
35
36   11+ 2006-09-29 00:00  Test1              Testing message 1
37   12  2006-09-29 00:00  Test2              Testing message 2
38   13  2006-09-29 00:00  Test3              Testing message 3
39   14  2006-09-29 00:00  Test4              Testing message 4
40   15  2006-09-29 00:00  Test5              Testing message 5
41   16  2006-09-29 00:00  Test6              Testing message 6
42   17  2006-09-29 00:00  Test7              Testing message 7
43   18  2006-09-29 00:00  Test8              Testing message 8
44   19  2006-09-29 00:00  Test9              Testing message 9
45   20  2006-09-29 00:00  Test10             Testing message 10
46 !
47
48 # Test nonempty redirected stdin.
49 cd "$MMH_TEST_DIR"
50 f=mbox
51 runandcheck "packf +inbox 1-10 >$f && inc -file - <$f" <<!
52 Incorporating new mail into inbox...
53
54   21+ 2006-09-29 00:00  Test1              Testing message 1
55   22  2006-09-29 00:00  Test2              Testing message 2
56   23  2006-09-29 00:00  Test3              Testing message 3
57   24  2006-09-29 00:00  Test4              Testing message 4
58   25  2006-09-29 00:00  Test5              Testing message 5
59   26  2006-09-29 00:00  Test6              Testing message 6
60   27  2006-09-29 00:00  Test7              Testing message 7
61   28  2006-09-29 00:00  Test8              Testing message 8
62   29  2006-09-29 00:00  Test9              Testing message 9
63   30  2006-09-29 00:00  Test10             Testing message 10
64 !
65 rm "$f"
66 unset f