Permalink
Browse files

add test file and Makefile for testing automatically

  • Loading branch information...
1 parent 6feb0fb commit fe1b9fb523f17cc3fb8942dd6c641f17c07b9ffa @syohex committed Oct 28, 2012
Showing with 69 additions and 0 deletions.
  1. +4 −0 Makefile
  2. +65 −0 test-quickrun.el
View
4 Makefile
@@ -0,0 +1,4 @@
+.PHONY : test
+
+test:
+ emacs -Q -batch -L . -l test-quickrun.el -f ert-run-tests-batch-and-exit
View
65 test-quickrun.el
@@ -0,0 +1,65 @@
+;;; test-quickrun.el ---
+
+;; Copyright (C) 2012 by Syohei YOSHIDA
+
+;; Author: Syohei YOSHIDA <syohex@gmail.com>
+;; URL:
+;; Version: 0.01
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(eval-when-compile
+ (require 'cl))
+
+(require 'ert)
+(require 'quickrun)
+
+(ert-deftest quickrun:exec-quickrun ()
+ "Exec `quickrun'"
+ (let ((buf (find-file-noselect "sample/sample.py")))
+ (with-current-buffer buf
+ (quickrun))
+ ;; quickrun is async function
+ (sleep-for 1)
+ (with-current-buffer "*quickrun*"
+ (let ((str (buffer-substring-no-properties (point-min) (point-max))))
+ (should (string= "Hello Python quickrun.el\n" str))))))
+
+(ert-deftest quickrun:add-command ()
+ "Add new command"
+ (quickrun-add-command "-test"
+ '((:command . "test foo")
+ (:description . "test description")))
+ (let ((params (assoc-default "-test" quickrun/language-alist)))
+ (should params)
+ (let ((command (assoc-default :command params))
+ (desc (assoc-default :description params)))
+ (should (string= command "test foo"))
+ (should (string= desc "test description")))))
+
+(ert-deftest quickrun:override-configuration ()
+ "Override registerd command"
+ (quickrun-add-command "c/gcc"
+ '((:command . "clang")
+ (:description . "Compile clang"))
+ :override t)
+ (let* ((params (assoc-default "c/gcc" quickrun/language-alist))
+ (command (assoc-default :command params)))
+ (should (string= command "clang"))))
+
+;;; test-quickrun.el ends here

0 comments on commit fe1b9fb

Please sign in to comment.