File: checkoptcc

package info (click to toggle)
opt 3.19-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,064 kB
  • sloc: ansic: 3,899; perl: 863; sh: 554; cpp: 524; tcl: 325; makefile: 50
file content (72 lines) | stat: -rwxr-xr-x 1,749 bytes parent folder | download | duplicates (6)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /bin/sh
## Perform various tests automatically -- for C++ version of code

##
PATH=.:$PATH
## Change output to a real file if you need further diagnostics
output=/dev/null
echo > $output

## checkit: if previous command successful, then print a dot
##          otherwise note an error
## checkitneg: vice versa
##
checkit ()    { if [ $? -eq 0 ]; then echo -n "."; else waserror $*; fi;
    }
checkitneg () { if [ $? -ne 0 ]; then echo -n "."; else waserror $*; fi;
    }

errcount=0
waserror()    { echo; echo Error: $*; errcount=`expr $errcount + 1`;
    }
################################
## Make sure we have the latest versions...
make testcc

################################

testcc | grep Hello >> $output
checkit to see that testcc basically works

## Check -y # and -y#
##
testcc -m 11 | grep month >> $output
checkit identify that user set month

testcc -m 11 | grep '/11/' >> $output
checkit that month set properly

## Check long options
##
testcc --month 12 | grep '/12/' >> $output
checkit longname --month

## Check that invalid numeric arguments are flagged
testcc --month July 2>&1 | grep 'OPT Warning' >> $output
checkit failed to flag invalid numeric arguments

## Check opthelp
##
testcc \?d 2>&1 | grep "32" >> $output
checkit opthelp

## Check optQuit
##
echo . | testcc --menu | grep "Bye" >> $output
checkit optQuit

testcc -m 9 -- snarfle | grep 'Extra option: snarfle' >> $output
checkit reading strings after the unadorned --
testcc -m 7 snarfle | grep 'Hello, snarfle' >> $output
checkit reading strings after processing is finished

## Check optexec
testcc --version | grep 99 >> $output
checkit optexec

echo "Done"
if [ $errcount -eq 0 ]; then echo "PASSED"; else echo "$errcount errors"; fi
exit $errcount