Hi,

a Makefile including bsd.regress.mk cannot reasonably set both
SUBDIR and REGRESS_TARGETS right now, or "make all" will first
run "make regress" in all subdirs, and then run "make all" in
all subdirs, because "all" depends on "regress", and both depend
on _SUBDIRUSE.  So all the SUBDIR tests will get run twice.

That's bad because if a test suite is growing organically -
which is a good thing! - the need to have both in the top level
directory arises naturally:  You first put some basic tests there,
and later realize that more refined tests for specific subsystems
would be worthwhile too, such that you then need SUBDIR as well.

A prominent example exhibiting the problem is:
  /usr/src/regress/usr.bin/ssh/Makefile

The following patch fixes the problem by avoiding the descent for
"regress" if we are going to descend for "all" later.
I have an OK from bluhm@ for it.

But before fiddling with /usr/share/mk/, i decided to be cautious
and show the patch here, such that you have a chance to speak up
if you see any potential problems.

Unless somebody raises any concerns, i'm going to commit.

Yours,
  Ingo

P.S.
clean and cleandir show the same problem as regress and all;
of course, it's less important for them, but why not fix them, too.


Index: bsd.subdir.mk
===================================================================
RCS file: /cvs/src/share/mk/bsd.subdir.mk,v
retrieving revision 1.21
diff -u -p -r1.21 bsd.subdir.mk
--- bsd.subdir.mk       8 Mar 2015 21:59:48 -0000       1.21
+++ bsd.subdir.mk       29 Sep 2016 11:37:40 -0000
@@ -76,11 +76,17 @@ realinstall: beforeinstall _SUBDIRUSE
 .endif
 
 
-.for t in all clean cleandir includes depend obj tags regress manlint
+.for t in all cleandir includes depend obj tags manlint
 .  if !target($t)
 $t: _SUBDIRUSE
 .  endif
 .endfor
+.if !target(regress) && empty(.TARGETS:Mall)
+regress: _SUBDIRUSE
+.endif
+.if !target(clean) && empty(.TARGETS:Mcleandir)
+clean: _SUBDIRUSE
+.endif
 
 .if !defined(BSD_OWN_MK)
 .  include <bsd.own.mk>

Reply via email to