xref: /freebsd/usr.bin/soelim/tests/soelim_test.sh (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1
2atf_test_case stdin
3stdin_head()
4{
5	atf_set "descr" "stdin functionality"
6}
7
8stdin_body()
9{
10	# no file after .so
11	atf_check \
12		-o inline:".so\n" \
13		-e empty \
14		-s exit:0 \
15		soelim <<-EOF
16.so
17EOF
18
19	# only space after .so
20	atf_check \
21		-o inline:".so  	\n" \
22		-e empty \
23		-s exit:0 \
24		soelim <<-EOF
25.so  	
26EOF
27
28	# explicit stdin
29	atf_check \
30		-o inline:".so\n" \
31		-e empty \
32		-s exit:0 \
33		soelim - <<-EOF
34.so
35EOF
36
37	atf_check \
38		-o empty \
39		-e inline:"soelim: can't open 'afile': No such file or directory\n" \
40		-s exit:1 \
41		soelim <<-EOF
42.so afile
43EOF
44
45	atf_check \
46		-o inline:".soafile\n" \
47		-e empty \
48		-s exit:0 \
49		soelim <<-EOF
50.soafile
51EOF
52
53	atf_check \
54		-o empty \
55		-e inline:"soelim: can't open 'afile': No such file or directory\n" \
56		-s exit:1 \
57		soelim -C <<-EOF
58.soafile
59EOF
60}
61
62atf_test_case files
63files_head()
64{
65	atf_set "descr" "testing files"
66}
67
68files_body()
69{
70	atf_check \
71		-o inline:"This is a test\n" \
72		-e inline:"soelim: can't open 'nonexistingfile': No such file or directory\n" \
73		-s exit:1 \
74		soelim $(atf_get_srcdir)/nonexisting.in
75
76	cp $(atf_get_srcdir)/basic .
77	atf_check \
78		-o file:$(atf_get_srcdir)/basic.out \
79		-e empty \
80		-s exit:0 \
81		soelim $(atf_get_srcdir)/basic.in
82
83	rm -f basic
84	atf_check \
85		-o file:$(atf_get_srcdir)/basic.out \
86		-e empty \
87		-s exit:0 \
88		soelim -I$(atf_get_srcdir) $(atf_get_srcdir)/basic.in
89
90	atf_check \
91		-o file:$(atf_get_srcdir)/basic-with-space.out \
92		-e empty \
93		-s exit:0 \
94		soelim -I$(atf_get_srcdir) $(atf_get_srcdir)/basic-with-space.in
95
96}
97
98atf_init_test_cases()
99{
100	atf_add_test_case stdin
101	atf_add_test_case files
102}
103