Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 14fced8

Browse filesBrowse files
committed
Add test harness (finally?)
This patch add ert test harness and some tests around the inf-clojure-completion-bounds-of-expr-at-point function.
1 parent 59be8bf commit 14fced8
Copy full SHA for 14fced8

File tree

5 files changed

+188
-0
lines changed
Filter options

5 files changed

+188
-0
lines changed

‎.gitignore

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*~
2+
*\#*\#
3+
*.\#*
4+
*.elc
5+
.cask
6+
elpa*
7+
.depend
8+
TAGS
9+
.DS_STORE
10+
dist
11+
.vagrant/
12+
.dir-locals?.el

‎.travis.yml

Copy file name to clipboard
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: generic
2+
sudo: false
3+
before_install:
4+
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
5+
- evm install $EVM_EMACS --use --skip
6+
- cask
7+
env:
8+
- EVM_EMACS=emacs-24.3-travis
9+
- EVM_EMACS=emacs-24.4-travis
10+
- EVM_EMACS=emacs-24.5-travis
11+
- EVM_EMACS=emacs-25.1-travis
12+
- EVM_EMACS=emacs-25.2-travis
13+
- EVM_EMACS=emacs-25.3-travis
14+
script:
15+
- emacs --version
16+
- cask install
17+
- cask exec ./run_tests.sh

‎Cask

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(source gnu)
2+
(source melpa)
3+
4+
(package-file "inf-clojure.el")
5+
6+
(files "*.el" (:exclude ".dir-locals.el"))
7+
8+
(development
9+
(depends-on "clojure-mode")
10+
(depends-on "buttercup")
11+
(depends-on "assess"))

‎run-tests.sh

Copy file name to clipboard
+62Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh
2+
#
3+
# Copyright © 2014-2018 Bozhidar Batsov
4+
# Authors: Bozhidar Batsov <bozhidar@batsov.com>
5+
# Andrea Richiardi <a.richiardi.work@gmail.com>
6+
# URL: http://github.com/clojure-emacs/inf-clojure
7+
8+
# This file is part of GNU Emacs.
9+
10+
# GNU Emacs is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation, either version 3 of the License, or
13+
# (at your option) any later version.
14+
15+
# GNU Emacs is distributed in the hope that it will be useful,
16+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
# GNU General Public License for more details.
19+
20+
# You should have received a copy of the GNU General Public License
21+
# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22+
23+
# This runs the test for emacs inf-clojure.
24+
# Either $EMACS must be set, or it must be possible to find emacs via PATH.
25+
26+
if [ -z "$EMACS" ]; then
27+
EMACS=emacs
28+
fi
29+
30+
$EMACS --batch || {
31+
echo "You must set EMACS to a program that runs emacs."
32+
exit 1
33+
}
34+
35+
$( $EMACS -batch > /dev/null 2>&1 ) || {
36+
echo "Your emacs command ($EMACS) does not run properly."
37+
exit 2
38+
};
39+
40+
$( $EMACS -batch --eval "(require 'ert)" > /dev/null 2>&1 ) || {
41+
echo 'You must install the `ert` dependency; see README.md'
42+
exit 3
43+
};
44+
45+
# All the files inf-clojure depends on (in dependency order!)
46+
DEPS_INCLUDES="-l inf-clojure.el"
47+
48+
WARNINGS="$($EMACS -Q -batch $DEPS_INCLUDES -f batch-byte-compile inf-clojure.el 2>&1 | grep -v '^Wrote ')"
49+
if [ -n "$WARNINGS" ]; then
50+
echo "Byte-compilation failed:"
51+
echo "$WARNINGS"
52+
rm *.elc
53+
exit 4
54+
else
55+
rm *.elc
56+
echo "Byte-compilation passed."
57+
fi
58+
59+
TEST_INCLUDES=$(ls test/*.el | sed -e 's/^/-l /' | xargs)
60+
61+
# Note that the order of the -l counts
62+
$EMACS -batch -l buttercup $DEPS_INCLUDES -l inf-clojure.el $TEST_INCLUDES -f buttercup-run-discover

‎test/inf-clojure-tests.el

Copy file name to clipboard
+86Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
;;; inf-clojure-tests.el --- Tests for Inf-Clojure -*- lexical-binding: t; -*-
2+
;;
3+
;; Copyright © 2014-2018 Bozhidar Batsov
4+
5+
;; Authors: Bozhidar Batsov <bozhidar@batsov.com>
6+
;; Andrea Richiardi <a.richiardi.work@gmail.com>
7+
;; URL: http://github.com/clojure-emacs/inf-clojure
8+
;; Keywords: processes, clojure
9+
;; Package-Requires: ((emacs "24.4") (clojure-mode "5.3"))
10+
11+
;; This file is part of GNU Emacs.
12+
13+
;; GNU Emacs is free software: you can redistribute it and/or modify
14+
;; it under the terms of the GNU General Public License as published by
15+
;; the Free Software Foundation, either version 3 of the License, or
16+
;; (at your option) any later version.
17+
18+
;; GNU Emacs is distributed in the hope that it will be useful,
19+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
;; GNU General Public License for more details.
22+
23+
;; You should have received a copy of the GNU General Public License
24+
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25+
26+
;;; Commentary:
27+
;;
28+
;; Code completion using alexander-yakushev/compliment.
29+
30+
;;; Code:
31+
32+
;; Tests for inf-clojure.el
33+
34+
(message "Running tests on Emacs %s" emacs-version)
35+
36+
(require 'buttercup)
37+
(require 'assess)
38+
(require 'inf-clojure)
39+
40+
(cl-defmacro ict-with-assess-buffers ((&rest varlist) &body body)
41+
`(assess-with-temp-buffers (,@varlist)
42+
(clojure-mode)
43+
(inf-clojure-minor-mode)
44+
,@body))
45+
46+
(defun ict-bounds-string (bounds)
47+
(buffer-substring (car bounds) (cdr bounds)))
48+
49+
(describe "completion bounds at point" ()
50+
51+
(it "computes bounds for plain-text"
52+
(ict-with-assess-buffers
53+
((a (insert "plain-text")))
54+
(with-current-buffer a
55+
(expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point))
56+
:to-equal "plain-text"))))
57+
58+
(it "computes bounds for @deref when point is after it"
59+
(ict-with-assess-buffers
60+
((a (progn
61+
(insert "@deref")
62+
(goto-char 7))))
63+
(with-current-buffer a
64+
(expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point))
65+
:to-equal "deref"))))
66+
67+
(it "computes bounds for ^:keyword when point is after it"
68+
(ict-with-assess-buffers
69+
((a (progn
70+
(insert "^:keyword")
71+
(goto-char 10))))
72+
(with-current-buffer a
73+
(expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point))
74+
:to-equal ":keyword"))))
75+
76+
(it "computes no bounds when point is after a break expression"
77+
(ict-with-assess-buffers
78+
((a (progn
79+
(insert "@")
80+
(goto-char 2))))
81+
(with-current-buffer a
82+
(expect
83+
(ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point))
84+
:not :to-be nil)))))
85+
86+
;;; inf-clojure-tests.el ends here

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.