-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.sh
executable file
·34 lines (27 loc) · 914 Bytes
/
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
#!/bin/sh
commands_and_expected_outputs='
date +"%Z"#UTC
locale | awk -F= "/LC_COLLATE/{print \$2}" | tr -d \"#en_US.UTF-8
'
# Split by newline.
IFS="
"
for command_and_output in $commands_and_expected_outputs; do
# Split the command and expected output using the "#" separator.
command=$(echo "$command_and_output" | cut -d "#" -f 1)
expected_output=$(echo "$command_and_output" | cut -d "#" -f 2)
output=$(eval "docker run --rm -t "${CI_REGISTRY_IMAGE}:${TAG}" $command")
if [ $? -ne 0 ]; then
echo "Error: \"$command\" failed"
exit 1
fi
# Remove any trailing whitespace characters from the output.
output=$(echo "$output" | sed 's/[[:space:]]*$//')
if [ "$output" != "$expected_output" ]; then
echo "Error: Output for \"$command\" does not match expected output"
echo "Actual output: $output"
echo "Expected output: $expected_output"
exit 2
fi
done
exit 0