From 3bda37e85e811e8ef3fc378912d5d5fa284db6bd Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 17 Sep 2016 21:12:36 +0200 Subject: [PATCH 2/4] TESTS: Add simple test for double semicolon --- Makefile.am | 2 ++ src/tests/double_semicolon_test | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 src/tests/double_semicolon_test diff --git a/Makefile.am b/Makefile.am index f89af5a9d6d26c732574aa3651de8c175f538b28..6a06bbbd9954d7e7d84a2d8d733b8d15c1f3f61f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -321,6 +321,7 @@ TESTS = \ $(non_interactive_cmocka_based_tests) \ $(non_interactive_check_based_tests) \ src/tests/whitespace_test \ + src/tests/double_semicolon_test \ $(NULL) sssdlib_LTLIBRARIES = \ @@ -410,6 +411,7 @@ dist_noinst_SCRIPTS = \ src/tests/pysss_murmur-test.py3.sh \ src/tests/python-test.py \ src/tests/whitespace_test \ + src/tests/double_semicolon_test \ src/tests/krb5_proxy_check_test_data.conf \ $(NULL) diff --git a/src/tests/double_semicolon_test b/src/tests/double_semicolon_test new file mode 100755 index 0000000000000000000000000000000000000000..3e28307ea597aa77d8ab6acd01edd5257dce432e --- /dev/null +++ b/src/tests/double_semicolon_test @@ -0,0 +1,38 @@ +#!/bin/bash + +set -e -u -o pipefail + +# An AWK regex matching tracked file paths to be included for the search. +# Example: '.*\.po|README' +PATH_INCLUDE_REGEX='.*\.c|.*\.h' + +export GIT_DIR="$ABS_TOP_SRCDIR/.git" +export GIT_WORK_TREE="$ABS_TOP_SRCDIR" + +if [ ! -d "$GIT_DIR" ]; then + echo "Git repository is required for this test!" 1>&2 + exit 77 +fi + +{ + # Look for lines with with double semicolon at the end of line + # in all files tracked by Git + git grep -n -I ';\s*;$' -- "$(git rev-parse --show-toplevel)" || + # Don't fail if no such lines were found anywhere + [[ $? == 1 ]] +} | + awk -- " + BEGIN { + found = 0 + } + /^($PATH_INCLUDE_REGEX):/ { + if (!found) { + print \"Double semicolon found:\" + found = 1 + } + print + } + END { + exit found + } + " -- 2.9.3