diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e0e1510 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ + +### Makefile for malabar-mode +## +## Copyright (c) 2009, 2010 Espen Wiborg +## +## 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 2 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, write to the Free Software +## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301 USA. +## + +EMACS=emacs + +mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) +mkfile_dir := $(dir $(mkfile_path)) + +all: testr + +testr: +# cd $(mkfile_dir) && $(EMACS) -Q --batch -l src/test/lisp/init.el -l src/test/lisp/all-tests.el + cd $(mkfile_dir) && $(EMACS) -Q --batch -f toggle-debug-on-error -l src/test/lisp/init.el -l src/test/lisp/init-malabar.el -l src/test/lisp/all-tests.el + diff --git a/src/main/lisp/malabar-ede-gradle.el b/src/main/lisp/malabar-ede-gradle.el index 3432e5d..ea35193 100755 --- a/src/main/lisp/malabar-ede-gradle.el +++ b/src/main/lisp/malabar-ede-gradle.el @@ -205,7 +205,7 @@ (ede-project-autoload "malabar-gradle" :name "MALABAR GRADLE" :file 'ede/gradle - :proj-file "build.gradle" + :proj-file "build.gradle" ;:proj-root 'ede-maven2-project-root :load-type 'malabar-gradle-load :class-sym 'ede-malabar-gradle-project diff --git a/src/main/lisp/malabar-ede-maven.el b/src/main/lisp/malabar-ede-maven.el index 52e6518..dd818f9 100755 --- a/src/main/lisp/malabar-ede-maven.el +++ b/src/main/lisp/malabar-ede-maven.el @@ -205,7 +205,7 @@ (ede-project-autoload "malabar-maven2" :name "MALABAR MAVEN2" :file 'ede/maven2 - ;:proj-file "pom.xml" + :proj-file "pom.xml" ;:proj-root 'ede-maven2-project-root ;:load-type 'malabar-maven2-load ;:class-sym 'ede-malabar-maven2-project diff --git a/src/main/lisp/malabar-import.el b/src/main/lisp/malabar-import.el index 7c49624..4028f9c 100755 --- a/src/main/lisp/malabar-import.el +++ b/src/main/lisp/malabar-import.el @@ -234,7 +234,7 @@ in the list." (let ((a-package (malabar-get-package-of class-a)) (b-package (malabar-get-package-of class-b))) (let ((a-package-successors (member a-package malabar-import-precedence-order)) - (b-package-successors (member b-package malabar-import-precedence-order))) + (b-package-successors (member b-package malabar-import-precedence-order))) (or (member b-package a-package-successors) (and a-package-successors (null b-package-successors)))))) diff --git a/src/main/lisp/malabar-mode.el b/src/main/lisp/malabar-mode.el index d218603..f098d3e 100755 --- a/src/main/lisp/malabar-mode.el +++ b/src/main/lisp/malabar-mode.el @@ -41,6 +41,7 @@ (eval-when-compile (require 'cl)) (require 'gud) +(require 'dash) (require 'inf-groovy) ;(require 'semantic/db-javap) (require 'url-vars) @@ -54,8 +55,8 @@ (require 'malabar-project) (require 'malabar-reflection) (require 'malabar-http) -(require 'malabar-ede-maven) -(require 'malabar-ede-gradle) +;(require 'malabar-ede-maven) +;(require 'malabar-ede-gradle) (require 'malabar-mode-autoloads) diff --git a/src/test/lisp/elk-test.el b/src/test/lisp/elk-test.el old mode 100755 new mode 100644 index eef77bc..10e9ed1 --- a/src/test/lisp/elk-test.el +++ b/src/test/lisp/elk-test.el @@ -1,12 +1,13 @@ ;;; elk-test.el --- Emacs Lisp testing framework ;; -;; Copyright (C) 2006,2008 Nikolaj Schumacher +;; Copyright (C) 2006-2009 Nikolaj Schumacher ;; ;; Author: Nikolaj Schumacher -;; Version: 0.3 +;; Version: 0.3.2 ;; Keywords: lisp ;; URL: http://nschum.de/src/emacs/guess-style/ -;; Compatibility: GNU Emacs 22.x +;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x +;; Package-Requires: ((fringe-helper "0.1.1")) ;; ;; This file is NOT part of GNU Emacs. ;; @@ -25,7 +26,7 @@ ;; ;;; Commentary: ;; -;; elk-test requires fringe-helper.el, which is available at: +;; For best visualization, install fringe-helper, which is available at: ;; http://nschum.de/src/emacs/fringe-helper/ ;; ;; Use `deftest' to define a test and `elk-test-group' to define test groups. @@ -83,6 +84,12 @@ ;; ;;; Change Log: ;; +;; 2009-03-21 (0.3.2) +;; Made fringe-helper dependency optional. +;; Removed dependency on CL functions. +;; Fixed deftest highlighting. +;; Added `elk-test-result-context-lines'. +;; ;; 2008-06-15 (0.3) ;; Added `elk-test-result-follow-mode'. ;; Switched to using button package for links. @@ -110,7 +117,7 @@ ;;; Code: (eval-when-compile (require 'cl)) -(require 'fringe-helper) +(require 'fringe-helper nil t) (require 'newcomment) (require 'eldoc) (require 'compile) @@ -186,6 +193,12 @@ :type '(choice (const :tag "Off" nil) (const :tag "On" t))) +(defcustom elk-test-result-context-lines compilation-context-lines + "Display this many lines of leading context before the current message. +See `compilation-context-lines'." + :group 'test-case + :type '(choice integer (const :tag "No window scrolling" nil))) + (defvar elk-test-result-mode-map (let ((keymap (make-sparse-keymap))) (define-key keymap "q" 'bury-buffer) @@ -199,6 +212,9 @@ "Remove all tests from memory." (setq elk-test-alist nil)) +(defsubst elk-test-mapcan (func sequence) + (apply 'nconc (mapcar func sequence))) + (defun elk-test-run (name &optional string-result) "Run the test case defined as NAME. The result is a list of errors strings, unless STRING-RESULT is set, in which @@ -211,9 +227,9 @@ case a message describing the errors or success is displayed and returned." (error "Undefined test <%s>" name) (setq error-list (if (equal (car test-or-group) 'group) ;; is test group - (mapcar 'elk-test-run (cdr test-or-group)) + (elk-test-mapcan 'elk-test-run (cdr test-or-group)) ;; is simple test - (cons name (elk-test-run-internal test-or-group)))) + (elk-test-run-internal test-or-group))) (if (or string-result (interactive-p)) (message (if error-list (mapconcat 'identity error-list "\n") @@ -422,7 +438,7 @@ The resulting group can be run by calling `elk-test-run' with parameter NAME." name)) (defconst elk-test-font-lock-keywords - `(("(\\_<\\(deftest\\)\\_>" 1 'font-lock-deftest) + `(("(\\_<\\(deftest\\)\\_>" 1 'elk-test-deftest) (,(concat "(\\_<" (regexp-opt '("assert-equal" "assert-eq" "assert-eql" "assert-nonnil" "assert-t" "assert-nil" "assert-error" "assert-that") t) @@ -493,25 +509,26 @@ If the state is set to 'success, a hook will be installed to switch to :visible `(buffer-live-p ,buf))) (elk-test-buffer-list)) "-" . - ,(mapcan (lambda (buffer-errors) - (mapcar (lambda (err) - (vector - (concat (cadr err) " - " - (elk-test-shorten-string (cdar (cddr err)))) - `(lambda () - (interactive) - (push-mark) - (switch-to-buffer ,(car buffer-errors)) - (goto-char ,(caar (cddr err)))))) - (cdr buffer-errors))) - errors))) + ,(elk-test-mapcan + (lambda (buffer-errors) + (mapcar (lambda (err) + (vector + (concat (cadr err) " - " + (elk-test-shorten-string (cdar (cddr err)))) + `(lambda () + (interactive) + (push-mark) + (switch-to-buffer ,(car buffer-errors)) + (goto-char ,(caar (cddr err)))))) + (cdr buffer-errors))) + errors))) (easy-menu-add elk-test-menu)) (defun elk-test-buffer-list () "List all buffers in `elk-test-mode'." - (mapcan (lambda (b) (when (with-current-buffer b - (eq major-mode 'elk-test-mode)) - (cons b nil))) + (elk-test-mapcan (lambda (b) (when (with-current-buffer b + (eq major-mode 'elk-test-mode)) + (cons b nil))) (buffer-list))) (defun elk-test-run-all-buffers (&optional show-results) @@ -539,11 +556,17 @@ If the state is set to 'success, a hook will be installed to switch to (defvar elk-test-fringe-regions nil) (make-variable-buffer-local 'elk-test-fringe-regions) +(defvar elk-test-regions nil) +(make-variable-buffer-local 'elk-test-regions) + (defun elk-test-unmark-failures () "Remove all highlighting from buffer." (interactive) - (while elk-test-fringe-regions - (fringe-helper-remove (pop elk-test-fringe-regions)))) + (when (fboundp 'fringe-helper-remove) + (mapc 'fringe-helper-remove elk-test-fringe-regions)) + (mapc 'delete-overlay elk-test-regions) + (setq elk-test-fringe-regions nil + elk-test-regions nil)) (defun elk-test-mark-failures (failures which-side) "Highlight failed tests." @@ -551,16 +574,16 @@ If the state is set to 'success, a hook will be installed to switch to (save-excursion (dolist (failure failures) (dolist (form (cddr failure)) - (when (and which-side window-system) - (push (fringe-helper-insert-region (caar form) (cdar form) - 'filled-square which-side - 'elk-test-fringe) - elk-test-fringe-regions)) + (and which-side window-system (fboundp 'fringe-helper-insert-region) + (push (fringe-helper-insert-region (caar form) (cdar form) + 'filled-square which-side + 'elk-test-fringe) + elk-test-fringe-regions)) (push (make-overlay (caar form) (cdar form)) - elk-test-fringe-regions) - (overlay-put (car elk-test-fringe-regions) + elk-test-regions) + (overlay-put (car elk-test-regions) 'elk-test-error (cdr form)) - (overlay-put (car elk-test-fringe-regions) + (overlay-put (car elk-test-regions) 'face 'elk-test-failed-region))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -644,7 +667,8 @@ This function is suitable for use as `eldoc-documentation-function'." (defun elk-test-jump (buffer region from) (let ((msg (copy-marker from)) (mk (make-marker)) - (end-mk (make-marker))) + (end-mk (make-marker)) + (compilation-context-lines elk-test-result-context-lines)) (set-marker mk (car region) buffer) (set-marker end-mk (cdr region) buffer) (compilation-goto-locus msg mk end-mk) diff --git a/src/test/lisp/init-malabar.el b/src/test/lisp/init-malabar.el new file mode 100644 index 0000000..0827b50 --- /dev/null +++ b/src/test/lisp/init-malabar.el @@ -0,0 +1,5 @@ +(load-file "src/main/lisp/malabar-mode.el") +(activate-malabar-mode) +(malabar-run-groovy) + +(find-file "src/test/project/basic/src/main/java/com/software_ninja/App.java") diff --git a/src/test/lisp/malabar-mode.elk b/src/test/lisp/malabar-mode.elk new file mode 100644 index 0000000..714b4ab --- /dev/null +++ b/src/test/lisp/malabar-mode.elk @@ -0,0 +1,68 @@ +;;; -*- emacs-lisp -*- +;; Copyright (c) 2009 Espen Wiborg +;; +;; 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 2 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, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +;; 02110-1301 USA. +;; + +;; Stub +(provide 'semantic) + +(deftest "buffer name" + (with-current-buffer (get-buffer "App.java") + (assert-equal "App.java" (buffer-name)))) + +(deftest "malabar-project variable malabar-mode-project-name" + (with-current-buffer (get-buffer "App.java") + (assert-equal "basic" malabar-mode-project-name))) + +(deftest "malabar-project variable malabar-mode-project-manager" + (with-current-buffer (get-buffer "App.java") + (assert-equal "maven" malabar-mode-project-manager))) + +(deftest "malabar-project variable malabar-mode-project-dir" + (with-current-buffer (get-buffer "App.java") + (assert-equal (expand-file-name "src/test/project/basic/" (getenv "PWD")) + (expand-file-name malabar-mode-project-dir)))) + +(deftest "malabar-project variable malabar-mode-project-parser" + (with-current-buffer (get-buffer "App.java") + (assert-equal "java" malabar-mode-project-parser))) + + + + +(deftest "malabar-fully-qualified-class-name-kill-ring-save" + (with-current-buffer (get-buffer "App.java") + (assert-equal "Copied com.software_ninja.App" (malabar-fully-qualified-class-name-kill-ring-save)))) + + +;;; +;;; HTTP Stuff +;;; + +(deftest "malabar-http-compile-file App.java" + (with-current-buffer (get-buffer "App.java") + (let ((result-buffer (malabar-http-compile-file))) + (with-current-buffer result-buffer + (assert-equal "" (buffer-string)))))) + + +(deftest "malabar-http-compile-file App.java fail" + (with-current-buffer (get-buffer "App.java") + + (let ((result-buffer (malabar-http-compile-file))) + (with-current-buffer result-buffer + (assert-equal "" (buffer-string))))))