]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Put always-failing programs first in PATH, so tests cannot mistakenly run installed...
authorJim Meyering <meyering@redhat.com>
Sat, 20 Oct 2007 12:41:50 +0000 (14:41 +0200)
committerJim Meyering <meyering@redhat.com>
Sun, 21 Oct 2007 12:01:15 +0000 (14:01 +0200)
* Makefile.maint (my-distcheck): Set up a bogus bin/ dir, to be used
for "make check".

Signed-off-by: Jim Meyering <meyering@redhat.com>
ChangeLog
Makefile.maint

index cf4a0add9ef0e735f5a5731b10c53cc5faca6b34..ab0562967f86df5ec30419886c641086097d9032 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2007-10-20  Jim Meyering  <meyering@redhat.com>
 
+       Put always-failing programs first in PATH, so tests cannot mistakenly
+       run installed versions.
+       * Makefile.maint (my-distcheck): Set up a bogus bin/ dir, to be used
+       for "make check".
+
        * doc/coreutils.texi (tee invocation): Fix typo.  Add a little.
        Add a cross-reference to bashref's Process Substitution node.
 
index 65e944dd13acd2f7ec0080441e40edfd78e2b4f9..ba39dec1b0c4ec91c6343a7518acb2ffee235d58 100644 (file)
@@ -562,13 +562,23 @@ null_AM_MAKEFLAGS = \
   AUTOHEADER=false \
   MAKEINFO=false
 
+built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
+
 warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
+bin=bin-$$$$
 
 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
 # Also, check for shadowing problems with -Wshadow, and for pointer
 # arithmetic problems with -Wpointer-arith.
 # These CFLAGS are pretty strict.  If you build this target, you probably
 # have to have a recent version of gcc and glibc headers.
+# The for-loop below ensures that there is a bin/ directory full of all
+# of the programs under test (except the few that are required for basic
+# Makefile rules), all symlinked to the just-built "false" program.
+# This is to ensure that if ever a test neglects to make PATH include
+# the build srcdir, these always-failing programs will run.
+# Otherwise, it is too easy to test the wrong programs.
+# Note that "false" itself is a symlink to true, so it too will malfunction.
 TMPDIR ?= /tmp
 t=$(TMPDIR)/$(PACKAGE)/test
 my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
@@ -580,7 +590,16 @@ my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
          && $(MAKE) CFLAGS='$(warn_cflags)'            \
              AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)'       \
          && $(MAKE) dvi                                \
-         && $(MAKE) check                              \
+         && mkdir $(bin)                               \
+         && for i in $(built_programs); do             \
+              case $$i in                              \
+                rm|expr|basename|echo|sort|ls|tr);;    \
+                *) ln -s ../src/false $(bin)/$$i;;     \
+              esac;                                    \
+            done                                       \
+         && ln -sf ../src/true $(bin)/false            \
+         && PATH=`pwd`/$(bin):$$PATH $(MAKE) check     \
+         && rm -rf $(bin)                              \
          && $(MAKE) distclean
        (cd $(t) && mv $(distdir) $(distdir).old        \
          && $(AMTAR) -zxf - ) < $(distdir).tar.gz