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 /src | |
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>
Diffstat (limited to 'src')
-rwxr-xr-x | src/tests/whitespace_test | 32 |
1 files changed, 32 insertions, 0 deletions
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 + } + " |