]> code.delx.au - gnu-emacs/blob - test/make-test-deps.emacs-lisp
Automatically detect whether .h file is C or C++
[gnu-emacs] / test / make-test-deps.emacs-lisp
1 ;; -*- emacs-lisp -*-
2
3 ;; Copyright (C) 2015-2016 Free Software Foundation, Inc.
4
5 ;; This file is part of GNU Emacs.
6
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.
11
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.
16
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/>.
19
20 ;;; Commentary:
21
22 ;; This file generates dependencies between test files and the files
23 ;; that they test.
24
25 ;; It has an .emacs-lisp extension because it makes the Makefile easier!
26
27 (require 'seq)
28
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)))))
36
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") ""))
45
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") ""))
54
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$")))
61
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))))))
70
71 (defun make-test-sans-suffix (files)
72 (mapcar
73 (lambda (file)
74 (substring file 0 -9))
75 files))
76
77 (defun make-test-de-stem (stem files)
78 (mapcar
79 (lambda (file)
80 (substring
81 file
82 (+ 1 (length stem))))
83 files))
84
85 (defun make-test-no-legacy (list)
86 (make-test-remove list "legacy/"))
87
88 (defun make-test-no-resources (list)
89 (make-test-remove list "-resources/"))
90
91 (defun make-test-no-test-dir (list)
92 (make-test-remove list "-tests/"))
93
94 (defun make-test-remove (list match)
95 (seq-remove
96 (lambda (file)
97 (string-match-p match file))
98 list))