aboutsummaryrefslogtreecommitdiff
path: root/test/tests.el
blob: ce42a9fa973d61c5a438737f9d893916a57bdaca (plain) (blame)
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

;;; SX Settings
(defun -sx--nuke ()
  (interactive)
  (mapatoms
   (lambda (symbol)
     (if (string-prefix-p "sx-" (symbol-name symbol))
         (unintern symbol)))))

(setq
 sx-initialized t
 sx-request-remaining-api-requests-message-threshold 50000
 debug-on-error t
 url-show-status nil
 user-emacs-directory "."
 sx-test-base-dir (file-name-directory (or load-file-name "./")))


;;; Test Data
(defvar sx-test-data-dir
  (expand-file-name "data-samples/" sx-test-base-dir))

(defun sx-test-sample-data (method &optional directory)
  (let ((file (concat (when directory (concat directory "/"))
                      sx-test-data-dir
                      method ".el")))
    (when (file-exists-p file)
      (with-temp-buffer
        (insert-file-contents file)
        (read (buffer-string))))))

(setq
 sx-test-data-questions
 (sx-test-sample-data "questions")
 sx-test-data-sites
 (sx-test-sample-data "sites"))


;;; General Settings
(setq
 package-user-dir (expand-file-name
                   (format "../../.cask/%s/elpa" emacs-version)
                   sx-test-data-dir))

(package-initialize)

(require 'sx-load)

(defun sx-load-test (test)
  (load-file
   (format "%s/test-%s.el"
           sx-test-base-dir
           (symbol-name test))))

(setq sx-test-enable-messages nil)

(defun sx-test-message (message &rest args)
  (when sx-test-enable-messages
    (apply #'message message args)))

(mapc #'sx-load-test
      '(api macros printing util search))