(scheme-in-list): Add a fallback to create an error tag.
[cedet.git] / tests / cit-checkenv.el
blob32a28bc1bbd6e74579b49ac659396896a2a867bf
1 ;;; cit-checkenv.el --- Check this computer's environment for needed tools.
2 ;;
3 ;; Copyright (C) 2014 Eric Ludlam
4 ;;
5 ;; Author: Eric Ludlam <zappo@ballista>
6 ;;
7 ;; This program is free software; you can redistribute it and/or
8 ;; modify it under the terms of the GNU General Public License as
9 ;; published by the Free Software Foundation, either version 3 of the
10 ;; License, or (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see http://www.gnu.org/licenses/.
20 ;;; Commentary:
22 ;; Lots of build tools are needed to run the CEDET Integration tests.
23 ;; This command will summarize the requirements.
25 ;;; Code:
27 (require 'eieio)
29 (require 'cedet-global)
30 (require 'cedet-idutils)
31 (require 'cedet-cscope)
32 (require 'cedet-java)
34 (defclass cit-checkenv-test (eieio-named)
35 ((testgroup :initarg :testgroup
36 :initform nil)
37 (test :initarg :test
38 :documentation
39 "A function, or a string representing a program to run.")
40 (result :initarg :result
41 :documentation
42 "The expected result.
43 If :test is a function then this is the expected output, compare w/ eq.
44 If :test is a string, then this is a version string to look for.")
45 (required :initarg :required
46 :initform t)
48 "A class representing a thing to check.")
50 (defmethod cit-checkenv-dotest ((test cit-checkenv-test) testgroup)
51 "Execute the TEST."
52 (when (let ((tg (oref test testgroup)))
53 (or (not testgroup) (not tg)
54 (if (stringp tg)
55 (string= testgroup tg)
56 (member testgroup tg))))
58 (let ((result nil))
59 (cond ((functionp (oref test test))
60 ;; Run SYMBOL
61 (let ((found (funcall (oref test test)))
62 (expect (oref test result)))
63 (if (eq found expect)
64 (cit-checkenv-ok test)
65 (cit-checkenv-error test "Test failed: Found %s, expected %s"
66 found expect))))
68 ((and (stringp (oref test test)) (not (slot-boundp test 'result)))
69 ;; Just check it is on the exec path.
70 (if (locate-file (oref test test) exec-path)
71 (cit-checkenv-ok test)
72 (cit-checkenv-error test "%s not found on exec-path."
73 (oref test test)))
76 (error "Unknown thing to check: %S" (oref test test))))
77 )))
79 (defmethod cit-checkenv-ok ((this cit-checkenv-test))
80 "Note that test THIS is OK."
81 (message "OK: %S" (oref this :object-name)))
83 (defmethod cit-checkenv-error ((this cit-checkenv-test) formatmsg &rest args)
84 "Issue an error (ie - test failed) for test THIS."
85 (let* ((req (oref this required))
86 (msg (concat
87 (if req "Error" "Warning")
88 (format " (%s): " (oref this :object-name))
89 (apply 'format formatmsg args))))
90 (if req
91 (error msg)
92 (message msg))))
94 (defvar cit-checkenv-checks
95 (list
96 (cit-checkenv-test "global"
97 :testgroup '("Make" "Automake" "globalref")
98 :test (lambda () (cedet-gnu-global-version-check t))
99 :result t)
100 (cit-checkenv-test "idutils"
101 :testgroup '("Make" "Automake")
102 :test (lambda () (cedet-idutils-version-check t))
103 :result t
104 :required nil)
105 (cit-checkenv-test "cscope"
106 :testgroup '("Make" "Automake")
107 :test (lambda () (cedet-cscope-version-check t))
108 :result t)
109 ;; Make tooling
110 (cit-checkenv-test "make" :testgroup '("Make" "Automake" "Arduino") :test "make")
111 ;; Automake tooling.
112 (cit-checkenv-test "automake" :testgroup "Automake" :test "automake")
113 (cit-checkenv-test "libtool" :testgroup "Automake" :test "libtool")
114 ;; C and CPP stuff
115 (cit-checkenv-test "cpp" :testgroup '("Make" "Automake" "cpp") :test "cpp")
116 ;; Texinfo
117 (cit-checkenv-test "texinfo" :testgroup '("Make" "Automake") :test "makeinfo")
118 ;; Java stuff
119 (cit-checkenv-test "java"
120 :testgroup "Java"
121 :test (lambda () (cedet-java-version-check t))
122 :result t)
123 (cit-checkenv-test "jar" :testgroup "Java" :test "jar")
124 (cit-checkenv-test "javap" :testgroup "Java" :test "javap")
125 ;; arduino
126 (cit-checkenv-test "arduino" :testgroup "Arduino"
127 :test (lambda ()
128 (require 'ede/arduino)
129 (stringp (ede-arduino-find-install)))
130 :result t)
131 (cit-checkenv-test "arduino-mk" :testgroup "Arduino"
132 :test (lambda ()
133 (require 'ede/arduino)
134 (stringp (ede-arduino-Arduino.mk)))
135 :result t)
136 ;; android
137 (cit-checkenv-test "android-sdk" :testgroup "Android"
138 :test (lambda () (cedet-android-adb-version-check t))
139 :result t)
140 (cit-checkenv-test "ant" :testgroup "Android" :test "ant") ;; may be moving off this soon.
142 "List of checks to perform to see if this system can run the tests.
143 Each entry is a `cit-checkenv-test' object. See the doc for that
144 class for details.")
146 (defun cit-checkenv (testgroup)
147 "Check this computer for the needed tools."
148 (interactive "sTest Group: ")
149 (message "\n** Environment testing:
150 Checking your environment for the tools needed to test CEDET.\n")
151 (mapc (lambda (check) (cit-checkenv-dotest check testgroup)) cit-checkenv-checks)
153 (message "** Environment Tests complete\n")
157 (provide 'cit-checkenv)
159 ;;; cit-checkenv.el ends here