]> code.delx.au - gnu-emacs/commitdiff
Tests now support out-of-source-build.
authorPhillip Lord <phillip.lord@russet.org.uk>
Tue, 1 Dec 2015 23:23:12 +0000 (23:23 +0000)
committerPhillip Lord <phillip.lord@russet.org.uk>
Tue, 1 Dec 2015 23:23:12 +0000 (23:23 +0000)
 * tests/Makefile.in,test/make-test-deps.emacs-lisp: Remove assumptions
   about current working directory.

test/Makefile.in
test/make-test-deps.emacs-lisp

index b2360fb2847a754bc5765417c248f4f6de47f372..06a2fb9ce315a8d2c9fc563a7d24a44c7a0c3ceb 100644 (file)
@@ -87,7 +87,7 @@ WRITE_LOG = > $@ 2>&1 || { stat=ERROR; cat $@; }; echo $$stat: $@
 ## to change this; bug#17848 - if that gets done, this can be simplified).
 ##
 ## Beware: it approximates 'no-byte-compile', so watch out for false-positives!
-%.log: ${srcdir}/%.el
+%.log: %.el
        @if grep '^;.*no-byte-compile: t' $< > /dev/null; then \
          loadfile=$<; \
        else \
@@ -96,14 +96,17 @@ WRITE_LOG = > $@ 2>&1 || { stat=ERROR; cat $@; }; echo $$stat: $@
        fi; \
        echo Testing $$loadfile; \
        stat=OK ; \
+       mkdir --parents $(dir $@) ; \
        $(emacs) -l ert -l $$loadfile \
          -f ert-run-tests-batch-and-exit ${WRITE_LOG}
 
-ELFILES = $(shell find ${srcdir} -path "./manual" -prune -o \
+ELFILES = $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
                -path "*resources" -prune -o -name "*el" -print)
-ELCFILES = $(patsubst %.el,%.elc,${ELFILES})
-LOGFILES = $(patsubst %.el,%.log,${ELFILES})
-LOGSAVEFILES  = $(patsubst %.el,%.log~,${ELFILES})
+## .elc files may be in a different directory for out of source builds
+ELCFILES = $(patsubst %.el,%.elc, \
+               $(patsubst $(srcdir)%,.%,$(ELFILES)))
+LOGFILES = $(patsubst %.elc,%.log,${ELCFILES})
+LOGSAVEFILES  = $(patsubst %.elc,%.log~,${ELCFILES})
 TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=))
 
 ## If we have to interrupt a hanging test, preserve the log so we can
@@ -117,8 +120,8 @@ TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=))
 ## of use.
 define test_template
 $(1):
-       @test ! -f ${srcdir}/$(1).log || mv ${srcdir}/$(1).log ${srcdir}/$(1).log~
-       @${MAKE} ${srcdir}/$(1).log WRITE_LOG=
+       @test ! -f ./$(1).log || mv ./$(1).log ./$(1).log~
+       @${MAKE} ./$(1).log WRITE_LOG=
 
 $(notdir $(1)): $(1)
 endef
@@ -156,7 +159,7 @@ distclean: clean
 maintainer-clean: distclean bootstrap-clean
 
 make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp
-       $(EMACS) --batch -l make-test-deps.emacs-lisp \
-       --eval "(make-test-deps \"`pwd`\")" \
+       $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \
+       --eval "(make-test-deps \"$(srcdir)\")" \
        2> $@
 # Makefile ends here.
index 563b3bf6722ac14b7332f1623440d4dc4718b401..7831da31061afd012770a474693df16b59eb5c13 100644 (file)
 
 (require 'seq)
 
-(defun make-test-deps (directory)
-  (message
-   "%s"
-   (concat
-    (make-test-deps-lisp directory)
-    (make-test-deps-src directory))))
-
-(defun make-test-deps-lisp (directory)
+(defun make-test-deps (src-dir)
+  (let ((src-dir (file-truename src-dir)))
+    (message
+     "%s"
+     (concat
+      (make-test-deps-lisp src-dir)
+      (make-test-deps-src src-dir)))))
+
+(defun make-test-deps-lisp (src-dir)
   (mapconcat
-   (lambda (stem)
-     (format "%s-tests.log: ../%s.elc\n" stem stem))
-   (make-test-test-files directory "lisp") ""))
-
-(defun make-test-deps-src (directory)
+   (lambda (file-without-suffix)
+     (format "./%s-tests.log: %s/../%s.el\n"
+             file-without-suffix
+             src-dir
+             file-without-suffix))
+   (make-test-test-files src-dir "lisp") ""))
+
+(defun make-test-deps-src (src-dir)
   (mapconcat
-   (lambda (stem)
-     (format "%s-tests.log: ../%s.o\n" stem stem))
-   (make-test-test-files directory "src") ""))
-
-(defun make-test-test-files (stem dir)
+   (lambda (file-without-suffix)
+     (format "./%s-tests.log: %s/../%s.c\n"
+             file-without-suffix
+             src-dir
+             file-without-suffix))
+   (make-test-test-files src-dir "src") ""))
+
+(defun make-test-test-files (src-dir sub-src-dir)
   (make-test-munge-files
-   stem
-   (directory-files-recursively dir ".*-tests.el$")))
+   src-dir
+   (directory-files-recursively
+    (concat src-dir "/"  sub-src-dir)
+    ".*-tests.el$")))
 
-(defun make-test-munge-files (stem files)
+(defun make-test-munge-files (src-dir files)
   (make-test-sans-suffix
    (make-test-de-stem
-    stem
+    src-dir
     (make-test-no-legacy
      (make-test-no-test-dir
       (make-test-no-resources