summaryrefslogtreecommitdiff
path: root/features/support/env.el
blob: 527088e495ffc89d499bcca22d6e05124057af2a (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
;;; env.el --- Test environment setup  -*- lexical-binding: t; -*-

(require 'f)

(defvar emacs-chess-support-path
  (f-dirname load-file-name))

(defvar emacs-chess-features-path
  (f-parent emacs-chess-support-path))

(defvar emacs-chess-root-path
  (f-parent emacs-chess-features-path))

;; Nikolaj Schumacher
(defmacro measure-time (&rest body)
  "Measure the time it takes to evaluate BODY."
  `(let ((time (current-time)))
     ,@body
     (float-time (time-since time))))

(add-to-list 'load-path emacs-chess-root-path)

(require 'chess-ics)
(require 'chess)
(require 'espuds)
(require 'ert)
(require 'cl-lib)

(Setup
 (defvar test-display nil)
 (defvar test-fifo nil)
 (defvar test-port nil)
 (setq test-port (catch 'loop
                   (dolist (cand (list "5678" "5413" "5142" "5308" "5987"))
                     (when (= 1 (call-process "nc" nil nil nil "-z" "localhost" cand))
                       (throw 'loop cand)))))
 (setq noninteractive t)
 (custom-set-variables '(chess-sound-moves nil)
                       '(chess-display-highlight-last-move t)
                       '(chess-display-highlight-legal t)
                       '(chess-display-popup nil)
                       '(chess-display-allow-pre-moves t)
                       '(chess-images-separate-frame nil))
)

(Before
 ;; Before each scenario is run
 )

(After
 ;; After each scenario is run
 (when test-display 
   (chess-module-destroy test-display)
   (setq test-display nil))
 (dolist (p (process-list))
   (delete-process p))
 (setq test-fifo nil)
 (let ((buf (get-buffer "*Chessboard*"))
       (buf2 (get-buffer "*Chessboard*<2>")))
   (if buf (kill-buffer buf))
   (if buf2 (kill-buffer buf2)))
)

(Teardown
 ;; After when everything has been run
 )

;;; env.el ends here