Skip to content

Commit

Permalink
Add Cask, ERT tests, and Travis builds
Browse files Browse the repository at this point in the history
  • Loading branch information
SavchenkoValeriy committed Aug 9, 2019
1 parent 311101b commit acec4b2
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions .ert-runner
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-L .
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
language: emacs-lisp
os: linux
dist: xenial
sudo: false

env:
- EVM_EMACS=emacs-24.3-travis
- EVM_EMACS=emacs-24.4-travis
- EVM_EMACS=emacs-24.5-travis
- EVM_EMACS=emacs-25.1-travis
- EVM_EMACS=emacs-25.2-travis
- EVM_EMACS=emacs-25.3-travis
- EVM_EMACS=emacs-26.1-travis
- EVM_EMACS=emacs-26.2-travis
- EVM_EMACS=emacs-git-snapshot-travis

addons:
apt:
packages:
- clang-format-3.8

install:
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > travis.sh && source ./travis.sh
- evm install $EVM_EMACS --use --skip
- cask install

script:
- clang-format --version
- cask exec ert-runner
7 changes: 7 additions & 0 deletions Cask
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(source gnu)
(source melpa)

(package-file "clang-format+.el")

(development
(depends-on "ert-runner"))
1 change: 1 addition & 0 deletions clang-format+.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

;;; Code:

(require 'cc-cmds)
(require 'clang-format)
(require 'cl-lib)

Expand Down
53 changes: 53 additions & 0 deletions test/clang-format+-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
;;; clang-format+-test.el --- Tests for clang-format+ -*- lexical-binding: t; -*-

(require 'clang-format+)

(ert-deftest clang-format+:basic-test ()
(with-temp-buffer
(c++-mode)
(clang-format+-mode)
(insert "\nclass A {\n\n\n};\n")
(clang-format+-before-save)
(should (equal (buffer-string)
"\nclass A {};\n"))))

(ert-deftest clang-format+:modified-test ()
(with-temp-buffer
(switch-to-buffer (current-buffer))
(insert "\nclass A {\n\nint foo () {\n\n};\n};\n")
(c++-mode)
(clang-format+-mode)
(previous-line 3)
(insert "\n\n\n")
(clang-format+-before-save)
(should (equal (buffer-string)
"\nclass A {\n\n int foo(){\n\n };\n};\n"))))

(ert-deftest clang-format+:apply-to-all-test ()
(let ((clang-format+-apply-to-modifications-only nil)
(clang-format-style "llvm"))
(with-temp-buffer
(switch-to-buffer (current-buffer))
(insert "\nclass A {\n public:\nint foo () {\n\n};\n};\n")
(c++-mode)
(clang-format+-mode)
(previous-line 3)
(insert "\n\n\n")
(clang-format+-before-save)
(should (equal (buffer-string)
"\nclass A {\npublic:\n int foo(){\n\n };\n};\n")))))

(ert-deftest clang-format+:no-definition-test ()
(let ((clang-format+-apply-to-modified-definition nil))
(with-temp-buffer
(switch-to-buffer (current-buffer))
(insert "\nclass A {\n\npublic:\n\n};\n")
(c++-mode)
(clang-format+-mode)
(previous-line 2)
(insert " void foo () { }")
(clang-format+-before-save)
(should (equal (buffer-string)
"\nclass A {\n\npublic:\n void foo() {}\n};\n")))))

;;; clang-format+-test.el ends here

0 comments on commit acec4b2

Please sign in to comment.