mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Implement code coverage without grunt-qunit-istanbul
This commit is contained in:
parent
80e8065e2f
commit
aaec7c9526
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,7 +3,7 @@ node_modules
|
|||||||
build/
|
build/
|
||||||
sftp-config.json
|
sftp-config.json
|
||||||
coverage/
|
coverage/
|
||||||
temp/
|
instrumented/
|
||||||
.idea
|
.idea
|
||||||
/nbproject/private/
|
/nbproject/private/
|
||||||
.directory
|
.directory
|
||||||
|
51
Gruntfile.js
51
Gruntfile.js
@ -1,6 +1,7 @@
|
|||||||
/* global module */
|
/* global module */
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
|
var dateFormat = require('dateformat');
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
grunt.loadNpmTasks("grunt-contrib-compress");
|
grunt.loadNpmTasks("grunt-contrib-compress");
|
||||||
@ -13,6 +14,7 @@ module.exports = function(grunt) {
|
|||||||
grunt.loadNpmTasks("grunt-eslint");
|
grunt.loadNpmTasks("grunt-eslint");
|
||||||
grunt.loadNpmTasks("grunt-git-describe");
|
grunt.loadNpmTasks("grunt-git-describe");
|
||||||
grunt.loadNpmTasks('grunt-text-replace');
|
grunt.loadNpmTasks('grunt-text-replace');
|
||||||
|
grunt.loadNpmTasks('grunt-istanbul');
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
var packageJson = grunt.file.readJSON("package.json"),
|
var packageJson = grunt.file.readJSON("package.json"),
|
||||||
@ -21,6 +23,7 @@ module.exports = function(grunt) {
|
|||||||
packageDirName = "openseadragon-bin-" + packageJson.version,
|
packageDirName = "openseadragon-bin-" + packageJson.version,
|
||||||
packageDir = "build/" + packageDirName + "/",
|
packageDir = "build/" + packageDirName + "/",
|
||||||
releaseRoot = "../site-build/built-openseadragon/",
|
releaseRoot = "../site-build/built-openseadragon/",
|
||||||
|
coverageDir = 'coverage/' + dateFormat(new Date(), 'yyyymmdd-HHMMss'),
|
||||||
sources = [
|
sources = [
|
||||||
"src/openseadragon.js",
|
"src/openseadragon.js",
|
||||||
"src/fullscreen.js",
|
"src/fullscreen.js",
|
||||||
@ -83,7 +86,7 @@ module.exports = function(grunt) {
|
|||||||
clean: {
|
clean: {
|
||||||
build: ["build"],
|
build: ["build"],
|
||||||
package: [packageDir],
|
package: [packageDir],
|
||||||
coverage: ["coverage"],
|
coverage: ["instrumented"],
|
||||||
release: {
|
release: {
|
||||||
src: [releaseRoot],
|
src: [releaseRoot],
|
||||||
options: {
|
options: {
|
||||||
@ -154,7 +157,8 @@ module.exports = function(grunt) {
|
|||||||
qunit: {
|
qunit: {
|
||||||
normal: {
|
normal: {
|
||||||
options: {
|
options: {
|
||||||
urls: [ "http://localhost:8000/test/test.html" ]
|
urls: [ "http://localhost:8000/test/test.html" ],
|
||||||
|
timeout: 500000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
coverage: {
|
coverage: {
|
||||||
@ -162,11 +166,13 @@ module.exports = function(grunt) {
|
|||||||
urls: [ "http://localhost:8000/test/coverage.html" ],
|
urls: [ "http://localhost:8000/test/coverage.html" ],
|
||||||
coverage: {
|
coverage: {
|
||||||
src: ['src/*.js'],
|
src: ['src/*.js'],
|
||||||
htmlReport: 'coverage/html/',
|
htmlReport: coverageDir + '/html/',
|
||||||
instrumentedFiles: 'temp/',
|
instrumentedFiles: 'instrumented/src/',
|
||||||
baseUrl: '.',
|
baseUrl: '.',
|
||||||
disposeCollector: true
|
disposeCollector: true
|
||||||
}
|
},
|
||||||
|
inject: 'test/helpers/phantom-bridge.js',
|
||||||
|
timeout: 500000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
all: {
|
all: {
|
||||||
@ -199,7 +205,38 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
build: {}
|
build: {}
|
||||||
},
|
},
|
||||||
gitInfo: "unknown"
|
gitInfo: "unknown",
|
||||||
|
instrument: {
|
||||||
|
files: sources,
|
||||||
|
options: {
|
||||||
|
lazy: false,
|
||||||
|
basePath: 'instrumented/'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
reloadTasks: {
|
||||||
|
rootPath: "instrumented/src/"
|
||||||
|
},
|
||||||
|
storeCoverage: {
|
||||||
|
options: {
|
||||||
|
dir: coverageDir,
|
||||||
|
'include-all-sources': true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
makeReport: {
|
||||||
|
src: "coverage/**/*.json",
|
||||||
|
options: {
|
||||||
|
type: [ "lcov", "html" ],
|
||||||
|
dir: coverageDir,
|
||||||
|
print: "detail"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.event.on("qunit.coverage", function(coverage) {
|
||||||
|
var reportPath = coverageDir + "/coverage.json";
|
||||||
|
|
||||||
|
// Create the coverage file
|
||||||
|
grunt.file.write(reportPath, JSON.stringify(coverage));
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
@ -287,7 +324,7 @@ module.exports = function(grunt) {
|
|||||||
// ----------
|
// ----------
|
||||||
// Coverage task.
|
// Coverage task.
|
||||||
// Outputs unit test code coverage report.
|
// Outputs unit test code coverage report.
|
||||||
grunt.registerTask("coverage", ["clean:coverage", "connect", "qunit:coverage"]);
|
grunt.registerTask("coverage", ["clean:coverage", "instrument", "connect", "qunit:coverage", "makeReport"]);
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Package task.
|
// Package task.
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
"grunt-contrib-watch": "^1.0.0",
|
"grunt-contrib-watch": "^1.0.0",
|
||||||
"grunt-eslint": "^19.0.0",
|
"grunt-eslint": "^19.0.0",
|
||||||
"grunt-git-describe": "^2.3.2",
|
"grunt-git-describe": "^2.3.2",
|
||||||
|
"grunt-istanbul": "^0.8.0",
|
||||||
"grunt-text-replace": "^0.4.0",
|
"grunt-text-replace": "^0.4.0",
|
||||||
"qunitjs": "2.4.1"
|
"qunitjs": "2.4.1"
|
||||||
},
|
},
|
||||||
|
@ -21,40 +21,40 @@
|
|||||||
<script src="/test/lib/jquery.simulate.js"></script>
|
<script src="/test/lib/jquery.simulate.js"></script>
|
||||||
|
|
||||||
<!-- OpenSeadragon sources -->
|
<!-- OpenSeadragon sources -->
|
||||||
<script src="/src/openseadragon.js"></script>
|
<script src="/instrumented/src/openseadragon.js"></script>
|
||||||
<script src="/src/fullscreen.js"></script>
|
<script src="/instrumented/src/fullscreen.js"></script>
|
||||||
<script src="/src/eventsource.js"></script>
|
<script src="/instrumented/src/eventsource.js"></script>
|
||||||
<script src="/src/mousetracker.js"></script>
|
<script src="/instrumented/src/mousetracker.js"></script>
|
||||||
<script src="/src/control.js"></script>
|
<script src="/instrumented/src/control.js"></script>
|
||||||
<script src="/src/controldock.js"></script>
|
<script src="/instrumented/src/controldock.js"></script>
|
||||||
<script src="/src/placement.js"></script>
|
<script src="/instrumented/src/placement.js"></script>
|
||||||
<script src="/src/viewer.js"></script>
|
<script src="/instrumented/src/viewer.js"></script>
|
||||||
<script src="/src/navigator.js"></script>
|
<script src="/instrumented/src/navigator.js"></script>
|
||||||
<script src="/src/strings.js"></script>
|
<script src="/instrumented/src/strings.js"></script>
|
||||||
<script src="/src/point.js"></script>
|
<script src="/instrumented/src/point.js"></script>
|
||||||
<script src="/src/tilesource.js"></script>
|
<script src="/instrumented/src/tilesource.js"></script>
|
||||||
<script src="/src/dzitilesource.js"></script>
|
<script src="/instrumented/src/dzitilesource.js"></script>
|
||||||
<script src="/src/iiiftilesource.js"></script>
|
<script src="/instrumented/src/iiiftilesource.js"></script>
|
||||||
<script src="/src/osmtilesource.js"></script>
|
<script src="/instrumented/src/osmtilesource.js"></script>
|
||||||
<script src="/src/tmstilesource.js"></script>
|
<script src="/instrumented/src/tmstilesource.js"></script>
|
||||||
<script src="/src/zoomifytilesource.js"></script>
|
<script src="/instrumented/src/zoomifytilesource.js"></script>
|
||||||
<script src="/src/legacytilesource.js"></script>
|
<script src="/instrumented/src/legacytilesource.js"></script>
|
||||||
<script src="/src/imagetilesource.js"></script>
|
<script src="/instrumented/src/imagetilesource.js"></script>
|
||||||
<script src="/src/tilesourcecollection.js"></script>
|
<script src="/instrumented/src/tilesourcecollection.js"></script>
|
||||||
<script src="/src/button.js"></script>
|
<script src="/instrumented/src/button.js"></script>
|
||||||
<script src="/src/buttongroup.js"></script>
|
<script src="/instrumented/src/buttongroup.js"></script>
|
||||||
<script src="/src/rectangle.js"></script>
|
<script src="/instrumented/src/rectangle.js"></script>
|
||||||
<script src="/src/referencestrip.js"></script>
|
<script src="/instrumented/src/referencestrip.js"></script>
|
||||||
<script src="/src/displayrectangle.js"></script>
|
<script src="/instrumented/src/displayrectangle.js"></script>
|
||||||
<script src="/src/spring.js"></script>
|
<script src="/instrumented/src/spring.js"></script>
|
||||||
<script src="/src/imageloader.js"></script>
|
<script src="/instrumented/src/imageloader.js"></script>
|
||||||
<script src="/src/tile.js"></script>
|
<script src="/instrumented/src/tile.js"></script>
|
||||||
<script src="/src/overlay.js"></script>
|
<script src="/instrumented/src/overlay.js"></script>
|
||||||
<script src="/src/drawer.js"></script>
|
<script src="/instrumented/src/drawer.js"></script>
|
||||||
<script src="/src/viewport.js"></script>
|
<script src="/instrumented/src/viewport.js"></script>
|
||||||
<script src="/src/tiledimage.js"></script>
|
<script src="/instrumented/src/tiledimage.js"></script>
|
||||||
<script src="/src/tilecache.js"></script>
|
<script src="/instrumented/src/tilecache.js"></script>
|
||||||
<script src="/src/world.js"></script>
|
<script src="/instrumented/src/world.js"></script>
|
||||||
|
|
||||||
<!-- Helpers -->
|
<!-- Helpers -->
|
||||||
<script src="/test/helpers/legacy.mouse.shim.js"></script>
|
<script src="/test/helpers/legacy.mouse.shim.js"></script>
|
||||||
|
73
test/helpers/phantom-bridge.js
Normal file
73
test/helpers/phantom-bridge.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* grunt-contrib-qunit
|
||||||
|
* http://gruntjs.com/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 "Cowboy" Ben Alman, contributors
|
||||||
|
* Licensed under the MIT license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*global QUnit:true, alert:true*/
|
||||||
|
(function (factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
require(['qunit'], factory);
|
||||||
|
} else {
|
||||||
|
factory(QUnit);
|
||||||
|
}
|
||||||
|
}(function(QUnit) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Don't re-order tests.
|
||||||
|
QUnit.config.reorder = false;
|
||||||
|
|
||||||
|
// Send messages to the parent PhantomJS process via alert! Good times!!
|
||||||
|
function sendMessage() {
|
||||||
|
var args = [].slice.call(arguments);
|
||||||
|
alert(JSON.stringify(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
// These methods connect QUnit to PhantomJS.
|
||||||
|
QUnit.log(function(obj) {
|
||||||
|
// What is this I don’t even
|
||||||
|
if (obj.message === '[object Object], undefined:undefined') { return; }
|
||||||
|
|
||||||
|
// Parse some stuff before sending it.
|
||||||
|
var actual, expected;
|
||||||
|
if (!obj.result) {
|
||||||
|
// Dumping large objects can be very slow, and the dump isn't used for
|
||||||
|
// passing tests, so only dump if the test failed.
|
||||||
|
actual = QUnit.dump.parse(obj.actual);
|
||||||
|
expected = QUnit.dump.parse(obj.expected);
|
||||||
|
}
|
||||||
|
// Send it.
|
||||||
|
sendMessage('qunit.log', obj.result, actual, expected, obj.message, obj.source, obj.todo);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.testStart(function(obj) {
|
||||||
|
sendMessage('qunit.testStart', obj.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.testDone(function(obj) {
|
||||||
|
sendMessage('qunit.testDone', obj.name, obj.failed, obj.passed, obj.total, obj.runtime, obj.skipped, obj.todo);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.moduleStart(function(obj) {
|
||||||
|
sendMessage('qunit.moduleStart', obj.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.moduleDone(function(obj) {
|
||||||
|
sendMessage('qunit.moduleDone', obj.name, obj.failed, obj.passed, obj.total);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.begin(function() {
|
||||||
|
sendMessage('qunit.begin');
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.done(function(obj) {
|
||||||
|
// send coverage data if available
|
||||||
|
if ( window.__coverage__ ) {
|
||||||
|
sendMessage( "qunit.coverage", window.__coverage__ );
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage('qunit.done', obj.failed, obj.passed, obj.total, obj.runtime);
|
||||||
|
});
|
||||||
|
}));
|
Loading…
Reference in New Issue
Block a user