Hi,

Regress prints FAILED in the middle of the make output, this is
hard to watch.  tb@ asked me to print a PASSED at the end.  As the
make processes cannot hold state over several targets or directories,
I create a regress log.  It is placed in the top directory where
you invoke make regress.  All failures are logged there.  if there
are none, PASSED is printed as final output.

ok?

bluhm

Index: share/man/man5/bsd.regress.mk.5
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/share/man/man5/bsd.regress.mk.5,v
retrieving revision 1.19
diff -u -p -r1.19 bsd.regress.mk.5
--- share/man/man5/bsd.regress.mk.5     14 May 2019 16:43:26 -0000      1.19
+++ share/man/man5/bsd.regress.mk.5     14 May 2019 18:53:39 -0000
@@ -79,7 +79,10 @@ target will abort as soon as a test fail
 Points to the fully-qualified path of a file to which regression
 results are appended.
 Defaults to
-.Pa /dev/null .
+.Pa regress.log
+in the current object directory.
+It is cleared at the beginning of each run and checked for failures
+afterwards.
 .It Ev REGRESS_ROOT_TARGETS
 Targets for which root access is required to run the test.
 The
Index: share/mk/bsd.regress.mk
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/share/mk/bsd.regress.mk,v
retrieving revision 1.18
diff -u -p -r1.18 bsd.regress.mk
--- share/mk/bsd.regress.mk     14 May 2019 16:43:26 -0000      1.18
+++ share/mk/bsd.regress.mk     14 May 2019 18:51:48 -0000
@@ -17,15 +17,18 @@ NOPROG=
 .MAIN: all
 all: regress

-# XXX - Need full path to REGRESS_LOG, otherwise there will be much pain.
-REGRESS_LOG?=/dev/null
+.if ! defined(REGRESS_LOG)
+REGRESS_LOG=           ${.OBJDIR}/regress.log
+_REGRESS_CLEANFILES=   ${.OBJDIR}/regress.log
+.endif
+CLEANFILES+=           ${.OBJDIR}/regress.log
+
 REGRESS_SKIP_TARGETS?=
 REGRESS_SKIP_SLOW?=no
 REGRESS_FAIL_EARLY?=no

-_REGRESS_NAME=${.CURDIR:S/${BSDSRCDIR}\/regress\///}
-_REGRESS_TMP?=/dev/null
-_REGRESS_OUT= | tee -a ${REGRESS_LOG} ${_REGRESS_TMP} 2>&1 > /dev/null
+_REGRESS_NAME=         ${.CURDIR:S,${BSDSRCDIR}/regress/,,}
+_REGRESS_OUT=          >>${REGRESS_LOG}

 .if defined(PROG) && !empty(PROG)
 run-regress-${PROG}: ${PROG}
@@ -50,10 +53,10 @@ _REGRESS_IGNORE_FAIL=       -
 .endif

 .if defined(REGRESS_ROOT_TARGETS)
-_ROOTUSER!=id -g
+_REGRESS_ROOTUSER!=    id -g
 SUDO?=
-.  if (${_ROOTUSER} != 0) && empty(SUDO)
-REGRESS_SKIP_TARGETS+=${REGRESS_ROOT_TARGETS}
+.  if (${_REGRESS_ROOTUSER} != 0) && empty(SUDO)
+REGRESS_SKIP_TARGETS+= ${REGRESS_ROOT_TARGETS}
 .  endif
 .endif

@@ -79,11 +82,11 @@ ${REGRESS_TARGETS}: ${REGRESS_SETUP}
 CLEANFILES+=${REGRESS_SETUP_ONCE:S/^/stamp-/}
 ${REGRESS_TARGETS}: ${REGRESS_SETUP_ONCE:S/^/stamp-/}
 ${REGRESS_SETUP_ONCE:S/^/stamp-/}: .SILENT
-       ${MAKE} -C ${.CURDIR} ${@:S/^stamp-//}
+       ${MAKE} -C ${.CURDIR} REGRESS_LOG=${REGRESS_LOG} ${@:S/^stamp-//}
        date >$@
 REGRESS_CLEANUP+=${REGRESS_SETUP_ONCE:S/^/cleanup-stamp-/}
 ${REGRESS_SETUP_ONCE:S/^/cleanup-stamp-/}: .SILENT
-       rm -f ${@:S/^cleanup-//}
+       rm -f -- ${@:S/^cleanup-//}
 .endif

 regress: .SILENT
@@ -94,23 +97,24 @@ regress: .SILENT
        echo =========================================================
        exit 1
 .endif
-.if !empty(REGRESS_SETUP_ONCE)
-       rm -f ${REGRESS_SETUP_ONCE:S/^/stamp-/}
-.endif
+       rm -f -- ${_REGRESS_CLEANFILES} ${REGRESS_SETUP_ONCE:S/^/stamp-/}
 .for RT in ${REGRESS_TARGETS} ${REGRESS_CLEANUP}
 .  if ${REGRESS_SKIP_TARGETS:M${RT}}
-       @echo -n "SKIP " ${_REGRESS_OUT}
-       @echo SKIPPED
+       echo 'SKIP ${_REGRESS_NAME} ${RT}' ${_REGRESS_OUT}
+       echo SKIPPED
 .  else
-       ${_REGRESS_IGNORE_FAIL} if ${MAKE} -C ${.CURDIR} ${RT}; then \
-           echo -n "SUCCESS " ${_REGRESS_OUT} ; \
+       ${_REGRESS_IGNORE_FAIL} \
+       if ${MAKE} -C ${.CURDIR} REGRESS_LOG=${REGRESS_LOG} ${RT}; then \
+           echo 'PASS ${_REGRESS_NAME} ${RT}' ${_REGRESS_OUT}; \
        else \
-           echo -n "FAIL " ${_REGRESS_OUT} ; \
-           echo FAILED ; \
+           echo 'FAIL ${_REGRESS_NAME} ${RT}' ${_REGRESS_OUT}; \
+           echo FAILED; \
            false; \
        fi
 .  endif
-       @echo ${_REGRESS_NAME}/${RT:S/^run-regress-//} ${_REGRESS_OUT}
 .endfor
+       if ! grep '^FAIL' ${REGRESS_LOG}; then \
+           echo PASSED; \
+       fi

 .PHONY: regress
Index: share/mk/bsd.subdir.mk
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/share/mk/bsd.subdir.mk,v
retrieving revision 1.22
diff -u -p -r1.22 bsd.subdir.mk
--- share/mk/bsd.subdir.mk      8 Oct 2016 09:43:46 -0000       1.22
+++ share/mk/bsd.subdir.mk      14 May 2019 18:51:48 -0000
@@ -9,8 +9,15 @@
 # Make sure this is defined
 SKIPDIR?=

+.if ! defined(REGRESS_LOG)
+MAKE_FLAGS+=           REGRESS_LOG=${.OBJDIR}/regress.log
+.endif
+
 _SUBDIRUSE: .USE
 .if defined(SUBDIR)
+.if ! defined(REGRESS_LOG)
+       @rm -f -- ${.OBJDIR}/regress.log
+.endif
        @for entry in ${SUBDIR}; do \
                set -e; if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
                        _newdir_="$${entry}.${MACHINE}"; \
@@ -48,6 +55,9 @@ _SUBDIRUSE: .USE
        done

 ${SUBDIR}::
+.if ! defined(REGRESS_LOG)
+       @rm -f -- ${.OBJDIR}/regress.log
+.endif
        @set -e; if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \
                _newdir_=${.TARGET}.${MACHINE}; \
        else \

Reply via email to