forked from Shopify/kubeaudit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·35 lines (27 loc) · 841 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
35
#!/usr/bin/env bash
set -e
touch coverage.txt
for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
go build -o kubeaudit main.go
cp -r fixtures/ fixtures_temp
for f in fixtures_temp/*; do
./kubeaudit autofix -f $f 2>> /dev/null
done
for f in fixtures_temp/*; do
echo $f >> result_file
./kubeaudit all -f $f 2>> result_file
done
if (( $(grep -c 'level=error' result_file) > 0 )); then
echo ERROR: Regression Test Failed
sed -n '/^fixtures_temp/{ x; /level=error/p; d; }; /level=error/H; ${ x; /level=error/p; }' result_file
rm result_file
rm -r fixtures_temp
exit 1 # terminate and indicate error
fi
rm -r ./result_file ./fixtures_temp