]> code.delx.au - gnu-emacs-elpa/commitdiff
Refactor coverage.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Tue, 5 May 2015 04:13:00 +0000 (21:13 -0700)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Tue, 5 May 2015 04:13:00 +0000 (21:13 -0700)
Makefile
test/ci-coverage.el [deleted file]
test/context-coloring-coverage.el [new file with mode: 0644]
test/local-coverage.el [deleted file]

index 868bd2a8dbb3df5b9401013045b7bf69da941d4c..bd82b883addfc194897e9c657a83e5e8f5022cd4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -30,17 +30,18 @@ test: ${DEPENDENCIES}
        -L . \
        -l ert \
        -l ert-async \
-       -l test/ci-coverage.el \
+       -l test/context-coloring-coverage.el \
+       -f context-coloring-coverage-ci-init \
        -l test/context-coloring-test.el \
        -f ert-run-tests-batch-and-exit
 
 cover: ${DEPENDENCIES}
-       COVERALLS_REPO_TOKEN="noop" \
        ${CASK} exec ${EMACS} -Q -batch \
        -L . \
        -l ert \
        -l ert-async \
-       -l test/local-coverage.el \
+       -l test/context-coloring-coverage.el \
+       -f context-coloring-coverage-local-init \
        -l test/context-coloring-test.el \
        -f ert-run-tests-batch-and-exit
 
diff --git a/test/ci-coverage.el b/test/ci-coverage.el
deleted file mode 100644 (file)
index 1c97075..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-(require 'undercover)
-(undercover "context-coloring.el")
-(require 'context-coloring)
diff --git a/test/context-coloring-coverage.el b/test/context-coloring-coverage.el
new file mode 100644 (file)
index 0000000..0383ac4
--- /dev/null
@@ -0,0 +1,84 @@
+;;; context-coloring-coverage.el --- Test coverage for context coloring  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2014-2015  Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; 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:
+
+;; Test coverage support for context coloring.
+
+;; Use with `make cover'.
+
+;;; Code:
+
+(require 'undercover)
+
+
+(defconst context-coloring-coverage-directory
+  (file-name-directory (or load-file-name buffer-file-name))
+  "This file's directory.")
+
+(defun context-coloring-coverage-resolve-path (path)
+  "Resolve PATH from this file's directory."
+  (expand-file-name path context-coloring-coverage-directory))
+
+(defconst context-coloring-coverage-output-file-prefix
+  (format-time-string "%s"))
+
+(defconst context-coloring-coverage-output-directory
+  (context-coloring-coverage-resolve-path "./coverage/"))
+
+(defconst context-coloring-coverage-output-file
+  (concat context-coloring-coverage-output-directory
+          context-coloring-coverage-output-file-prefix ".json"))
+
+(defconst context-coloring-coverage-report-file
+  (concat context-coloring-coverage-output-directory
+          context-coloring-coverage-output-file-prefix ".txt"))
+
+(defconst context-coloring-coverage-parser
+  (concat "node " (context-coloring-coverage-resolve-path "./parse-coverage.js")))
+
+(defun context-coloring-coverage-local-init ()
+  "Initialize test coverage for local viewing."
+  (make-directory context-coloring-coverage-output-directory t)
+  (setq undercover-force-coverage t)
+  (setenv "COVERALLS_REPO_TOKEN" "noop")
+  (undercover "context-coloring.el"
+              (:report-file context-coloring-coverage-output-file))
+  (add-hook
+   'kill-emacs-hook
+   (lambda ()
+     (let* ((output-buffer (get-buffer-create "*parsed coverage*")))
+       (call-process-shell-command
+        context-coloring-coverage-parser
+        context-coloring-coverage-output-file
+        output-buffer)
+       (with-current-buffer output-buffer
+         (princ (buffer-substring-no-properties (point-min) (point-max)))
+         (write-file context-coloring-coverage-report-file))))
+   t)
+  (require 'context-coloring))
+
+(defun context-coloring-coverage-ci-init ()
+  "Initialize test coverage for continuous integration."
+  (undercover "context-coloring.el")
+  (require 'context-coloring))
+
+(provide 'context-coloring-coverage)
+
+;; context-coloring-coverage.el ends here
diff --git a/test/local-coverage.el b/test/local-coverage.el
deleted file mode 100644 (file)
index 7d6ee0d..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-(defconst context-coloring-test-directory
-  (file-name-directory (or load-file-name buffer-file-name))
-  "This file's directory.")
-
-(defun context-coloring-test-resolve-path (path)
-  "Resolve PATH from this file's directory."
-  (expand-file-name path context-coloring-test-directory))
-
-(defconst context-coloring-coverage-output-file-prefix
-  (format-time-string "%s"))
-
-(defconst context-coloring-coverage-output-file
-  (context-coloring-test-resolve-path
-   (concat "./coverage/" context-coloring-coverage-output-file-prefix ".json")))
-
-(defconst context-coloring-coverage-report-file
-  (context-coloring-test-resolve-path
-   (concat "./coverage/" context-coloring-coverage-output-file-prefix ".txt")))
-
-(defconst context-coloring-test-coverage-parser
-  (concat "node " (context-coloring-test-resolve-path "./parse-coverage.js")))
-
-(require 'undercover)
-(setq undercover-force-coverage t)
-(make-directory (context-coloring-test-resolve-path "./coverage/") t)
-(undercover "context-coloring.el"
-            (:report-file context-coloring-coverage-output-file))
-
-(add-hook
- 'kill-emacs-hook
- (lambda ()
-   (let* ((output-buffer (get-buffer-create "*parsed coverage*")))
-     (call-process-shell-command
-      context-coloring-test-coverage-parser
-      context-coloring-coverage-output-file
-      output-buffer)
-     (with-current-buffer output-buffer
-       (princ (buffer-substring-no-properties (point-min) (point-max)))
-       (write-file context-coloring-coverage-report-file))))
- t)
-
-(require 'context-coloring)