-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Travis integration #61
Merged
+142
−0
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1a0afdf
first stab at testing with buttercup
cg505 5dfca52
add travis conf
cg505 7dc777c
dynamically load tests
cg505 23052a1
add dev mode and load tests when in dev mode
cg505 b6af5be
initialize emacs as part of travis tests
cg505 fd70b32
fix usage of home directory
cg505 35fdca5
also test against emacs HEAD
cg505 38364fe
slack notifs + whitespace update
cg505 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
(kotct/load-corresponding) | ||
|
||
(describe "completion config" | ||
(describe "ido menu mode" | ||
:var (orig-mode) | ||
|
||
(before-all | ||
; record original setting for later | ||
(setf orig-mode kotct/ido-current-menu-mode)) | ||
|
||
(after-all | ||
; restore original setting | ||
(setf kotct/ido-current-menu-mode orig-mode)) | ||
|
||
(before-each | ||
(spy-on #'ido-grid-mode) | ||
(spy-on #'ido-vertical-mode)) | ||
|
||
(describe "is unset correctly" | ||
(it "when using grid mode" | ||
(let ((kotct/ido-current-menu-mode 'grid)) | ||
(kotct/ido-unset-menu-mode)) | ||
|
||
(expect #'ido-grid-mode :to-have-been-called) | ||
(expect (spy-calls-args-for #'ido-grid-mode 0) :to-equal '(-1))) | ||
|
||
(it "when using vertical mode" | ||
(let ((kotct/ido-current-menu-mode 'vertical)) | ||
(kotct/ido-unset-menu-mode)) | ||
|
||
(expect #'ido-vertical-mode :to-have-been-called) | ||
(expect (spy-calls-args-for #'ido-vertical-mode 0) :to-equal '(-1)))) | ||
|
||
(describe "is set correctly" | ||
(it "to grid mode" | ||
(let ((kotct/ido-current-menu-mode 'normal)) | ||
(kotct/ido-set-menu-mode 'grid)) | ||
|
||
(expect #'ido-grid-mode :to-have-been-called) | ||
(expect (spy-calls-args-for #'ido-grid-mode 0) :to-equal '(+1))) | ||
|
||
(it "to vertical mode" | ||
(let ((kotct/ido-current-menu-mode 'normal)) | ||
(kotct/ido-set-menu-mode 'vertical)) | ||
|
||
(expect #'ido-vertical-mode :to-have-been-called) | ||
(expect (spy-calls-args-for #'ido-vertical-mode 0) :to-equal '(+1)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(require 'buttercup) | ||
|
||
(defun kotct/quietly-load-file (filename &optional throw-error) | ||
"Load FILENAME, but do not send a message on success. | ||
If loading throws an error, send a message with FILENAME and the error. | ||
If THROW-ERROR is non-nil, re-throw the caught error." | ||
(condition-case err | ||
(load filename nil 'nomessage) | ||
(error | ||
(message (format "Error while loading %s:\n%s" file (error-message-string err))) | ||
(if throw-error | ||
(error (cdr err)))))) | ||
|
||
(defun kotct/load-corresponding () | ||
"Load the file corresponding to the current test. | ||
Only works when called in script mode." | ||
(when noninteractive | ||
(assert (string-match-p "-test\\.el$" load-file-name)) | ||
(kotct/quietly-load-file | ||
(replace-regexp-in-string | ||
"-test\\.el$" ".el" | ||
(replace-regexp-in-string | ||
(regexp-quote "/test/") "/" | ||
load-file-name))))) | ||
|
||
(defun kotct/run-tests () | ||
"Run all emacs lisp tests for the kotct/dot emacs configuration." | ||
(interactive) | ||
(setf buttercup-suites nil) | ||
(dolist (file (directory-files-recursively | ||
(file-name-directory (symbol-file #'kotct/run-tests)) | ||
"-test\\.el\\'")) | ||
(kotct/quietly-load-file file)) | ||
(let ((buttercup-reporter | ||
(lambda (event arg) | ||
(condition-case err | ||
(buttercup-reporter-adaptive event arg) | ||
(error | ||
;; avoid error on test failure | ||
(unless (and (not noninteractive) | ||
(equal (second err) "")) | ||
(error (second err)))))))) | ||
(buttercup-run))) | ||
|
||
(provide 'dot-tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(load-file "~/.emacs.d/lisp/package/dependencies.el") | ||
(load-file "~/.emacs.d/lisp/package/repositories.el") | ||
|
||
(package-initialize) | ||
(package-refresh-contents) | ||
|
||
(mapc #'package-install kotct/dependency-list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
;; NOTE: this file is designed to be exclusively run in script mode | ||
|
||
(package-initialize) | ||
|
||
(load-file (concat (file-name-directory load-file-name) "/dot-tests.el")) | ||
|
||
(kotct/run-tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
language: emacs-lisp | ||
sudo: false | ||
cache: apt | ||
env: | ||
- EVM_EMACS=emacs-25.1-travis | ||
- EVM_EMACS=emacs-25.2-travis | ||
- EVM_EMACS=emacs-git-snapshot-travis | ||
before_install: | ||
- git clone https://github.com/rejeep/evm.git ~/.evm | ||
- export PATH="~/.evm/bin:$PATH" | ||
- evm config path /tmp | ||
install: | ||
- evm install $EVM_EMACS --use --skip | ||
- ln -s "$(pwd)/.emacs.d" ~/.emacs.d | ||
- emacs --script .emacs.d/test/lisp/install.el | ||
- echo "base-config" > .emacs.d/lisp/user/default-username | ||
before_script: | ||
- emacs --version | ||
script: | ||
- emacs --script .emacs.d/init.el | ||
- emacs --script .emacs.d/test/lisp/run-tests.el | ||
notifications: | ||
slack: | ||
secure: Pu2AagcBjx2iBPwsIJ3oNdB5koGfqSP12Mat9KYajxtIwbyzgGsToiyma3+s+Yl02+IRZdGonZaKH/c2RGNF05PK4PAoNfkhYafiog4hKD5ZusIi1xVr0zWOREZVsqpAeu0cxs/b+p7Va66+CRukGYxTGs0LjfEXoJ3KRJYwziSVDYVEoujGHFTPKlyNZNU0fSW+pioVneiVy+hpVvfdzqby9WJG9nK/607xceJ+HVdntXABnUBDk6/1KVqbH36U2Xlw2hlRebGWIowqg/S6yOqn+NxvrM5FNb7LHWxx/mLM3o5Ml1pm9mcDS0M+sPOquLlW/0NPfiV3cz485W6aoSo37z9eassQ4DKQsEjiL4AfGXH4Wgu3BASnWTMkSXfGwW09rKSu1PCyozp76htkiMWp2tJQo/GUAey7PYTSEHhFWBhBL2UaJ3WY4H/1SdaVqHwnBNXU6YEMIJn0S7F31MmQUmSIcVMbqP9XojWl9DHDKP9o4S5CCshYlKR3XzdSeOzyQKb2PKr5NAtU2lYVMfL4XYEsz+sWO1yOCUB+U0yVXdk9kInGHY5AAwIJ6v/ODSDGW67SlXMAJcrkW2nlX8I9JZ+aR4vKo47j+MCPsPMBaPoHyGquVe9++iq67Kdxl18azrQ6fVbjNda3LRTZVH9ekWRf9eMsVBbSeyORUx8= |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to include this (both the var and the thing) in
init.el
becauseinit
stream under normal non-dev circumstances, andI think tests should be run in a separate Emacs instance from the existing one, if the developer is running one. The ability to run
kotct/run-tests
within the normal running circumstances is somewhat sketchy to me. Far better to run Emacs using a--script
that also loadsinit
than do this, I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardly. I wouldn't consider a variable definition and an if-statement to be adding anything.
I mean... the tests do not run or actually do anything unless you explicitly run them, so the only "tainting" is the definition of a few functions. Also this only happens in dev mode.
Officially, a separate Emacs instance is the correct way to run the tests. If
emacs --script ~/.emacs.d/test/lisp/run-tests.el
fails, the tests do not pass. That is how they're run in Travis. That said, having the ability to run the tests in your Emacs session is a convenience that makes it much easier to run/debug tests, and there's very little overhead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be a good enough first step, I guess. We can go ahead and continue with the PR, and if it causes problems we can rethink.