From 3b387d81e63893ed3fe3b45e3721fbcfb1c5dde0 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 19 Oct 2022 10:29:05 -0400 Subject: tests: Split test cases into separate files --- docs/BUILDING.md | 15 ++++++++------- docs/HACKING.md | 20 ++++++++++++++------ docs/USAGE.md | 14 +++++++------- 3 files changed, 29 insertions(+), 20 deletions(-) (limited to 'docs') diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 932845b..5219160 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -107,27 +107,28 @@ Testing $ make check -Most of the testsuite is implemented in the file [`tests.sh`](/tests.sh). -This script contains hundreds of separate test cases. -Most of them are *snapshot tests* which compare `bfs`'s output to a known-good copy saved under [`tests`](/tests). +The test harness is implemented in the file [`tests/tests.sh`](/tests/tests.sh). +Individual test cases are found in `tests/*/*.sh`. +Most of them are *snapshot tests* which compare `bfs`'s output to a known-good copy saved under the matching `tests/*/*.out`. You can pass the name of a particular test case (or a few) to run just those tests. For example: - $ ./tests/tests.sh test_basic + $ ./tests/tests.sh posix/basic If you need to update the reference snapshot, pass `--update`. It can be handy to generate the snapshot with a different `find` implementation to ensure the output is correct, for example: - $ ./tests/tests.sh test_basic --bfs=find --update + $ ./tests/tests.sh posix/basic --bfs=find --update But keep in mind, other `find` implementations may not be correct. To my knowledge, no other implementation passes even the POSIX-compatible subset of the tests: $ ./tests/tests.sh --bfs=find --posix ... - tests passed: 89 - tests failed: 5 + tests passed: 90 + tests skipped: 3 + tests failed: 6 Run diff --git a/docs/HACKING.md b/docs/HACKING.md index 08ddac2..c9bbe14 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -30,18 +30,26 @@ Tests `bfs` includes an extensive test suite. See the [build documentation](BUILDING.md#testing) for details on running the tests. +Test cases are grouped by the standard or `find` implementation that supports the tested feature(s): + +| Group | Description | +|---------------------------------|---------------------------------------| +| [`tests/posix`](/tests/posix) | POSIX compatibility tests | +| [`tests/bsd`](/tests/bsd) | BSD `find` features | +| [`tests/gnu`](/tests/gnu) | GNU `find` features | +| [`tests/common`](/tests/common) | Features common to BSD and GNU `find` | +| [`tests/bfs`](/tests/bfs) | `bfs`-specific tests | + Both new features and bug fixes should have associated tests. -To add a test, create a new function in `tests.sh` called `test_`. +To add a test, create a new `*.sh` file in the appropriate group. Snapshot tests use the `bfs_diff` function to automatically compare the generated and expected outputs. For example, ```bash -function test_something() { - bfs_diff basic -name something -} +# posix/something.sh +bfs_diff basic -name something ``` `basic` is one of the directory trees generated for test cases; others include `links`, `loops`, `deep`, and `rainbow`. -Run `./tests/tests.sh test_something --update` to generate the reference snapshot (and don't forget to `git add` it). -Finally, add the test case to one of the arrays `posix_tests`, `bsd_tests`, `gnu_tests`, or `bfs_tests`, depending on which `find` implementations it should be compatible with. +Run `./tests/tests.sh posix/something --update` to generate the reference snapshot (and don't forget to `git add` it). diff --git a/docs/USAGE.md b/docs/USAGE.md index e2cff44..4f5db98 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -78,17 +78,17 @@ $ bfs -name '*.md' -and -name '*ING'` There are other operators like `-or`: ```console -$ bfs -name '*.md' -or -name '*.sh' +$ bfs -name '*.md' -or -name 'bfs.*' ./README.md -./tests/find-color.sh -./tests/ls-color.sh -./tests/remove-sibling.sh -./tests/sort-args.sh -./tests/tests.sh +./completions/bfs.bash +./completions/bfs.fish +./completions/bfs.zsh +./docs/BUILDING.md ./docs/CHANGELOG.md ./docs/HACKING.md -./docs/BUILDING.md ./docs/USAGE.md +./docs/bfs.1 +./src/bfs.h ``` and `-not`: -- cgit v1.2.3