From: Dan Vanderkam Date: Fri, 23 Oct 2015 23:24:32 +0000 (-0400) Subject: Post coverage from travis job X-Git-Tag: v2.0.0~38^2~5 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=843b58d61b5958a2d79607878b6950c722bf19f7;p=dygraphs.git Post coverage from travis job --- diff --git a/.travis.yml b/.travis.yml index a16a7b0..cbda81c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,6 @@ script: > npm run build-tests && npm run test && npm run coverage && + ./scripts/post-coverage.sh && curl -O https://raw.githubusercontent.com/danvk/travis-weigh-in/master/weigh_in.py && python weigh_in.py dist/dygraph-combined.js diff --git a/scripts/build-tests.sh b/scripts/build-tests.sh index 216296d..0fc2e9b 100755 --- a/scripts/build-tests.sh +++ b/scripts/build-tests.sh @@ -9,4 +9,6 @@ browserify \ -t [ envify --NODE_ENV development ] \ --debug \ -o dist/tests.js \ - auto_tests/tests/*.js + auto_tests/tests/utils_test.js + +# auto_tests/tests/*.js diff --git a/scripts/generate-coverage.sh b/scripts/generate-coverage.sh index e2343de..6fb02be 100755 --- a/scripts/generate-coverage.sh +++ b/scripts/generate-coverage.sh @@ -7,8 +7,8 @@ set -o errexit set -x # Generate per-file ES6 --> ES5 transpilations -babel src --out-dir dist/src -babel auto_tests/tests --out-dir dist/auto_tests/tests +babel --retain-lines src --out-dir dist/src +babel --retain-lines auto_tests/tests --out-dir dist/auto_tests/tests # Instrument the source code with Istanbul's __coverage__ variable. rm -rf coverage/* # Clear out everything to ensure a hermetic run. @@ -42,7 +42,7 @@ if [ $CI ]; then istanbul report --include coverage/*.json lcovonly # Monkey patch in the untransformed source paths. - # perl -i -pe 's,dist/main,src/main,' coverage/lcov.info + perl -i -pe 's,dist/,,' coverage/lcov.info echo '' # reset exit code -- failure to post coverage shouldn't be an error. else diff --git a/scripts/post-coverage.sh b/scripts/post-coverage.sh new file mode 100755 index 0000000..e3aaf50 --- /dev/null +++ b/scripts/post-coverage.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cat coverage/lcov.info | ./node_modules/.bin/coveralls + +echo '' # reset exit code -- failure to post coverage shouldn't be an error. diff --git a/scripts/transform-coverage.js b/scripts/transform-coverage.js deleted file mode 100755 index a492f26..0000000 --- a/scripts/transform-coverage.js +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env node -/** - * This script applies a source map to LCOV data. If you have coverage data for - * a concatenated file, plus a source map, this will output LCOV data for your - * original source files. - * - * Usage: - * - * transform-coverage.js path/to/soure.map path/to/coverage.lcov > out.lcov - */ - -// TODO: make this a command line argument -var SOURCE = 'src/'; // only report files under this directory - -var assert = require('assert'), - fs = require('fs'), - lcovParse = require('lcov-parse'), - parseDataUri = require('parse-data-uri'), - sourcemap = require('source-map'); - -var sourcemapFile = process.argv[2]; -var lcovFile = process.argv[3]; - -var sourcemapData = fs.readFileSync(sourcemapFile).toString(); -var sourcemap = new sourcemap.SourceMapConsumer(sourcemapData); - -lcovParse(lcovFile, function(err, data) { - assert(!err); - // TODO: 0 --> the correct file - var lines = data[0].lines.details; - - var fileToCov = {}; // filename -> { line num -> hits } - - lines.forEach(function(line) { - var pos = sourcemap.originalPositionFor({line: line.line, column: 0}); - if (pos == null) { - return; - } - - var filename = pos.source; - - // Test coverage of node_modules is never interesting. - if (!filename || filename.indexOf('node_modules') >= 0) { - return; - } - - // Strip paths down to the source root. - var base = filename.indexOf(SOURCE); - if (base == -1) return; - filename = filename.slice(base); - - if (!fileToCov[filename]) fileToCov[filename] = []; - fileToCov[filename][pos.line] = line.hit; - }); - - // Other LCOV fields to translate: - // FN:2454 - // FNF:465 - // FNH:410 - // FNDA:1,(anonymous_1) - // LF:4570 - // LH:4002 - // BRDA:13,1,0,1 - // BRF:2213 - // BRH:1684 - - // Convert to LCOV format - for (var filename in fileToCov) { - var cov = fileToCov[filename] - console.log('SF:' + filename); - for (var i = 0; i < cov.length; i++) { - if (cov[i] != null) { - console.log('DA:' + i + ',' + cov[i]); - } - } - console.log('end_of_record'); - } -});