diff options
author | Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com> | 2015-08-10 13:05:37 -0400 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-09-03 09:43:07 +0200 |
commit | cbff3fcdce5b0377a62fbe74f32e476efbf7ca9c (patch) | |
tree | f15296caeedd933c4df6d5290edadea937bf7eee | |
parent | 2b490bc947dbe0094417304840bd721417a162d9 (diff) | |
download | sssd-cbff3fcdce5b0377a62fbe74f32e476efbf7ca9c.tar.gz sssd-cbff3fcdce5b0377a62fbe74f32e476efbf7ca9c.tar.xz sssd-cbff3fcdce5b0377a62fbe74f32e476efbf7ca9c.zip |
TESTS: Add trailing whitespace test
Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com>
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Reviewed-by: Pavel Reichl <preichl@redhat.com>
-rw-r--r-- | Makefile.am | 6 | ||||
-rwxr-xr-x | src/tests/whitespace_test | 32 |
2 files changed, 37 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index ac6221f3c..a5c66fa1f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -284,7 +284,9 @@ TEST_EXTENSIONS = .sh TESTS = \ $(PYTHON_TESTS) \ $(non_interactive_cmocka_based_tests) \ - $(non_interactive_check_based_tests) + $(non_interactive_check_based_tests) \ + src/tests/whitespace_test \ + $(NULL) sssdlib_LTLIBRARIES = \ libsss_ldap.la \ @@ -367,6 +369,7 @@ dist_noinst_SCRIPTS = \ src/tests/pysss_murmur-test.py2.sh \ src/tests/pysss_murmur-test.py3.sh \ src/tests/python-test.py \ + src/tests/whitespace_test \ src/tests/krb5_proxy_check_test_data.conf \ $(NULL) @@ -1382,6 +1385,7 @@ endif ################# TESTS_ENVIRONMENT = LDB_MODULES_PATH=$(abs_top_builddir)/ldb_mod_test_dir \ SSS_TEST_DIR=$(TEST_DIR) \ + ABS_TOP_SRCDIR=$(abs_top_srcdir) \ $(AUX_TESTS_ENVIRONMENT) ldb_mod_test_dir: memberof.la diff --git a/src/tests/whitespace_test b/src/tests/whitespace_test new file mode 100755 index 000000000..ea2aecf60 --- /dev/null +++ b/src/tests/whitespace_test @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e -u -o pipefail + +# An AWK regex matching tracked file paths to be excluded from the search. +# Example: '.*\.po|README' +PATH_EXCLUDE_REGEX='.*\.po|.*\.patch|.*\.diff|\/debian\/.*' + +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 + +git grep -n -I '\s\+$' -- "$(git rev-parse --show-toplevel)" | + awk -- " + BEGIN { + found = 0 + } + ! /^($PATH_EXCLUDE_REGEX):/ { + if (!found) { + print \"Trailing whitespace found:\" + found = 1 + } + print + } + END { + exit found + } + " |