Merge branch 'master' into comment-cache
[emacs.git] / test / make-test-deps.emacs-lisp
blob609e927618696b423e3bf89d300c94c17230e39f
1 ;; -*- emacs-lisp -*-
3 ;; Copyright (C) 2015-2017 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software: you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
20 ;;; Commentary:
22 ;; This file generates dependencies between test files and the files
23 ;; that they test.
25 ;; It has an .emacs-lisp extension because it makes the Makefile easier!
27 (require 'seq)
29 (defun make-test-deps (src-dir)
30   (let ((src-dir (file-truename src-dir)))
31     (message
32      "%s"
33      (concat
34       (make-test-deps-lisp src-dir)
35       (make-test-deps-src src-dir)))))
37 (defun make-test-deps-lisp (src-dir)
38   (mapconcat
39    (lambda (file-without-suffix)
40      (format "./%s-tests.log: %s/../%s.el\n"
41              file-without-suffix
42              src-dir
43              file-without-suffix))
44    (make-test-test-files src-dir "lisp") ""))
46 (defun make-test-deps-src (src-dir)
47   (mapconcat
48    (lambda (file-without-suffix)
49      (format "./%s-tests.log: %s/../%s.c\n"
50              file-without-suffix
51              src-dir
52              file-without-suffix))
53    (make-test-test-files src-dir "src") ""))
55 (defun make-test-test-files (src-dir sub-src-dir)
56   (make-test-munge-files
57    src-dir
58    (directory-files-recursively
59     (concat src-dir "/"  sub-src-dir)
60     ".*-tests.el$")))
62 (defun make-test-munge-files (src-dir files)
63   (make-test-sans-suffix
64    (make-test-de-stem
65     src-dir
66     (make-test-no-legacy
67      (make-test-no-test-dir
68       (make-test-no-resources
69        files))))))
71 (defun make-test-sans-suffix (files)
72   (mapcar
73    (lambda (file)
74      (substring file 0 -9))
75    files))
77 (defun make-test-de-stem (stem files)
78   (mapcar
79    (lambda (file)
80      (substring
81       file
82       (+ 1 (length stem))))
83    files))
85 (defun make-test-no-legacy (list)
86   (make-test-remove list "legacy/"))
88 (defun make-test-no-resources (list)
89   (make-test-remove list "-resources/"))
91 (defun make-test-no-test-dir (list)
92   (make-test-remove list "-tests/"))
94 (defun make-test-remove (list match)
95   (seq-remove
96    (lambda (file)
97      (string-match-p match file))
98    list))