EmacsLispã§æå°æ§æ(ã£ã½ã)ãã¹ããããæ¹æ³
ERTã§ãã¹ããããããæ¹ãæ°ã«ãªã£ãã®ã§ãGithubã§ãã¹ããã¦ãããªãã¸ããªãããã¤ãè¦ã¦ãã£ãã
ããã¤ãã®ãªãã¸ããªãè¦ã¦ãããããããªãå¾ã å¿ç¨ãå©ãããªã¨ç¨åº¦ã®ãã®ãã§ããã®ã§è¨äºã«ãã¦ã¿ããã¨æãã
ãã¹ãã¯Emacs24ã§ã¤ãã¦ããããã«ãªã£ãERTãMakefileã§ãã¹ããããã¤ã«ãªãã
https://github.com/pogin503/emacs-test-sample
ããã«ä½ã£ããã¤ãç½®ãã¦ããã®ã§
$ git clone git://github.com/pogin503/emacs-test-sample.git $ cd emacs-test-sample $ make test
ã§å®è¡åºæ¥ã¾ãã
å®è¡ä¾
$ make test /Applications/Emacs.app/Contents/MacOS/Emacs --batch -Q -L . --eval \ "(progn \ (setq byte-compile-error-on-warn t) \ (batch-byte-compile))" *.el Wrote /Users/username/repo/emacs-test-sample/myfile.elc /Applications/Emacs.app/Contents/MacOS/Emacs --batch -Q -L . -l test/run-test.el Running tests on Emacs 24.3.1 Loading /Users/username/repo/emacs-test-sample/test/myfile-test.el (source)... Running 1 tests (2013-06-18 01:57:09+0900) passed 1/1 myfile:addition-test Ran 1 tests, 1 results as expected (2013-06-18 01:57:09+0900)
ä¸èº«ã«ã¤ãã¦
ãã©ã«ãæ§æ
ãã©ã«ãæ§æã¯ãããªãµãã«ãã¦ããã
. âââ Makefile âââ myfile.el âââ test âââ lib #ãã¹ãç¨ã®ã©ã¤ãã©ãªãã£ã¬ã¯ããªï¼å¿ è¦ãããã°ä½ãï¼ â âââ cl-lib.el â âââ ert.el âââ myfile-test.el #å®è¡ããããã¹ã âââ run-test.el #å®è¡ç¨ã®è¨å®ããã¦ãã¹ããèµ°ããããã¡ã¤ã«
- testç¨ã®å®è¡é¢æ°ãªã©ã¯myfile-test.elã«å ¥ãããå®éã«å®è¡ãããã®ã¯run-test.elã«å®è¡ãããã®ãè¯ãã¨æãã
- libã®ä¸ã«ã¯å¤ãEmacsç¨ã«ert.elãå ¥ããããä»ã®å¿ è¦ãªã©ã¤ãã©ãªãå ¥ãã¦ããã°ããã
- libã®ä½ç½®ã¯ããããã£ã¬ã¯ããªã«ããã¹ãããtestå ã«å ¥ããã»ããããã®ãããããªããèªåã¯testã®ä¸ã«å ¥ãã¨ãã®ãããã®ããªã¨æãã
ãããå¦ç
Emacsã®ãããå¦çã¯-batchãã¾ãã¯--batchããªãã·ã§ã³ã«å ¥ãã¦å®è¡ãã¾ãã
$ emacs --batch -L . --eval "(message \"Running tests on Emacs %s\" emacs-version)"
ãããå¦çã§ãã使ããªãã·ã§ã³ã¯ãããªã®
ãªãã·ã§ã³ | å¹æ | |
-Q | .emacsãã.emacs.d/init.elãèªã¿è¾¼ã¾ãªãããã«ããããã¤æå°ã®è¨å®ã§èµ·åãã | |
-L directory | directoryãload-pathã«è¿½å ãã | |
-f function | functionãå¼æ°ãªãã§èªã¿è¾¼ã | |
-l file | ãã¡ã¤ã«åãloadãã | |
--batch | ãããã¢ã¼ããåãã | |
--eval expression | --evalã®å¾ã«ç¶ãLispããã°ã©ã ãè©ä¾¡ãã |
Makefile
Makefileã¯ãããªé¢¨ã«ããã°ããããããªããã¨æãã
# Makefile UNAME:=$(shell uname -s) #å¤ååãã¨æã ifeq ($(UNAME),Darwin) EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs else EMACS=emacs endif .PHONY : build test build : $(EMACS) --batch -Q -L . --eval \ "(progn \ (setq byte-compile-error-on-warn t) \ (batch-byte-compile))" *.el test: build $(EMACS) --batch -Q -L . -l test/run-test.el
Macã使ã£ã¦ããã¨/usr/binã«ããå¤ãEmacsã使ãããã®ã§
ifeq ($(UNAME),Darwin) EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs else EMACS=emacs endif
ifeqæ®æ®µä½¿ãEmacsãè¨å®ãã¦ãããªãã¨ãããªãã
- buildé¨åã§ã¯ãã¤ãã³ã³ãã¤ã«ããã¦ãã¾ãããã¼ããããã¡ã¤ã«ãå¤ããªãã°å¤åä½æã§ãããããã¾ã§æ©ããªãã®ãããå¥ã«ãªãã¦ãããæ°ãããã
ã ããããããªé¢¨ã«ããã°æå°éã®è¨å®ã§åãããã¨ãã§ãã¦ãã¹ãããããã¨ãã§ãã¾ãã
myfile.el
ERTã§å®è¡ããç¨ã«ç¨æããã
;; myfile.el (defun myfile:addition (a b) (+ a b)) (provide 'myfile)
test/myfile-test.el
å®è¡ããããã¡ã¤ã«ã«ã¯(require 'ert)ã(require 'myfile)ã¨ããã¦å¿ è¦ãªãã¡ã¤ã«ããã®ããã¼ãããã
ERTã¯ert-deftestã使ã£ã¦å®è¡ãããã¹ããä½ãã
;; test/myfile-test.el (require 'ert) (require 'myfile) (ert-deftest myfile:addition-test () (should (= (myfile:addtion 1 2) 3)))
test/run-test.el
ãã®ãã¡ã¤ã«ã§å®éã«ãã¹ããããããã®ãã¼ããã¹ããèªã¿è¾¼ãã©ã¤ãã©ãªãè¨å®ããã
Makefileã«ã®-lãªãã·ã§ã³ã§èªã¿è¾¼ãã¨ãã«ä½¿ãããã
å°ã ãªããã®ã§githubã®æ¹ã§è¦ã¦ãã ããã
https://github.com/pogin503/emacs-test-sample/blob/master/test/run-test.el
test/run-test.el å ã§ãã¹ããå®è¡ãã¦ãé¨åã¯ä¸ã®é¨åã«ãªãã
;; test/run-test.el ;; Run tests (if noninteractive (ert-run-tests-batch-and-exit) (ert t))
ãã¹ãããã¦ãããªãã¸ããª
GitHub - uk-ar/el-spec
GitHub - bbatsov/projectile: Project Interaction Library for Emacs
GitHub - rolandwalker/emacs-travis: Travis CI recipe for Emacs libraries.
GitHub - ecukes/ecukes: Cucumber for Emacs
GitHub - cask/cask: Project management tool for Emacs
GitHub - auto-complete/auto-complete: Emacs auto-complete package
GitHub - emacs-mirror/emacs: Mirror of GNU Emacs
GitHub - tkf/emacs-jedi: Python auto-completion for Emacs
GitHub - haskell/haskell-mode: Emacs mode for Haskell
https://github.com/flycheck/flycheck
travis-ciã§ãã¹ããããå ´å㯠rolandwalker/emacs-travis ãè¦ãã°ããã¨æããã§ãMakefileã®ä¸èº«ã§ãããããã£ã¦ã¦è¤éã§ã¯ããã
ãã£ã±ããã£ã¡ã®æ¹ãç°¡åãããªã®ã§ãã£ã¡ãè¦ãã¨ããã¨æãã
GitHub - lewang/ert-test-skeleton
(è¿½è¨ 2013.6.18)
Cartonã使ã£ãtravis-ciã®ãã¹ããtkfãããä½ã£ã¦ãããã®ã§ãããç´¹ä»ãã
GitHub - tkf/emacs-plugin-template: Minimal emacs plug-in template with setup for Travis CI
Cartonã使ãã»ããã ãã¶æ¥½ããã
追è¨2013/10/3
âCartonããCaskã«ååãå¤ãã£ãã
çµããã«
ã¨ããããERTã®ããããã¹ãã¯åºæ¥ãã®ã§ã²ã¨ã¾ãã¯æºè¶³ã
ããã¦ãã®è¨äºãæ¸ããå¾ã«ãã£ã¨è¯ãããªãµã³ãã«ãè¦ã¤ãã¦ãã¾ãã¨ãã...ã
èªåã¯ã¾ã ãã¹ãã¡ããã¨ä½ã£ããã¨ãç¡ãã®ã§ã¡ããã¨ä½ã£ã¦ã¿ããã¨æãã
(è¿½è¨ 2013.6.18)
el-specã¨ãEcukesã¨ãERTãã«ãã¼ããå®è£
ãããã®ã§ããã£ã¡ã®å°å
¥ã次ã¯æ¸ãã°ããã®ããªã¨ã