>From 797c443b594c6a606ffa1aa69efdf6a2090d8b91 Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Mon, 10 Aug 2015 13:05:37 -0400 Subject: [PATCH 2/2] TESTS: Add trailing whitespace test Signed-off-by: Lukas Slebodnik --- Makefile.am | 6 +++++- src/tests/whitespace_test | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100755 src/tests/whitespace_test diff --git a/Makefile.am b/Makefile.am index ac6221f3ca0b414bd4eeebfe4c66640e48b0da8b..a5c66fa1f610700cc4c4b0d30a2e4d466682f18d 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 0000000000000000000000000000000000000000..ea2aecf601068463ce7c9c7fcc20776d3f38204b --- /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 + } + " -- 2.5.0