forked from bonsai/harakit
tests: bonsai/scrut.mk: add tests
This commit is contained in:
parent
0f2d357476
commit
acdbecf178
46
tests/bonsai/scrut.mk
Executable file
46
tests/bonsai/scrut.mk
Executable file
@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) 2024 DTB <trinity@trinity.moe>
|
||||
# SPDX-License-Identifier: FSFAP
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice and this
|
||||
# notice are preserved. This file is offered as-is, without any warranty.
|
||||
|
||||
.PRAGMA: command_comment
|
||||
|
||||
.PHONY: scrut_tests
|
||||
scrut_tests: scrut_help scrut_options
|
||||
|
||||
.PHONY: scrut_help
|
||||
scrut_help: $(BIN)/scrut
|
||||
! $(BIN)/scrut -h
|
||||
|
||||
.PHONY: scrut_options
|
||||
# scrut tests file attributes, but files of a certain attribute aren't
|
||||
# guaranteed to be present on a system. This test checks all of the files in
|
||||
# harakit and, if test(1p) says a file matches a certain attribute, then checks
|
||||
# scrut.
|
||||
# opts are space-delimited (for command splitting), sel is not
|
||||
scrut_options: $(BIN)/scrut
|
||||
set -e; \
|
||||
opts="b c d e f g k p r s u w x L S"; \
|
||||
sel=; \
|
||||
find . -name .git -prune -o -print \
|
||||
| while read -r f; do \
|
||||
for opt in $$opts; \
|
||||
do if ! printf "%s\n" $$sel | grep $$opt >/dev/null; then \
|
||||
if test -$$opt "$$f"; then \
|
||||
if ! $(BIN)/scrut -$$opt "$$f"; \
|
||||
then printf "[!!] scrut -%s failed on %s.\n" \
|
||||
$$opt "$$f"; \
|
||||
fi; \
|
||||
sel="$$sel$$opt"; \
|
||||
printf "[OK] Tested scrut -%s using %s\n" \
|
||||
$$opt "$$f"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done; \
|
||||
if printf "%s\n" "$$opts" | sed 's/ //g' | xargs test "$$sel" =; \
|
||||
then break; \
|
||||
fi; \
|
||||
done
|
Loading…
Reference in New Issue
Block a user