summaryrefslogtreecommitdiffstats
path: root/emacs.d/nxhtml/tests/nxhtmltest-Q.el
blob: b89857d3fd4fc30ec59582a2f39a1f73a4116f0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
;;; test-Q.el --- Run test from a fresh Emacs
;;
;; Author: Lennart Borgman (lennart O borgman A gmail O com)
;; Created: 2008-07-08T23:05:40+0200 Tue
;; Version: 0.1
;; Last-Updated: 2008-07-09T00:17:26+0200 Tue
;; URL:
;; Keywords:
;; Compatibility:
;;
;; Features that might be required by this library:
;;
;;   Required feature `test-Q' was not provided.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Defines `nxhtmltest-Q'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:

(eval-when-compile (require 'cl))
(eval-when-compile (require 'ourcomments-util))

(eval-and-compile
  (defvar nxhtmltest-bin-Q
    (file-name-directory (or load-file-name
                             (when 'bytecomp-filename bytecomp-filename)
                             buffer-file-name)))

  (add-to-list 'load-path nxhtmltest-bin-Q)
  (require 'nxhtmltest-helpers))

;;;###autoload
(defun nxhtmltest-run-Q ()
  "Run all tests defined for nXhtml in fresh Emacs.
See `nxhtmltest-run' for more information about the tests."
  (interactive)
  (let* ((test-el (expand-file-name "nxhtmltest-suites.el" nxhtmltest-bin-Q))
         (nxhtml-auto-start (expand-file-name "../autostart.el" nxhtmltest-bin-Q))
         (temp-eval-file (expand-file-name "temp-test.el" nxhtmltest-bin-Q))
         (temp-eval-buf (find-file-noselect temp-eval-file))
         (load-path load-path))
    ;;(load (expand-file-name "nxhtmltest-helpers" nxhtmltest-bin-Q))
    (add-to-list 'load-path nxhtmltest-bin-Q)
    (require 'nxhtmltest-helpers)
    (nxhtmltest-get-fontification-method)
    (with-current-buffer temp-eval-buf
      (erase-buffer)
      (insert "(setq debug-on-error t)\n"
              "(eval-when-compile (require 'cl))\n"
              "(delete-other-windows)\n"
              "(eval-after-load 'nxhtml '(setq nxhtml-skip-welcome t))\n"
              (format "(setq nxhtmltest-default-fontification-method '%s)\n"
                      nxhtmltest-default-fontification-method)
              ))
    (when (featurep 'ruby-mode)
      (with-current-buffer temp-eval-buf
        (insert "(pushnew \""
                (file-name-directory (locate-library "ruby-mode"))
                "\" load-path)")))
    (with-current-buffer temp-eval-buf
      (save-buffer))
    (kill-buffer temp-eval-buf)
    (unless (file-exists-p nxhtmltest-bin-Q)
      (error "Can't find directory %s" nxhtmltest-bin-Q))
    (setq nxhtmltest-bin-Q (file-name-sans-extension nxhtmltest-bin-Q))
    (unless (file-exists-p test-el)
      (error "Can't find file %s" test-el))
    (setq test-el (file-name-sans-extension test-el))
    (unless (file-exists-p nxhtml-auto-start)
      (error "Can't find file %s" nxhtml-auto-start))
    (setq nxhtml-auto-start (file-name-sans-extension nxhtml-auto-start))
    (message "nxhtmltest-bin-Q=%s" nxhtmltest-bin-Q)
    (message "nxhtml-auto-start=%s" nxhtml-auto-start)
    (setenv "nxhtmltest-run-Q" "run")
    (message "After setenv nxhtmltest-run-Q=%s" (getenv "nxhtmltest-run-Q"))
    (message "(ourcomments-find-emacs) => %s" (ourcomments-find-emacs))
    (call-process (ourcomments-find-emacs) nil 0 nil "-Q"
                  "-l" temp-eval-file
                  "-l" nxhtml-auto-start
                  "-l" test-el)
    (message "After call-process")
    (setenv "nxhtmltest-run-Q")
    (message "Starting new Emacs instance for test - it will be ready soon ...")))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; nxhtmltest-Q.el ends here