mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Fixed qunit tests (coverage still missing). (#7716)
This commit is contained in:
parent
620dcdde6e
commit
10278885fd
15
Gruntfile.js
15
Gruntfile.js
@ -2,19 +2,12 @@ var globalThreshold = 50; // Global code coverage threshold (as a percentage)
|
||||
|
||||
module.exports = function(grunt) {
|
||||
grunt.initConfig({
|
||||
// Configuration to be run (and then tested).
|
||||
blanket_qunit: {
|
||||
default_options: {
|
||||
options: {
|
||||
urls: ['js_tests/tests.html?coverage=true&gruntReport'],
|
||||
globalThreshold: globalThreshold,
|
||||
threshold: 10
|
||||
}
|
||||
}
|
||||
qunit: {
|
||||
all: ['js_tests/tests.html']
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-blanket-qunit');
|
||||
grunt.registerTask('test', ['blanket_qunit']);
|
||||
grunt.loadNpmTasks('grunt-contrib-qunit');
|
||||
grunt.registerTask('test', ['qunit']);
|
||||
grunt.registerTask('default', ['test']);
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,78 +0,0 @@
|
||||
// grunt-reporter.js
|
||||
//
|
||||
// A communication bridge between blanket.js and the grunt-blanket-qunit plugin
|
||||
// Distributed as part of the grunt-blanket-qunit library
|
||||
//
|
||||
// Copyright (C) 2013 Model N, Inc.
|
||||
// Distributed under the MIT License
|
||||
//
|
||||
// Documentation and full license available at:
|
||||
// https://github.com/ModelN/grunt-blanket-qunit
|
||||
//
|
||||
(function (){
|
||||
"use strict";
|
||||
|
||||
// this is an ugly hack, but it's the official way of communicating between
|
||||
// the parent phantomjs and the inner grunt-contrib-qunit library...
|
||||
var sendMessage = function sendMessage() {
|
||||
var args = [].slice.call(arguments);
|
||||
alert(JSON.stringify(args));
|
||||
};
|
||||
|
||||
// helper function for computing coverage info for a particular file
|
||||
var reportFile = function( data ) {
|
||||
var ret = {
|
||||
coverage: 0,
|
||||
hits: 0,
|
||||
misses: 0,
|
||||
sloc: 0
|
||||
};
|
||||
for (var i = 0; i < data.source.length; i++) {
|
||||
var line = data.source[i];
|
||||
var num = i + 1;
|
||||
if (data[num] === 0) {
|
||||
ret.misses++;
|
||||
ret.sloc++;
|
||||
} else if (data[num] !== undefined) {
|
||||
ret.hits++;
|
||||
ret.sloc++;
|
||||
}
|
||||
}
|
||||
ret.coverage = ret.hits / ret.sloc * 100;
|
||||
|
||||
return [ret.hits,ret.sloc];
|
||||
|
||||
};
|
||||
|
||||
// this function is invoked by blanket.js when the coverage data is ready. it will
|
||||
// compute per-file coverage info, and send a message to the parent phantomjs process
|
||||
// for each file, which the grunt task will use to report passes & failures.
|
||||
var reporter = function(cov){
|
||||
cov = window._$blanket;
|
||||
|
||||
var sortedFileNames = [];
|
||||
|
||||
var totals =[];
|
||||
|
||||
for (var filename in cov) {
|
||||
if (cov.hasOwnProperty(filename)) {
|
||||
sortedFileNames.push(filename);
|
||||
}
|
||||
}
|
||||
|
||||
sortedFileNames.sort();
|
||||
|
||||
for (var i = 0; i < sortedFileNames.length; i++) {
|
||||
var thisFile = sortedFileNames[i];
|
||||
var data = cov[thisFile];
|
||||
var thisTotal= reportFile( data );
|
||||
sendMessage("blanket:fileDone", thisTotal, thisFile);
|
||||
}
|
||||
|
||||
sendMessage("blanket:done");
|
||||
|
||||
};
|
||||
|
||||
blanket.customReporter = reporter;
|
||||
|
||||
})();
|
@ -42,7 +42,6 @@
|
||||
</script>
|
||||
|
||||
<script src="./qunit/qunit.js"></script>
|
||||
<script src="./qunit/blanket.js" data-cover-flags="branchTracking"></script>
|
||||
|
||||
<script src='../django/contrib/admin/static/admin/js/vendor/jquery/jquery.min.js'></script>
|
||||
<script src='../django/contrib/admin/static/admin/js/jquery.init.js'></script>
|
||||
@ -87,11 +86,5 @@
|
||||
<script src='../django/contrib/gis/static/gis/js/OLMapWidget.js' data-cover></script>
|
||||
<script src='./gis/mapwidget.test.js'></script>
|
||||
|
||||
<script>
|
||||
if (location.href.match(/(\?|&)gruntReport($|&|=)/)) {
|
||||
blanket.options("reporter", "qunit/grunt-reporter.js");
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -10,8 +10,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^0.22.1",
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-blanket-qunit": "^0.2.0",
|
||||
"grunt-cli": "^0.1.13"
|
||||
"grunt": "^1.0.1",
|
||||
"grunt-cli": "^1.2.0",
|
||||
"grunt-contrib-qunit": "^1.2.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user