make-test-deps.emacs-lisp 2.6 KB

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