X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Ftests.git;a=blobdiff_plain;f=devops-stages%2Fstage-test.sh;fp=devops-stages%2Fstage-test.sh;h=00c8981e7894817bced81374aa1e19c5ab7e51da;hp=abc03e25ac928820093aa698cd250c0dcff2e910;hb=f4ebaa88025189ede4f073ab8a1f27c95efff867;hpb=d90c14aa761a796cf74563812fb5a01f3b145ee9 diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh index abc03e2..00c8981 100755 --- a/devops-stages/stage-test.sh +++ b/devops-stages/stage-test.sh @@ -11,14 +11,72 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. + # python3 -m rflint testsuites + +check_tabs () { + folder="$1" + tabs="y" + ! grep -r " " ${folder} && tabs="" + [ -n "${tabs}" ] && \ + echo "There are tabs in ${folder}" && \ + echo "Please replace by spaces" && \ + exit 1 +} + +check_two_spaces () { + folder="$1" + two_spaces="y" + ! grep -r "[^ ] [^ ]" ${folder} && two_spaces="" + [ -n "${two_spaces}" ] && \ + echo "Some files in ${folder} are using two spaces to separate params" && \ + echo "Use this command to change it:" && \ + echo " sed -i 's/\([^ ]\) \([^ ]\)/\\\1 \\\2/g' " && \ + exit 1 +} + +check_four_spaces () { + folder="$1" + four_spaces="y" + ! grep -r "[^# \.] " ${folder} && four_spaces="" + [ -n "${four_spaces}" ] && \ + echo "Some files in ${folder} are using four spaces or more to separate params" && \ + echo "You can try this command to change it:" && \ + echo " sed -i 's/\([^# \.]\) */\\\1 /g' " && \ + exit 1 +} + +check_crlf_terminators () { + folder="$1" + crlf_terminators="y" + ! (find ${folder} -not -type d -exec file "{}" ";" | grep CRLF) && crlf_terminators="" + [ -n "${crlf_terminators}" ] && \ + echo "Some files in ${folder} have CRLF at the end of some lines" && \ + echo "Use this command to change it:" && \ + echo " dos2unix " && \ + exit 1 +} + echo "Checking tabs in robot files. No tabs should be present" -tabs_in_testsuite="y" -tabs_in_lib="y" -! grep -ri " " robot-systest/testsuite && tabs_in_testsuite="" -! grep -ri " " robot-systest/lib && tabs_in_lib="" -[ -n "${tabs_in_testsuite}" ] && echo "There are tabs in robot-systest/testsuite" && exit 1 -[ -n "${tabs_in_lib}" ] && echo "There are tabs in robot-systest/lib" && exit 1 -echo "No tabs are present in robot files" +check_tabs robot-systest/testsuite +check_tabs robot-systest/lib +echo "No tabs are present in robot files. Correct!" + +echo "Checking param separation in robot files. Three spaces is the recommendation, instead of two" +check_two_spaces robot-systest/testsuite +check_two_spaces robot-systest/lib +echo "No presence of two spaces to separate params in robot files. Correct!" + +echo "Checking param separation in robot files. Three spaces is the recommendation, instead of four or more" +check_four_spaces robot-systest/testsuite +check_four_spaces robot-systest/lib +echo "Only three spaces must be used between params in robot files. Correct!" + +echo "Checking CRLF terminators in robot files. No CRLF should be found" +check_crlf_terminators robot-systest/testsuite +check_crlf_terminators robot-systest/lib +echo "No presence of CRLF terminators in robot files. Correct!" + +echo "SUCCESS" exit 0