-
Notifications
You must be signed in to change notification settings - Fork 20
/
qa-test
executable file
·37 lines (33 loc) · 942 Bytes
/
qa-test
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
#!/bin/bash
set -ex
test_shell()
{
mkdir -p .shellcheck
find . -path ./.git -prune -o -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
while IFS="" read -r file
do
# collect all warnings
shellcheck --format=checkstyle "$file" > .shellcheck/$(basename ${file}).log || true
# fail on >=error
shellcheck --severity error "$file"
done
}
# fails on error and ignores other levels
test_shell_error()
{
# Shellcheck
find . -path ./.git -prune -o -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
while IFS="" read -r file
do
# with recent shellcheck, "-S error" replaces this hack
# kept as this runs on machines running rudder-dev
shellcheck --format gcc "$file" | grep " error: " && exit 1 || true
done
}
if [ "$1" = "--shell" ]; then
test_shell
exit 0
else
# quick tests to be launched during merge
test_shell_error
fi