12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #!/bin/bash
- #shellcheck disable=SC1090,SC2164
-
- . "$(sfpath)" || exit 3
-
- shellfu import pretty
-
- usage() {
- mkusage "$@" "[options] PATH" \
- -- \
- "Discover all JATS tests under directory PATH." \
- -o \
- "-f FMT Print test name in format FMT. 'jats' or 'path'."
- }
-
- discover() {
- #
- # Find tests under dirs ${FindDirs[@]}
- #
- local SuiteDir # suite root dir
- local TRPath # relative path to test directory within $SuiteDir
- local SuiteId # suite's jats: id
- jattool sfind -f path "${FindDirs[@]}" \
- | while read -r SuiteDir; do
- SuiteId=$(jattool sfind "$SuiteDir")
- debug -v SuiteDir SuiteId
- pushd "$SuiteDir">/dev/null
- find . -type f -name test -printf '%P\n' \
- | sed 's:/test::' \
- | while read -r TRPath; do
- case $Fmt in
- path) echo "$SuiteDir/$TRPath" ;;
- jats) echo "$SuiteId/$TRPath" ;;
- esac
- debug -v TRPath
- done
- popd >/dev/null
- done
- }
-
- main() {
- local FindDirs=()
- local Fmt=path
- while true; do case $1 in
- -f) Fmt=$2; shift 2 || usage -w "missing FMT" ;;
- -*) usage -w "unknown argument: $1" ;;
- *) break ;;
- esac done
- FindDirs=("$@")
- case $Fmt in
- jats|path) : ;;
- *) usage -w "unknown FMT: $Fmt" ;;
- esac
- debug -v FindDirs Fmt
- discover
- }
-
- main "$@"
|