-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathrun-ut
executable file
·101 lines (84 loc) · 2.44 KB
/
run-ut
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
#================================================================================
# Run unit tests
#
# $1 Test configuration file name
# $2 Program to be tested (without suffix)
# $3 Unit test cases copy file
# $4 Test driver program name
#
#================================================================================
function run_unit_tests {
. envvars
export SRCPRG="$MAINSRC/$PROGRAM.CBL"
export TESTPRG="$TESTSRC/TESTPRG.CBL"
export TESTNAME=TESTPRG
export UTSTCFG="$TESTRSC/$CONFIG"
export UTESTS="$TESTCPY/$UNITTESTS"
if [ $DEBUG == true ]; then
echo "SRCPRG=$SRCPRG"
echo "TESTPRG=$TESTPRG"
echo "TESTNAME=$TESTNAME"
echo "UTSTCFG=$UTSTCFG"
echo "UTESTS=$UTESTS"
echo "COBCPY=$COBCPY"
echo "COB_LIBRARY_PATH=$COB_LIBRARY_PATH"
fi
rm "$TARGET/TESTPRG" 2> /dev/null
"$TARGET/ZUTZCPC"
if [ $? -eq 0 ]; then
if [ $SUBPROGRAM == true ]; then
compile -ts "$TESTNAME"
mv "$TARGET/TESTPRG.so" "$TARGET/$PROGRAM.so"
"$TARGET/$DRIVER"
else
compile -t "$TESTNAME"
"$TARGET/$TESTNAME"
fi
fi
}
function show_help {
echo 'Run unit test cases for a Cobol program'
echo 'Usage: run ut [options]'
echo ' config-file-name'
echo ' program-name-without-suffix'
echo ' unit-test-copy-file-name'
echo ' [test-driver-program-name]'
echo ' -d | --debug Echo debugging information'
echo ' -h | --help Display usage help (this text) and exit'
echo ' -s | --subprogram Compile the program under test as a subprogram'
echo ' (requires test-driver-program-name)'
echo ' -v | --version Display the version of the unit test framework'
}
function show_version {
echo "Cobol batch unit test framework $VERSION"
}
DEBUG=false
SUBPROGRAM=false
TEMP=`getopt -o dhsv --long debug,help,subprogram,version \
-n 'javawrap' -- "$@"`
if [ $? != 0 ] ; then show_help >&2 ; exit 0 ; fi
eval set -- "$TEMP"
while [ $# -gt 0 ]; do
case "$1" in
-d | --debug ) DEBUG=true; shift ;;
-h | --help ) show_help; exit 0 ;;
-s | --subprogram ) SUBPROGRAM=true; shift ;;
-v | --version ) show_version; exit 0 ;;
-- ) shift; break ;;
* ) break ;;
esac
done
if [ $# -eq 0 ]
then
show_help
exit 0
fi
CONFIG="$1"
PROGRAM="$2"
UNITTESTS="$3"
DRIVER="$4"
echo '=================================================='
echo "Running: $0 $@"
run_unit_tests
exit 0