-L . \
-l ert \
-l ert-async \
- -l test/test-helper.el \
+ -l test/ci-coverage.el \
-l test/context-coloring-test.el \
-f ert-run-tests-batch-and-exit
-.PHONY: all bench compile uncompile clean test
+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-test.el \
+ -f ert-run-tests-batch-and-exit
+
+.PHONY: all bench compile uncompile clean test cover
--- /dev/null
+(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)
--- /dev/null
+#!/usr/bin/env node
+
+// Copyright (C) 2014-2015 Free Software Foundation, Inc.
+
+// 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/>.
+
+'use strict';
+
+var padRight = function (value, padding) {
+ return value + new Array(Math.max(0, padding - String(value).length) + 1).join(' ');
+};
+
+var formatSourceFile = function (sourceFile) {
+ var sourceLines = sourceFile.source.split('\n');
+ var results = [
+ padRight('Hits', 5) + ' | Source',
+ new Array(80 + 1).join('-')
+ ];
+ var linesHit = 0;
+ var linesHittable = 0;
+ results = results.concat(sourceFile.coverage.map(function (hits, index) {
+ var hitsValue = hits === null ? 'N/A' : hits;
+ var column = hits === 0 ? '~' : '|';
+ if (hits > 0) {
+ linesHit += 1;
+ }
+ if (hits !== null) {
+ linesHittable += 1;
+ }
+ return padRight(hitsValue, 5) + ' ' + column + ' ' + sourceLines[index];
+ }));
+ results = results.concat([
+ '',
+ 'Lines: ' + linesHit + ' / ' + linesHittable,
+ 'Coverage: ' + (Math.round(linesHit / linesHittable * 10000) / 100) + '%'
+ ]);
+ return results.join('\n');
+};
+
+var format = function (json) {
+ return json.source_files.map(formatSourceFile).join('\n');
+};
+
+var read = function () {
+ var whole = '';
+
+ process.stdin.setEncoding('utf8');
+
+ process.stdin.on('readable', function () {
+ var chunk = process.stdin.read();
+ if (chunk !== null) {
+ whole += chunk;
+ }
+ });
+
+ process.stdin.on('end', function () {
+ console.log(format(JSON.parse(whole)));
+ });
+};
+
+read();