1 ;;; context-coloring-coverage.el --- Test coverage for context coloring -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ;; Test coverage support for context coloring.
24 ;; Use with `make cover'.
31 (defconst context-coloring-coverage-directory
32 (file-name-directory (or load-file-name buffer-file-name))
33 "This file's directory.")
35 (defun context-coloring-coverage-resolve-path (path)
36 "Resolve PATH from this file's directory."
37 (expand-file-name path context-coloring-coverage-directory))
39 (defconst context-coloring-coverage-output-file-prefix
40 (format-time-string "%s"))
42 (defconst context-coloring-coverage-output-directory
43 (context-coloring-coverage-resolve-path "./coverage/"))
45 (defconst context-coloring-coverage-output-file
46 (concat context-coloring-coverage-output-directory
47 context-coloring-coverage-output-file-prefix ".json"))
49 (defconst context-coloring-coverage-report-file
50 (concat context-coloring-coverage-output-directory
51 context-coloring-coverage-output-file-prefix ".txt"))
53 (defconst context-coloring-coverage-parser
54 (concat "node " (context-coloring-coverage-resolve-path "./parse-coverage.js")))
56 (defun context-coloring-coverage-local-init ()
57 "Initialize test coverage for local viewing."
58 (make-directory context-coloring-coverage-output-directory t)
59 (setq undercover-force-coverage t)
60 (setenv "COVERALLS_REPO_TOKEN" "noop")
61 (undercover "context-coloring.el"
62 (:report-file context-coloring-coverage-output-file))
66 (let* ((output-buffer (get-buffer-create "*parsed coverage*")))
67 (call-process-shell-command
68 context-coloring-coverage-parser
69 context-coloring-coverage-output-file
71 (with-current-buffer output-buffer
72 (princ (buffer-substring-no-properties (point-min) (point-max)))
73 (write-file context-coloring-coverage-report-file))))
75 (require 'context-coloring))
77 (defun context-coloring-coverage-ci-init ()
78 "Initialize test coverage for continuous integration."
79 (undercover "context-coloring.el")
80 (require 'context-coloring))
82 (provide 'context-coloring-coverage)
84 ;; context-coloring-coverage.el ends here