~nabijaczleweli/voreutils

4e62ce5c70c54c4b86c95f451c4041d9410a204b — наб 5 months ago 5a4de15
Fix tests, actually run them on BSD find
4 files changed, 49 insertions(+), 26 deletions(-)

M .builds/openbsd-latest.yml
M Makefile
M tests/sleep
M tests/tac/test
M .builds/openbsd-latest.yml => .builds/openbsd-latest.yml +2 -3
@@ 1,9 1,8 @@
image: openbsd/latest
packages:
  - gmake
  - bzip2
tasks:
  - build: |
      cd voreutils
      gmake CXX=c++ LTO=n
      gmake CXX=c++ LTO=n test
      gmake CXX=c++
      gmake CXX=c++ test

M Makefile => Makefile +2 -2
@@ 78,8 78,8 @@ clean:
	rm -rf $(OUTDIR) $(OBJDIR)

test : binaries
	CMDDIR=$(realpath $(CMDDIR))/ find "tests/" -mindepth 1 -maxdepth 1 -type f -print -execdir {} \; 3>$(OBJDIR)testpsko
	CMDDIR=$(realpath $(CMDDIR))/ find "tests/" -mindepth 2 -maxdepth 2 -type f -name test -print -execdir {} \; 3>>$(OBJDIR)testpsko
	CMDDIR=$(realpath $(CMDDIR))/ find "tests/" -mindepth 1 -maxdepth 1 -type f -print -execdir ./{} \; 3>$(OBJDIR)testpsko
	CMDDIR=$(realpath $(CMDDIR))/ find "tests/" -mindepth 2 -maxdepth 2 -type f -name test -print -execdir ./{} \; 3>>$(OBJDIR)testpsko
	@cat $(OBJDIR)testpsko >&2
	@! [ -s $(OBJDIR)testpsko ]


M tests/sleep => tests/sleep +10 -0
@@ 3,6 3,16 @@

sleep="${CMDDIR}sleep"

case "$(date +"%s.%N")" in
	*N)
		echo "sleep: skipping, date(1) doesn't support %N" >&2
		exit
		;;
	*)
		format="%s.%N"
		;;
esac

:                 ; p0="$(date +"%s.%N")"
"$sleep" 0.2      ; p1="$(date +"%s.%N")"
"$sleep" 0.1 .1   ; p2="$(date +"%s.%N")"

M tests/tac/test => tests/tac/test +35 -21
@@ 1,13 1,17 @@
#!/bin/sh
# SPDX-License-Identifier: 0BSD

# GNU coreutils ship their own regexes(!), which recognise \s but don't [[:space:]]
# Conversely, regcomp(3) universally recognises [[:space:]], but not always \s (glibc does, Berkeley libcs don't)
# For ease of testing (and regeneration), pat= is set to [[:space:]] if it's \s: if retesting against GNU tac or regenerating, comment out those lines

IFS="
"

tmpdir="$(mktemp -dt "tac.XXXXXXXXXX")/"
tac="${CMDDIR}tac"
# tac="tac"
data="$(realpath data)/"
data="$(readlink -f data)/"
files="$(for f in "$data"*; do [ -f "$f" ] && echo "${f##*/}"; done)"

mkdir "${tmpdir}singlef/"


@@ 26,10 30,12 @@ cd "${tmpdir}singlef/" && for f in $files; do
  "$tac" -r  "$f" > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  "$tac" -br "$f" > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    "$tac" -s   "$s" "$f" > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$s" "$f" > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$s" "$f" > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$s" "$f" > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
    pat="$s"
    [ "$pat" = '\s' ] && pat='[[:space:]]'
    "$tac" -s   "$pat" "$f" > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$pat" "$f" > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$pat" "$f" > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$pat" "$f" > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}singlef/" >&3 2>&1 && echo "Single-file ok"


@@ 41,10 47,12 @@ cd "${tmpdir}withnull/" && for f in $files; do
  "$tac" -r  /dev/null "$f" /dev/null > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  "$tac" -br /dev/null "$f" /dev/null > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    "$tac" -s   "$s" /dev/null "$f" /dev/null > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$s" /dev/null "$f" /dev/null > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$s" /dev/null "$f" /dev/null > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$s" /dev/null "$f" /dev/null > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
    pat="$s"
    [ "$pat" = '\s' ] && pat='[[:space:]]'
    "$tac" -s   "$pat" /dev/null "$f" /dev/null > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$pat" /dev/null "$f" /dev/null > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$pat" /dev/null "$f" /dev/null > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$pat" /dev/null "$f" /dev/null > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}withnull/" >&3 2>&1 && echo "Interposed null ok"


@@ 56,10 64,12 @@ cd "${tmpdir}with-/" && for f in $files; do
  printf "" | "$tac" -r  - "$f" - > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  printf "" | "$tac" -br - "$f" - > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    printf "" | "$tac" -s   "$s" - "$f" - > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    printf "" | "$tac" -bs  "$s" - "$f" - > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    printf "" | "$tac" -rs  "$s" - "$f" - > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    printf "" | "$tac" -brs "$s" - "$f" - > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
    pat="$s"
    [ "$pat" = '\s' ] && pat='[[:space:]]'
    printf "" | "$tac" -s   "$pat" - "$f" - > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    printf "" | "$tac" -bs  "$pat" - "$f" - > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    printf "" | "$tac" -rs  "$pat" - "$f" - > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    printf "" | "$tac" -brs "$pat" - "$f" - > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}with-/" >&3 2>&1 && echo "Interposed - ok"


@@ 71,10 81,12 @@ cd "${tmpdir}just-/" && for f in $files; do
  "$tac" -r  - < "$f" > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  "$tac" -br - < "$f" > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    "$tac" -s   "$s" - < "$f" > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$s" - < "$f" > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$s" - < "$f" > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$s" - < "$f" > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
    pat="$s"
    [ "$pat" = '\s' ] && pat='[[:space:]]'
    "$tac" -s   "$pat" - < "$f" > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$pat" - < "$f" > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$pat" - < "$f" > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$pat" - < "$f" > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}just-/" >&3 2>&1 && echo "stdin ok"


@@ 86,10 98,12 @@ cd "${tmpdir}nothing/" && for f in $files; do
  "$tac" -r  < "$f" > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  "$tac" -br < "$f" > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    "$tac" -s   "$s" < "$f" > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$s" < "$f" > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$s" < "$f" > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$s" < "$f" > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
    pat="$s"
    [ "$pat" = '\s' ] && pat='[[:space:]]'
    "$tac" -s   "$pat" < "$f" > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$pat" < "$f" > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$pat" < "$f" > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$pat" < "$f" > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}nothing/" >&3 2>&1 && echo "Default ok"