Skip to content

Commit

Permalink
xx-verify: skip non-binary
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Dec 11, 2024
1 parent 88f4f36 commit 57a2f2a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/test-verify.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/xx-verify
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 57a2f2a

Please sign in to comment.