diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2022-08-15 22:45:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-15 22:45:31 (GMT) |
commit | 5ff839680134437dbf4678f3d0c7b371d84f4964 (patch) | |
tree | 939d919c3903b42ed637542a4799fb3f4fa8b5fc /tests/unicode_lint.sh | |
parent | 416bc96faca629abcef42e56ecd2e20d26b79934 (diff) | |
parent | cfd6ab32522280079c2e6d3ea995f172b9ae0312 (diff) | |
download | lz4-1.9.4.zip lz4-1.9.4.tar.gz lz4-1.9.4.tar.bz2 |
stage v1.9.4
Diffstat (limited to 'tests/unicode_lint.sh')
-rw-r--r-- | tests/unicode_lint.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/unicode_lint.sh b/tests/unicode_lint.sh new file mode 100644 index 0000000..cd65d2d --- /dev/null +++ b/tests/unicode_lint.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# `unicode_lint.sh' determines whether source files under the ./lib/, ./tests/ and ./programs/ directories +# contain Unicode characters, and fails if any do. +# +# See https://github.com/lz4/lz4/issues/1018 + +echo "Ensure no unicode character is present in source files *.{c,h}" +pass=true + +# Scan ./lib/ for Unicode in source (*.c, *.h) files +echo "Scanning lib/" +result=$( + find ./lib/ -regex '.*\.\(c\|h\)$' -exec grep -P -n "[^\x00-\x7F]" {} \; -exec echo "{}: FAIL" \; +) +if [[ $result ]]; then + echo "$result" + pass=false +fi + +# Scan ./programs/ for Unicode in source (*.c, *.h) files +echo "Scanning programs/" +result=$( + find ./programs/ -regex '.*\.\(c\|h\)$' -exec grep -P -n "[^\x00-\x7F]" {} \; -exec echo "{}: FAIL" \; +) +if [[ $result ]]; then + echo "$result" + pass=false +fi + +# Scan ./tests/ for Unicode in source (*.c, *.h) files +echo "Scanning tests/" +result=$( + find ./tests/ -regex '.*\.\(c\|h\)$' -exec grep -P -n "[^\x00-\x7F]" {} \; -exec echo "{}: FAIL" \; +) +if [[ $result ]]; then + echo "$result" + pass=false +fi + +if [ "$pass" = true ]; then + echo "All tests successful: no unicode character detected" + echo "Result: PASS" + exit 0 +else + echo "Result: FAIL" + exit 1 +fi |