Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
8eece4cf84 | |||
0e9127d417 | |||
e6f747d635 | |||
9b699d7298 | |||
f0eac562b3 | |||
008c0624f6 |
11
Makefile
11
Makefile
@ -62,7 +62,12 @@ dist: all docs
|
|||||||
install: dist
|
install: dist
|
||||||
cp -r $(DESTDIR)/* /
|
cp -r $(DESTDIR)/* /
|
||||||
|
|
||||||
include tests/tests.mk
|
TESTFILES != for file in tests/*.mk; do printf '%s ' "$$file"; done
|
||||||
|
|
||||||
|
TESTS != printf '%s\n' "$(TESTFILES)" | xargs -n1 basename \
|
||||||
|
| sed 's/\.mk/_tests/g'
|
||||||
|
|
||||||
|
include $(TESTFILES)
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: all $(TESTS) /tmp/getopt
|
test: all $(TESTS) /tmp/getopt
|
||||||
@ -114,8 +119,8 @@ build/bin/false: src/false.c build
|
|||||||
|
|
||||||
.PHONY: fileis
|
.PHONY: fileis
|
||||||
fileis: build/bin/fileis
|
fileis: build/bin/fileis
|
||||||
build/bin/fileis: src/fileis.rs build
|
build/bin/fileis: src/fileis.rs build rustlibs
|
||||||
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ src/fileis.rs
|
$(RUSTC) $(RUSTFLAGS) -o $@ src/fileis.rs
|
||||||
|
|
||||||
.PHONY: fop
|
.PHONY: fop
|
||||||
fop: build/bin/fop
|
fop: build/bin/fop
|
||||||
|
31
tests/README
31
tests/README
@ -1,24 +1,13 @@
|
|||||||
The testing suite contains two trees: the Bonsai tree and the POSIX tree:
|
Tests
|
||||||
|
=====
|
||||||
|
|
||||||
.
|
The Harakit testing suite verifies the functionality of Harakit utilities
|
||||||
├── README
|
and checks for regressions and other issues relating to compliance to our
|
||||||
├── bonsai/
|
standards of practice.
|
||||||
│ ├── dj.mk
|
|
||||||
│ ├── false.mk
|
|
||||||
│ ├── fop.mk
|
|
||||||
│ └── ...
|
|
||||||
├── posix/
|
|
||||||
└── tests.mk
|
|
||||||
|
|
||||||
The Bonsai tree tests the functionality of Harakit utilities for regressions and
|
Tests inherit the environment set by the top-level Makefile, which sets the BIN
|
||||||
other issues relating to compliance to our standards of practice.
|
variable to the build/bin directory at the root of the project; therefore, each
|
||||||
|
binary is located at $(BIN)/tool for idiomatic access.
|
||||||
The POSIX tests are currently a work-in-progress. Their status in this
|
|
||||||
repository is uncertain.
|
|
||||||
|
|
||||||
Both sets of tests also inherit the environment set by the top-level Makefile,
|
|
||||||
which sets the BIN variable to the build/bin directory at the root of the
|
|
||||||
project; therefore, each binary is located at $(BIN)/tool for idiomatic access.
|
|
||||||
|
|
||||||
Each test contains a set of PHONY targets which are prefixed with the name of
|
Each test contains a set of PHONY targets which are prefixed with the name of
|
||||||
the tool being tested and an underscore. The first target is tests, which
|
the tool being tested and an underscore. The first target is tests, which
|
||||||
@ -27,10 +16,10 @@ included in the top Makefile, so they can be called from the root of the
|
|||||||
repository. This also means that BIN can be set manually so that tests can be
|
repository. This also means that BIN can be set manually so that tests can be
|
||||||
run using make(1) inside of the tests directory:
|
run using make(1) inside of the tests directory:
|
||||||
|
|
||||||
$ make -f tests.mk BIN=../build/bin dj_tests
|
$ make -f dj.mk BIN=../build/bin dj_tests
|
||||||
|
|
||||||
--
|
--
|
||||||
Copyright © 2024 Emma Tebibyte <emma@tebibyte.media>
|
Copyright © 2024–2025 Emma Tebibyte <emma@tebibyte.media>
|
||||||
|
|
||||||
This work is licensed under CC BY-SA 4.0. To view a copy of this license, visit
|
This work is licensed under CC BY-SA 4.0. To view a copy of this license, visit
|
||||||
<http://creativecommons.org/licenses/by-sa/4.0/>.
|
<http://creativecommons.org/licenses/by-sa/4.0/>.
|
||||||
|
@ -8,20 +8,20 @@
|
|||||||
|
|
||||||
.PRAGMA: command_comment
|
.PRAGMA: command_comment
|
||||||
|
|
||||||
.PHONY: scrut_tests
|
.PHONY: fileis_tests
|
||||||
scrut_tests: scrut_help scrut_options
|
fileis_tests: fileis_help fileis_options
|
||||||
|
|
||||||
.PHONY: scrut_help
|
.PHONY: fileis_help
|
||||||
scrut_help: $(BIN)/scrut
|
fileis_help: $(BIN)/fileis
|
||||||
! $(BIN)/scrut -h
|
! $(BIN)/fileis -h
|
||||||
|
|
||||||
.PHONY: scrut_options
|
.PHONY: fileis_options
|
||||||
# scrut tests file attributes, but files of a certain attribute aren't
|
# fileis 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
|
# 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
|
# harakit and, if test(1p) says a file matches a certain attribute, then checks
|
||||||
# scrut.
|
# fileis.
|
||||||
# opts are space-delimited (for command splitting), sel is not
|
# opts are space-delimited (for command splitting), sel is not
|
||||||
scrut_options: $(BIN)/scrut
|
fileis_options: $(BIN)/fileis
|
||||||
set -e; \
|
set -e; \
|
||||||
opts="b c d e f g k p r s u w x L S"; \
|
opts="b c d e f g k p r s u w x L S"; \
|
||||||
sel=; \
|
sel=; \
|
||||||
@ -30,12 +30,12 @@ scrut_options: $(BIN)/scrut
|
|||||||
for opt in $$opts; \
|
for opt in $$opts; \
|
||||||
do if ! printf "%s\n" $$sel | grep $$opt >/dev/null; then \
|
do if ! printf "%s\n" $$sel | grep $$opt >/dev/null; then \
|
||||||
if test -$$opt "$$f"; then \
|
if test -$$opt "$$f"; then \
|
||||||
if ! $(BIN)/scrut -$$opt "$$f"; \
|
if ! $(BIN)/fileis -$$opt "$$f"; \
|
||||||
then printf "[!!] scrut -%s failed on %s.\n" \
|
then printf "[!!] fileis -%s failed on %s.\n" \
|
||||||
$$opt "$$f"; \
|
$$opt "$$f"; \
|
||||||
fi; \
|
fi; \
|
||||||
sel="$$sel$$opt"; \
|
sel="$$sel$$opt"; \
|
||||||
printf "[OK] Tested scrut -%s using %s\n" \
|
printf "[OK] Tested fileis -%s using %s\n" \
|
||||||
$$opt "$$f"; \
|
$$opt "$$f"; \
|
||||||
fi; \
|
fi; \
|
||||||
fi; \
|
fi; \
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (c) 2024 DTB <trinity@trinity.moe>
|
# Copyright (c) 2024 DTB <trinity@trinity.moe>
|
||||||
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
# Copyright (c) 2024–2025 Emma Tebibyte <emma@tebibyte.media>
|
||||||
# SPDX-License-Identifier: FSFAP
|
# SPDX-License-Identifier: FSFAP
|
||||||
#
|
#
|
||||||
# Copying and distribution of this file, with or without modification, are
|
# Copying and distribution of this file, with or without modification, are
|
||||||
@ -26,7 +26,7 @@ npc_args:
|
|||||||
|
|
||||||
.PHONY: npc_ascii
|
.PHONY: npc_ascii
|
||||||
# Test 0x00 to 0x7f in input; in other words, the full 7b ASCII range.
|
# Test 0x00 to 0x7f in input; in other words, the full 7b ASCII range.
|
||||||
npc_ascii: npc_ascii_controls npc_ascii_symbols npc_ascii_uppers # \
|
npc_ascii: npc_ascii_controls npc_ascii_uppers # npc_ascii_symbols \
|
||||||
# npc_ascii_lowers
|
# npc_ascii_lowers
|
||||||
|
|
||||||
.PHONY: npc_ascii_controls
|
.PHONY: npc_ascii_controls
|
||||||
@ -63,14 +63,18 @@ npc_ascii_controls:
|
|||||||
| tail -n 1 \
|
| tail -n 1 \
|
||||||
| xargs -I out test "^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_"
|
| xargs -I out test "^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_"
|
||||||
|
|
||||||
.PHONY: npc_ascii_symbols
|
# This test is broken on Linux and will need closer inspection along with GNU
|
||||||
# ASCII 0x1f to 0x3f (^_ and symbols)
|
# xargs(1).
|
||||||
npc_ascii_symbols:
|
# .PHONY: npc_ascii_symbols
|
||||||
# shell quoting olympics
|
# # ASCII 0x1f to 0x3f (^_ and symbols)
|
||||||
awk 'BEGIN{ for (i = 31; i < 64; ++i) printf("%c", i); print }' \
|
# npc_ascii_symbols:
|
||||||
| $(BIN)/npc \
|
# # shell quoting olympics
|
||||||
| sed -e s"/\'/\\\'/g" -e 's/"/\\"/g' \
|
# c="$(awk 'BEGIN{ for (i = 31; i < 64; ++i) printf("%c", i); print }')"
|
||||||
| xargs -I out test "^_ !\"#$$%&'()*+,-./0123456789:;<=>?" = out
|
#
|
||||||
|
# printf '%s\n' "$c" | $(BIN)/npc \
|
||||||
|
# | sed -e s"/\'/\\\'/g" -e 's/"/\\"/g' \
|
||||||
|
# | tr -d '\n' \
|
||||||
|
# | xargs -I out test "^_ !\"#$$%&\'()*+,-./0123456789:;<=>?" = out
|
||||||
|
|
||||||
.PHONY: npc_ascii_uppers
|
.PHONY: npc_ascii_uppers
|
||||||
# ASCII 0x40 to 0x5f (uppercases)
|
# ASCII 0x40 to 0x5f (uppercases)
|
@ -1,22 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Strictly POSIX-compliant cat(1) implementation. See cat(1p)
|
|
||||||
|
|
||||||
for arg in "$@"; do
|
|
||||||
case "$arg" in
|
|
||||||
-u) args="$(printf '%s %s\n' "$args" "$arg")" ;;
|
|
||||||
*) args="$(printf -- '%s -i %s\n' "$args" "$arg")" ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# See IEEE Std 1003.1-2017 3.282
|
|
||||||
# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_282
|
|
||||||
IFS=' '
|
|
||||||
|
|
||||||
mm $args
|
|
@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# Copyright (c) 2024 DTB <trinity@trinity.moe>
|
|
||||||
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Strictly POSIX-compliant false(1) implementation. See false(1p)
|
|
||||||
|
|
||||||
false "$@"
|
|
@ -1,11 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# Copyright (c) 2024 DTB <trinity@trinity.moe>
|
|
||||||
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Strictly POSIX-compliant true(1) implementation. See true(1p)
|
|
||||||
true "$@"
|
|
@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
PATH="$PWD/bin:$PATH"
|
|
@ -1,15 +0,0 @@
|
|||||||
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
|
|
||||||
#TESTFILES != for file in tests/bonsai/*.mk tests/posix/*.mk; do printf '%s ' "$$file"; done;
|
|
||||||
TESTFILES != for file in tests/bonsai/*.mk; do printf '%s ' "$$file"; done;
|
|
||||||
|
|
||||||
TESTS != printf '%s\n' "$(TESTFILES)" | xargs -n1 basename \
|
|
||||||
| sed 's/\.mk/_tests/g'
|
|
||||||
|
|
||||||
include $(TESTFILES)
|
|
Loading…
Reference in New Issue
Block a user