-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-tests.bash
executable file
·145 lines (120 loc) · 4.25 KB
/
run-tests.bash
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# run-tests - run implemented self end-to-end tests
#
# Copyright (C) hdsdi3g for hd3g.tv 2022
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or any
# later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Usage: ./run-tests
#
# manage-internal-deb-repo are not tested here
set -eu
cd "$(dirname "$0")"
###################
# SETUP TESTS ZONE
###################
PREFIX="src";
export PREFIX="$PREFIX";
TESTROOT="test";
TEST_TEMP_DIR="$TESTROOT/temp";
if [ -d "$TEST_TEMP_DIR" ]; then
rm -rf "$TEST_TEMP_DIR";
fi
mkdir -p "$TEST_TEMP_DIR";
###################
# DEB CLI TEST ZONE
###################
"$PREFIX/usr/bin/make-springboot-deb" "$TESTROOT/democlispringboot" "$TEST_TEMP_DIR"
EXPECTED_TEST_PACKAGE="$TEST_TEMP_DIR/democlispringboot-0.0.1-SNAPSHOT.deb";
if [ ! -f "$EXPECTED_TEST_PACKAGE" ]; then
echo "Error: can't found builded package: $EXPECTED_TEST_PACKAGE" >&2;
exit 1;
fi
################
# DEB TEST ZONE
################
"$PREFIX/usr/bin/make-springboot-deb" "$TESTROOT/demospringboot" "$TEST_TEMP_DIR"
EXPECTED_TEST_PACKAGE="$TEST_TEMP_DIR/demospringboot-0.0.1-SNAPSHOT.deb";
if [ ! -f "$EXPECTED_TEST_PACKAGE" ]; then
echo "Error: can't found builded package: $EXPECTED_TEST_PACKAGE" >&2;
exit 1;
fi
################
# RPM TEST ZONE
################
"$PREFIX/usr/bin/make-springboot-rpm" "$TESTROOT/demospringboot" "$TEST_TEMP_DIR"
EXPECTED_TEST_PACKAGE="$TEST_TEMP_DIR/demospringboot-0.0.1-SNAPSHOT.rpm";
if [ ! -f "$EXPECTED_TEST_PACKAGE" ]; then
echo "Error: can't found builded package: $EXPECTED_TEST_PACKAGE" >&2;
exit 1;
fi
RMP_QI="$TEST_TEMP_DIR/rpm-qi.txt";
rpm -qi "$EXPECTED_TEST_PACKAGE" > $RMP_QI;
function assert_equals() {
local ATTR;
ATTR=$(grep "$1" $RMP_QI | head -1 | cut -d ":" -f 2 | xargs);
if [ "$ATTR" != "$2" ]; then
echo "Error: invalid package information [$1], expected $2, but was $ATTR" >&2;
exit 1;
fi
}
assert_equals Name demospringboot;
assert_equals Version 0.0.1.SNAPSHOT;
assert_equals Architecture noarch;
assert_equals Group "System Environment/Daemons";
assert_equals License "GNU General Public License, Version 3";
assert_equals Signature "(none)"
assert_equals Vendor "hd3g.tv"
RMP_QLP="$TEST_TEMP_DIR/rpm-qlp.txt";
rpm -qlp "$EXPECTED_TEST_PACKAGE" > "$RMP_QLP"
function assert_contain() {
if ! grep -q "$1" "$RMP_QLP"; then
echo "Error: can't found file $1, in builded package" >&2;
exit 1;
fi
}
assert_contain "/etc/default/demospringboot";
assert_contain "/etc/demospringboot";
assert_contain "/etc/demospringboot/application.yml";
assert_contain "/etc/demospringboot/logback.xml";
assert_contain "/usr/lib/demospringboot";
assert_contain "/usr/lib/demospringboot/THIRD-PARTY.txt";
assert_contain "/usr/lib/demospringboot/LICENCE.txt";
assert_contain "/usr/lib/demospringboot/demospringboot-bin.jar";
assert_contain "/etc/systemd/system/demospringboot.service";
assert_contain "/usr/local/share/man/man8/demospringboot.8";
assert_contain "/var/log/demospringboot";
###################
# RPM CLI TEST ZONE
###################
"$PREFIX/usr/bin/make-springboot-rpm" "$TESTROOT/democlispringboot" "$TEST_TEMP_DIR"
EXPECTED_TEST_PACKAGE="$TEST_TEMP_DIR/democlispringboot-0.0.1-SNAPSHOT.rpm";
if [ ! -f "$EXPECTED_TEST_PACKAGE" ]; then
echo "Error: can't found builded package: $EXPECTED_TEST_PACKAGE" >&2;
exit 1;
fi
################
# EXE TEST ZONE
################
if [ -x "$(command -v makensis)" ]; then
echo "Empty" > "$PREFIX/usr/lib/linux-springboot-packager/templates/WinSW-x64.exe"
"$PREFIX/usr/bin/make-springboot-exe" "$TESTROOT/demospringboot" "$TEST_TEMP_DIR"
fi
################
# CLEAN ZONE
################
if [ -d "$PREFIX/tmp" ]; then
rm -rf "$PREFIX/tmp";
fi
echo "Tests are ok";