-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·58 lines (49 loc) · 1.22 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# These are a few minimal integration level regression tests.
# Everything 'cept check_eq() should be pretty self-explanitory.
# Look up 'indirect references' if you want to know what that hacky-ass
# eval nonesense is about.
set -e
optbot=bin/optbot
check_eq() {
eval val=\$$1
if ! [ "$val" = "$2" ]; then
echo >&2 "$1 set to: $val not: $2"
exit 1
fi
}
test_initial() {
eval `$optbot -aa,opt_a,"blah",false -- $@`
check_eq arg_opt_a true
}
test_initial -a
test_multiple() {
eval `$optbot -aa,opt_a,"blah",false -ab,opt_b,"blah",false -- $@`
check_eq arg_opt_b true
check_eq arg_opt_a true
}
test_multiple -a -b
test_values() {
eval `$optbot -aa,opt_a,"blah",true -- $@`
check_eq arg_opt_a_n 2
check_eq arg_opt_a one
check_eq arg_opt_a_1 one
check_eq arg_opt_a_2 two
}
test_values -a one -a two
test_argv() {
eval `$optbot -aa,opt_a,"engages hypnotoad",true -- $@`
check_eq arg_argc 2
check_eq arg_opt_a beautiful
check_eq arg_argv_1 hello
check_eq arg_argv_2 world
}
test_argv hello -a beautiful world
test_help() {
$optbot -aa,opt_a,"does great things",true -- $@ 2>&1 |
if ! grep -q "does great things"; then
echo 'Help output seems broken'
exit 1
fi
}
test_help -h