[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3f63fab 11/28: Add local coverage configuration.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 3f63fab 11/28: Add local coverage configuration. |
Date: |
Tue, 05 May 2015 11:10:18 +0000 |
branch: master
commit 3f63fabe8fbb5135448bb5eb495d2cb9d58e1a68
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Add local coverage configuration.
---
.gitignore | 1 +
Makefile | 14 +++++-
test/{test-helper.el => ci-coverage.el} | 0
test/local-coverage.el | 42 ++++++++++++++++++
test/parse-coverage.js | 72 +++++++++++++++++++++++++++++++
5 files changed, 127 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index d0147ab..a269508 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.elc
.cask/
/benchmark/logs/
+/test/coverage/
diff --git a/Makefile b/Makefile
index f322a81..868bd2a 100644
--- a/Makefile
+++ b/Makefile
@@ -30,8 +30,18 @@ test: ${DEPENDENCIES}
-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
diff --git a/test/test-helper.el b/test/ci-coverage.el
similarity index 100%
rename from test/test-helper.el
rename to test/ci-coverage.el
diff --git a/test/local-coverage.el b/test/local-coverage.el
new file mode 100644
index 0000000..7d6ee0d
--- /dev/null
+++ b/test/local-coverage.el
@@ -0,0 +1,42 @@
+(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)
diff --git a/test/parse-coverage.js b/test/parse-coverage.js
new file mode 100755
index 0000000..e65eab0
--- /dev/null
+++ b/test/parse-coverage.js
@@ -0,0 +1,72 @@
+#!/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();
- [elpa] master fd5b9e1 05/28: Add tests for versions and disabling., (continued)
- [elpa] master fd5b9e1 05/28: Add tests for versions and disabling., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 85ff3ef 13/28: Trailing whitespace, empty arrays, empty strings., Jackson Ray Hamilton, 2015/05/05
- [elpa] master f11f97f 09/28: Make default colors more like font-lock's., Jackson Ray Hamilton, 2015/05/05
- [elpa] master a7f5970 04/28: Remove unused function., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 9873030 08/28: Use real keywords., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 0888e06 01/28: Use Cask and Coveralls., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 202ca74 15/28: Drop `subr-x' dependency., Jackson Ray Hamilton, 2015/05/05
- [elpa] master dd3fe3c 06/28: Fix badges., Jackson Ray Hamilton, 2015/05/05
- [elpa] master fb53884 17/28: Update README., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 52da59c 18/28: Bust cache., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 3f63fab 11/28: Add local coverage configuration.,
Jackson Ray Hamilton <=
- [elpa] master 158fd83 16/28: Test the trimming function., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 0c20edf 14/28: Add coverage for missing lines., Jackson Ray Hamilton, 2015/05/05
- [elpa] master d116055 12/28: Fix original-maximum-face restoration bug., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 1b6f6fb 21/28: Cleanup README., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 5dd3035 19/28: Refactor trim functions., Jackson Ray Hamilton, 2015/05/05
- [elpa] master f8cfd37 22/28: Double-space., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 64852e7 24/28: Update library headers., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 55ca15a 23/28: Guard against excessively lenghty nodes., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 8f1af4a 20/28: Update library header., Jackson Ray Hamilton, 2015/05/05
- [elpa] master dbddc45 26/28: Reimplement coverage reporter in elisp., Jackson Ray Hamilton, 2015/05/05