forked from os-autoinst/os-autoinst-distri-opensuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_invalid_syntax
executable file
·38 lines (32 loc) · 1.23 KB
/
check_invalid_syntax
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
#!/bin/sh
exit_code=0
GIT_CMD="git --no-pager grep --break --color -n -P"
check_loadtest() {
CHECK_LOADTEST_RESULT=$(${GIT_CMD} "\sloadtest\s?\(?(?:\"|')?[\w\/]+\.pm(?:\"|'),?.*\)?")
if [ ! -z "$CHECK_LOADTEST_RESULT" ]; then
echo "${CHECK_LOADTEST_RESULT}"
echo "Invalid syntax found for loadtest call. '.pm' extensions are not allowed at test distribution level"
exit_code=$(($exit_code+1))
fi
echo "Finished checking loadtests"
}
check_versions(){
# Check for patterns that will be likely rejected by is_leap or is_sle calls
CHECK_IS_LEAP_RESULT=$(${GIT_CMD} "is_leap[\(\s](\"|')\d{2}(?!\.\d)\1")
if [ ! -z "$CHECK_IS_LEAP_RESULT" ]; then
echo "${CHECK_IS_LEAP_RESULT}"
echo "Invalid call for is_leap"
exit_code=$(($exit_code+1))
fi
CHECK_IS_SLE_RESULT=$(${GIT_CMD} "is_sle[\(\s](\"|')\d{2,}(?:\.\d\+)\1"+" --and -P "+"is_sle.*(['\"])[+].+\1[\)\s\;]")
if [ ! -z "$CHECK_IS_SLE_RESULT" ]; then
echo "${CHECK_IS_SLE_RESULT}"
echo "Invalid call for is_sle"
exit_code=$(($exit_code+1))
fi
echo "Finished checking for invalid version syntax"
}
check_versions
check_loadtest
echo "All checks finished: $exit_code."
exit $exit_code;