-
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
Conversation
This is a part of #53. (Does not fix.) |
Gonna squash those last two commits. |
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 is a good first step. I just that some cleanup specifically related to the Travis config and some of the runners is needed to make this very refined.
:var (orig-mode) | ||
|
||
(before-all | ||
; record orignal setting for 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.
typo: orignal
.travis.yml
Outdated
install: | ||
- emacs --script .emacs.d/test/lisp/install.el | ||
script: | ||
- emacs --version |
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 shouldn't be included in the script
block; it's not part of our tests.
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.
Do you advocate removing completely or moving to before_script
?
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.
That would be smart, I think.
.emacs.d/test/lisp/dot-tests.el
Outdated
|
||
(defun kotct/run-tests () | ||
(setf buttercup-suites nil) | ||
(load "~/.emacs.d/test/lisp/behavior/completion-c-test.el" nil t) |
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.
Is nil t
necessary here? Can you extract the test running behavior out into a different function and call it a bunch of times in a master function rather than add more and more of these lines to this one function? Or maybe do globbing to find all the tests?
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.
nil t
is necessary, otherwise we get a bunch of messages saying it loaded all the test files. It's annoying. I'm making this line dynamic so we don't have to specify all the test files.
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.
Do you prefer nil t
over something more like nil 'nomessage
?
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.
That is fine.
.emacs.d/test/lisp/dot-tests.el
Outdated
@@ -0,0 +1,27 @@ | |||
(require 'buttercup) | |||
|
|||
(defun kotct/load-corresponding () |
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.
Missing docstring?
.travis.yml
Outdated
- export PATH="/home/travis/.evm/bin:$PATH" | ||
- git clone https://github.com/rejeep/evm.git /home/travis/.evm | ||
- evm config path /tmp | ||
- evm install $EVM_EMACS --use --skip |
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 should move to the install
block.
.travis.yml
Outdated
- EVM_EMACS=emacs-25.2-travis | ||
before_install: | ||
- export PATH="/home/travis/.evm/bin:$PATH" | ||
- git clone https://github.com/rejeep/evm.git /home/travis/.evm |
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.
Maybe consider cloning before exporting PATH
? It's just a matter of semantics.
.travis.yml
Outdated
- git clone https://github.com/rejeep/evm.git /home/travis/.evm | ||
- evm config path /tmp | ||
- evm install $EVM_EMACS --use --skip | ||
- ln -s "$(pwd)/.emacs.d" ~/.emacs.d |
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.
Perhaps do this in the install
block as well?
.travis.yml
Outdated
before_install: | ||
- export PATH="/home/travis/.evm/bin:$PATH" | ||
- git clone https://github.com/rejeep/evm.git /home/travis/.evm | ||
- evm config path /tmp |
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.
Doesn't matter but maybe use mktemp -d
to make a temporary directory specifically for the install?
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.
Don't think this really matters. EVM says to use /tmp
, and I don't want to run into issues with that, so I'm just going to leave it.
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.
Progress, but I'm hesitant to keep dev-mode
in init.el
.
.travis.yml
Outdated
before_script: | ||
- emacs --version | ||
script: | ||
- emacs --script ~/.emacs.d/init.el |
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.
Is this needed and will it stay persistent to the next call?
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 just tests startup. Nothing persists to the next call (except maybe the creation of some random things like the recentf file).
.travis.yml
Outdated
- emacs --version | ||
script: | ||
- emacs --script ~/.emacs.d/init.el | ||
- emacs --script .emacs.d/test/lisp/run-tests.el |
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.
Which one of these is needed? Also, do you need ~/
at the start of this?
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.
The first one is intended to make sure that Emacs can successfully start without error. The second runs the tests.
The ~/
is just meant to replicate Emacs' behavior by running init.el from the home directory instead of the clone directory.
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.
Probably we can make the presence of ~/
consistent without impact, I was just explaining why it is what it is rn.
.travis.yml
Outdated
- EVM_EMACS=emacs-25.1-travis | ||
- EVM_EMACS=emacs-25.2-travis | ||
before_install: | ||
- git clone https://github.com/rejeep/evm.git /home/travis/.evm |
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.
Consider using $HOME
instead; HOME=/home/travis
by default.
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.
You could also just use ~
, which is equivalent to $HOME
.
.travis.yml
Outdated
- EVM_EMACS=emacs-25.2-travis | ||
before_install: | ||
- git clone https://github.com/rejeep/evm.git /home/travis/.evm | ||
- export PATH="/home/travis/.evm/bin:$PATH" |
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.
Ditto here, use $HOME
or ~
?
.travis.yml
Outdated
cache: apt | ||
env: | ||
- EVM_EMACS=emacs-25.1-travis | ||
- EVM_EMACS=emacs-25.2-travis |
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.
Can we add support for latest HEAD
Emacs, too? Does EVM have development versions?
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.
EVM has an emacs-git-snapshot-travis
build but it seems like maybe not the best plan to have our tests dependent on unstable behavior in the emacs git repo? It also seems unnecessary. On second thought I don't really care very much and this is unlikely to break anything. I'm happy to go with whatever you think is the best plan.
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 typically test my Ruby projects against ruby
's latest release(s) as well as the latest Git snapshot because I like to see if stuff works with the new API. It's okay to omit it, though.
@@ -109,6 +116,10 @@ Despite this, your config appears to have loaded successfully.") | |||
(if loaddefs-buffer | |||
(kill-buffer loaddefs-buffer))) | |||
|
|||
;; If in dev mode, load the test runner. | |||
(when kotct/dev-mode | |||
(require 'dot-tests "~/.emacs.d/test/lisp/dot-tests")) |
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
because
- It adds calls to the
init
stream under normal non-dev circumstances, and - Adding this to the source tree for the entire configuration means that we're tainting our actual configuration with testing stuff.
I 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 loads init
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.
It adds calls to the
init
stream under normal non-dev circumstances
Hardly. I wouldn't consider a variable definition and an if-statement to be adding anything.
Adding this to the source tree for the entire configuration means that we're tainting our actual configuration with testing stuff.
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.
I 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.
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.
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.
LGTM for now! 🎉 🥇
This PR adds basic integration for Travis CI. Merging it now will allow future PRs to write tests for their code.