From 594ec829e372558ef5617bd508149468d9432acd Mon Sep 17 00:00:00 2001 From: Nate <37554478+servusdei2018@users.noreply.github.com> Date: Sun, 8 Aug 2021 00:34:07 -0400 Subject: tests(unicode_lint.sh): create: lint source files in ./lib/ and ./programs/ for Unicode --- tests/unicode_lint.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/unicode_lint.sh diff --git a/tests/unicode_lint.sh b/tests/unicode_lint.sh new file mode 100644 index 0000000..08f8381 --- /dev/null +++ b/tests/unicode_lint.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# `unicode_lint.sh' determines whether source files under the ./lib/ and ./programs/ directories +# contain Unicode characters, and fails if any do. +# +# See https://github.com/lz4/lz4/issues/1018 + +pass=true + +# Scan ./lib/ for Unicode in source (*.c, *.h) files +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 +result=$( + find ./programs/ -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." + echo "Result: PASS" + exit 0 +else + echo "Result: FAIL" + exit 1 +fi -- cgit v0.12