mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 20:14:37 -04:00
Update test runner.
This commit is contained in:
parent
63fe57731e
commit
21c976bb3d
3 changed files with 77 additions and 49 deletions
|
@ -13,5 +13,7 @@ html
|
||||||
body
|
body
|
||||||
div#report
|
div#report
|
||||||
a( href="index.html" ) h5ai #{pkg.version} test suite
|
a( href="index.html" ) h5ai #{pkg.version} test suite
|
||||||
|
div.stats
|
||||||
|
div.progress
|
||||||
div#mocha-overlay
|
div#mocha-overlay
|
||||||
div#mocha
|
div#mocha
|
||||||
|
|
|
@ -36,6 +36,21 @@
|
||||||
&.fail {
|
&.fail {
|
||||||
background: @col-red-500;
|
background: @col-red-500;
|
||||||
}
|
}
|
||||||
|
.stats {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
right: 8px;
|
||||||
|
top: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.progress {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
height: 100%;
|
||||||
|
background: rgba(255,255,255,0.2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#mocha-overlay {
|
#mocha-overlay {
|
||||||
|
@ -191,38 +206,35 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#mocha-stats {
|
#mocha-stats {
|
||||||
position: fixed;
|
display: none;
|
||||||
top: 40px;
|
// position: fixed;
|
||||||
right: 20px;
|
// top: 40px;
|
||||||
margin: 0;
|
// right: 20px;
|
||||||
color: @col-grey-800;
|
// margin: 0;
|
||||||
z-index: 1;
|
// color: @col-grey-800;
|
||||||
font-size: 13px;
|
// z-index: 1;
|
||||||
|
// font-size: 13px;
|
||||||
|
|
||||||
em {
|
// em {
|
||||||
font-style: normal;
|
// font-style: normal;
|
||||||
font-size: 14px;
|
// font-size: 14px;
|
||||||
}
|
// }
|
||||||
a {
|
// a {
|
||||||
text-decoration: none;
|
// text-decoration: none;
|
||||||
color: inherit;
|
// color: inherit;
|
||||||
}
|
// }
|
||||||
li {
|
// li {
|
||||||
display: inline-block;
|
// display: inline-block;
|
||||||
margin: 0 5px;
|
// margin: 0 5px;
|
||||||
list-style: none;
|
// list-style: none;
|
||||||
padding-top: 11px;
|
// padding-top: 11px;
|
||||||
}
|
// }
|
||||||
canvas {
|
// canvas {
|
||||||
width: 40px;
|
// width: 40px;
|
||||||
height: 40px;
|
// height: 40px;
|
||||||
}
|
// }
|
||||||
.progress {
|
// .progress {
|
||||||
float: right;
|
// float: right;
|
||||||
padding-top: 0;
|
// padding-top: 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
.passes, .failures {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,28 @@
|
||||||
|
|
||||||
function onEnd() {
|
function onEnd() {
|
||||||
|
|
||||||
var failed = $('.test.fail').length > 0;
|
var runner = this;
|
||||||
|
var failed = runner.stats.failures > 0;
|
||||||
|
var stats = (runner.stats.duration / 1000.0).toFixed(2) + 's';
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
var onlyFailures = false;
|
||||||
|
$('#report .stats').on('click', function (ev) {
|
||||||
|
|
||||||
|
onlyFailures = !onlyFailures;
|
||||||
|
if (onlyFailures) {
|
||||||
|
$('.suite, .test').hide();
|
||||||
|
$('.suite.fail, .test.fail').show();
|
||||||
|
} else {
|
||||||
|
$('.suite, .test').show();
|
||||||
|
}
|
||||||
|
ev.stopImmediatePropagation();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$('#report').addClass(failed ? 'fail' : 'pass');
|
$('#report').addClass(failed ? 'fail' : 'pass');
|
||||||
|
$('#report .progress').hide();
|
||||||
|
$('#report .stats').text(stats);
|
||||||
|
|
||||||
$('#mocha-overlay .suite').each(function () {
|
$('#mocha-overlay .suite').each(function () {
|
||||||
|
|
||||||
|
@ -31,24 +50,19 @@ function onEnd() {
|
||||||
var $code = $(this);
|
var $code = $(this);
|
||||||
$code.text($code.text().trim().replace(/;\n\s*/g, ';\n'));
|
$code.text($code.text().trim().replace(/;\n\s*/g, ';\n'));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#mocha-stats .passes a').replaceWith('<span>passes:</span>');
|
|
||||||
$('#mocha-stats .failures a').replaceWith('<span>failures:</span>');
|
|
||||||
|
|
||||||
if (failed) {
|
|
||||||
var onlyFailures = false;
|
|
||||||
$('#mocha-stats .failures').on('click', function (ev) {
|
|
||||||
|
|
||||||
onlyFailures = !onlyFailures;
|
|
||||||
if (onlyFailures) {
|
|
||||||
$('.suite, .test').hide();
|
|
||||||
$('.suite.fail, .test.fail').show();
|
|
||||||
} else {
|
|
||||||
$('.suite, .test').show();
|
|
||||||
}
|
}
|
||||||
ev.stopImmediatePropagation();
|
|
||||||
});
|
function onTest() {
|
||||||
|
|
||||||
|
var runner = this;
|
||||||
|
var complete = runner.stats.tests;
|
||||||
|
var total = runner.total;
|
||||||
|
var percent = 100.0 - 100.0 * complete / total;
|
||||||
|
|
||||||
|
if (runner.stats.failures) {
|
||||||
|
$('#report').addClass('fail');
|
||||||
}
|
}
|
||||||
|
$('#report .progress').css('width', percent + '%');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupMocha() {
|
function setupMocha() {
|
||||||
|
@ -59,7 +73,7 @@ function setupMocha() {
|
||||||
|
|
||||||
function runMocha() {
|
function runMocha() {
|
||||||
|
|
||||||
mocha.run().on('end', onEnd);
|
mocha.run().on('test', onTest).on('end', onEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.util = window.util || {};
|
window.util = window.util || {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue