-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathrun-system-tests.sh
executable file
·51 lines (42 loc) · 1.34 KB
/
run-system-tests.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
echo "▶ Running system tests..."
if [[ "$(docker images -q codeclimate/codeclimate-eslint 2> /dev/null)" == "" ]]; then
echo "▶ Building image..."
make image
fi
SOURCE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
for d in system-tests/*/ ; do
echo ""
echo "▶ Running $d ..."
echo "${SOURCE}"/"${d}"
cd "${SOURCE}"/"${d}" || exit
output=$(docker run \
--interactive --tty --rm \
--env CODECLIMATE_CODE="$PWD" \
--volume "$PWD":/code \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume /tmp/cc:/tmp/cc \
codeclimate/codeclimate analyze --dev)
if [[ -f "${SOURCE}/${d}snapshot" ]]; then
count=$(cat "${SOURCE}"/"${d}"snapshot)
issues=$(echo ${output} | sed -E "s/.*Found ([0-9]+).*/\1/")
if [[ "$issues" -ne "$count" ]]; then
echo -e "FAIL It should have $count issues but found $issues";
exit 1
else
echo -e "PASS Found $issues issues"
fi
fi
if [[ -f "${SOURCE}/${d}error" ]]; then
expected_error=$(cat "${SOURCE}"/"${d}"error)
if [[ "$output" == *"$expected_error"* ]]; then
echo -e "PASS Expected error found"
else
echo -e "FAIL It should have errored with: $expected_error";
exit 1
fi
fi
if [[ "$?" -ne 0 ]]; then
break
fi
done