From 57a2f2a6f807dcdc46287f6d0fbecbc38ad7ff3f Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:52:10 +0100 Subject: [PATCH] xx-verify: skip non-binary Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- src/test-verify.bats | 47 ++++++++++++++++++++++++++++++++++++++++++++ src/xx-verify | 7 +++++++ 2 files changed, 54 insertions(+) diff --git a/src/test-verify.bats b/src/test-verify.bats index a9db217..d6da521 100755 --- a/src/test-verify.bats +++ b/src/test-verify.bats @@ -372,6 +372,53 @@ load 'assert' export TARGETPLATFORM=linux/amd64 run xx-verify /idontexist assert_failure +} + +@test "not-binary" { + export XX_VERIFY_FILE_CMD_OUTPUT="POSIX shell script, ASCII text executable" + export TARGETPLATFORM=linux/amd64 + run xx-verify /idontexist + assert_success + + export XX_VERIFY_FILE_CMD_OUTPUT="Bourne-Again shell script, ASCII text executable" + export TARGETPLATFORM=linux/amd64 + run xx-verify /idontexist + assert_success + + export XX_VERIFY_FILE_CMD_OUTPUT="Python script, ASCII text executable" + export TARGETPLATFORM=linux/amd64 + run xx-verify /idontexist + assert_success + + export XX_VERIFY_FILE_CMD_OUTPUT="C source, ASCII text" + export TARGETPLATFORM=linux/amd64 + run xx-verify /idontexist + assert_success + + export XX_VERIFY_FILE_CMD_OUTPUT="UTF-8 Unicode text" + export TARGETPLATFORM=linux/amd64 + run xx-verify /idontexist + assert_success + + export XX_VERIFY_FILE_CMD_OUTPUT="XML document text" + export TARGETPLATFORM=linux/amd64 + run xx-verify /idontexist + assert_success + + export XX_VERIFY_FILE_CMD_OUTPUT="Markdown document text" + export TARGETPLATFORM=linux/amd64 + run xx-verify /idontexist + assert_success + + export XX_VERIFY_FILE_CMD_OUTPUT="YAML document text" + export TARGETPLATFORM=linux/amd64 + run xx-verify /idontexist + assert_success + + export XX_VERIFY_FILE_CMD_OUTPUT="JSON data" + export TARGETPLATFORM=linux/amd64 + run xx-verify /idontexist + assert_success unset XX_VERIFY_FILE_CMD_OUTPUT unset TARGETPLATFORM diff --git a/src/xx-verify b/src/xx-verify index 8442d53..c1435a9 100755 --- a/src/xx-verify +++ b/src/xx-verify @@ -122,6 +122,13 @@ for f in "$@"; do ;; esac + case "$out" in + *"ASCII text"* | *"Unicode text"* | *"document text"* | *"JSON data"*) + echo "skipping verification of non-binary file ${f}: $out" + exit 0 + ;; + esac + if [ -z "$expOS" ]; then echo >&2 "unsupported target os ${TARGETOS}" exit 1