File: test_script.sh

package info (click to toggle)
mdbtools 1.0.1-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,348 kB
  • sloc: ansic: 12,252; sh: 516; xml: 218; yacc: 188; lex: 129; makefile: 126; python: 27
file content (131 lines) | stat: -rwxr-xr-x 2,728 bytes parent folder | download
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh

# Simple test script; run after performing
# git clone https://github.com/mdbtools/mdbtestdata.git test

set -o errexit
set -o nounset

LANG=C.UTF-8
CDPATH= cd -- "$(dirname -- "$0")"

parseArgs() {
	MT_OUTPUT_KIND=verbose
	while :; do
		if test $# -lt 1; then
			break
		fi
		case "$1" in
			-q | --quiet)
				MT_OUTPUT_KIND=quiet
				;;
			-g | --github)
				MT_OUTPUT_KIND=github
				;;
			-h | --help)
				printf 'Syntax:\n%s [-q|--quiet|-g|--github] [-h|--help]\n' "$0"
				exit 0
				;;
			*)
				printf 'Unrecognized option: "%s"\n' "$1"
				exit 1
				;;
		esac
		shift
	done
}

testCommand() {
	testCommand_name="$1"
	shift
	case $MT_OUTPUT_KIND in
		verbose)
			printf '# Running %s (%s)\n' "$testCommand_name" "$*"
			if "./src/util/$testCommand_name" "$@"; then
				return 0
			fi
			return 1
			;;
		quiet)
			printf 'Testing %s (%s)... ' "$testCommand_name" "$*"
			if "./src/util/$testCommand_name" "$@" >/dev/null; then
				printf 'passed.\n'
				return 0
			fi
			return 1
			;;
		github)
			testCommand_tempFile="$(mktemp)"
			printf 'Testing %s (%s)... ' "$testCommand_name" "$*"
			if "./src/util/$testCommand_name" "$@" 2>&1 >"$testCommand_tempFile"; then
				printf 'passed.\n'
				testCommand_rc=0
			else
				printf 'failed.\n'
				testCommand_rc=1
			fi
			echo '::group::Output'
			cat "$testCommand_tempFile"
			echo '::endgroup::'
			unlink "$testCommand_tempFile"
			return $testCommand_rc
			;;
		*)
			printf 'Unrecognized MT_OUTPUT_KIND (%s)\n' "$MT_OUTPUT_KIND"
			exit 1
			;;
	esac
}

parseArgs "$@"

rc=0
if ! testCommand mdb-json test/data/ASampleDatabase.accdb "Asset Items"; then
	rc=1
fi
if ! testCommand mdb-json test/data/nwind.mdb "Umsätze"; then
	rc=1
fi
if ! testCommand mdb-count test/data/ASampleDatabase.accdb "Asset Items"; then
	rc=1
fi
if ! testCommand mdb-count test/data/nwind.mdb "Umsätze"; then
	rc=1
fi
if ! testCommand mdb-prop test/data/ASampleDatabase.accdb "Asset Items"; then
	rc=1
fi
if ! testCommand mdb-prop test/data/nwind.mdb "Umsätze"; then
	rc=1
fi
if ! testCommand mdb-schema test/data/ASampleDatabase.accdb; then
	rc=1
fi
if ! testCommand mdb-schema test/data/nwind.mdb; then
	rc=1
fi
if ! testCommand mdb-schema test/data/nwind.mdb -T "Umsätze" postgres; then
	rc=1
fi
if ! testCommand mdb-tables test/data/ASampleDatabase.accdb; then
	rc=1
fi
if ! testCommand mdb-tables test/data/nwind.mdb; then
	rc=1
fi
if ! testCommand mdb-ver test/data/ASampleDatabase.accdb; then
	rc=1
fi
if ! testCommand mdb-ver test/data/nwind.mdb; then
	rc=1
fi
if ! testCommand mdb-queries test/data/ASampleDatabase.accdb qryCostsSummedByOwner; then
	rc=1
fi

if [ $rc = 0 ]; then
	printf -- '\n%s passed.\n' "$0"
else
	printf -- '\n%s failed!\n' "$0"
fi
exit $rc