Skip to content
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
merged 8 commits into from
Jul 19, 2017
Merged

Add Travis integration #61

merged 8 commits into from
Jul 19, 2017

Conversation

cg505
Copy link
Contributor

@cg505 cg505 commented Jul 16, 2017

This PR adds basic integration for Travis CI. Merging it now will allow future PRs to write tests for their code.

@cg505 cg505 requested review from rye and samontea July 16, 2017 16:08
@cg505
Copy link
Contributor Author

cg505 commented Jul 16, 2017

This is a part of #53. (Does not fix.)

@cg505
Copy link
Contributor Author

cg505 commented Jul 16, 2017

Gonna squash those last two commits.

rye
rye previously requested changes Jul 16, 2017
Copy link
Member

@rye rye left a 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
Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.


(defun kotct/run-tests ()
(setf buttercup-suites nil)
(load "~/.emacs.d/test/lisp/behavior/completion-c-test.el" nil t)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fine.

@@ -0,0 +1,27 @@
(require 'buttercup)

(defun kotct/load-corresponding ()
Copy link
Member

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
Copy link
Member

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
Copy link
Member

@rye rye Jul 16, 2017

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
Copy link
Member

@rye rye Jul 16, 2017

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
Copy link
Member

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?

Copy link
Contributor Author

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.

@cg505 cg505 dismissed rye’s stale review July 16, 2017 20:16

concerns addressed, please re-review

@cg505 cg505 requested a review from rye July 17, 2017 00:54
Copy link
Member

@rye rye left a 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
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Member

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"
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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"))
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@rye rye Jul 19, 2017

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.

@cg505 cg505 requested a review from rye July 19, 2017 00:58
Copy link
Member

@rye rye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for now! 🎉 🥇

@rye rye mentioned this pull request Jul 19, 2017
4 tasks
@cg505 cg505 merged commit 5d5c678 into master Jul 19, 2017
@rye rye modified the milestone: Version 0.0.0 Aug 3, 2017
@rye rye deleted the test-framework branch September 11, 2017 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants