diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rwxr-xr-x | contrib/ci/run | 3 | ||||
-rwxr-xr-x | src/tests/double_semicolon_test | 38 |
3 files changed, 42 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index f792ed6a6..17c5f26ce 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/contrib/ci/run b/contrib/ci/run index 1b230f584..f96476ff8 100755 --- a/contrib/ci/run +++ b/contrib/ci/run @@ -187,7 +187,8 @@ function build_debug() { # Extended glob pattern matching tests to run under Valgrind. # NOTE: The particular pattern below is inverted - declare -r valgrind_test_pattern="!(*.py|*/dlopen-tests|*/whitespace_test)" + declare -r valgrind_test_pattern="\ + !(*.py|*/dlopen-tests|*/whitespace_test|*/double_semicolon_test)" export CFLAGS="$DEBUG_CFLAGS" declare test_dir declare test_dir_distcheck diff --git a/src/tests/double_semicolon_test b/src/tests/double_semicolon_test new file mode 100755 index 000000000..bbc05fa22 --- /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 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 + } + " |