2013-07-17 08:28:14 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2013-08-27 03:37:06 +00:00
|
|
|
<meta name="referrer" content="always">
|
2014-04-29 03:51:49 +00:00
|
|
|
<link href="../node_modules/mocha/mocha.css" rel="stylesheet">
|
2013-08-25 08:23:40 +00:00
|
|
|
<script src="jquery-2.0.3.min.js"></script>
|
2013-07-17 08:28:14 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="mocha"></div>
|
|
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8">
|
|
|
|
(function() {
|
2013-12-15 09:02:43 +00:00
|
|
|
// Disable use of deprecated functions.
|
|
|
|
process.throwDeprecation = true;
|
|
|
|
|
2016-08-03 21:12:05 +00:00
|
|
|
var path = require('path');
|
2015-11-12 10:28:04 +00:00
|
|
|
var electron = require ('electron');
|
|
|
|
var remote = electron.remote;
|
|
|
|
var ipcRenderer = electron.ipcRenderer;
|
|
|
|
|
2016-08-03 21:12:05 +00:00
|
|
|
// Check if we are running in CI.
|
2015-12-10 18:33:18 +00:00
|
|
|
var isCi = remote.getGlobal('isCi')
|
2013-08-21 03:35:39 +00:00
|
|
|
|
|
|
|
if (!isCi) {
|
2015-11-12 10:28:04 +00:00
|
|
|
var win = remote.getCurrentWindow();
|
2013-08-21 03:35:39 +00:00
|
|
|
win.show();
|
|
|
|
win.focus();
|
|
|
|
}
|
|
|
|
|
2013-07-31 02:55:47 +00:00
|
|
|
// Show DevTools.
|
|
|
|
document.oncontextmenu = function(e) {
|
2015-11-12 10:28:04 +00:00
|
|
|
remote.getCurrentWindow().inspectElement(e.clientX, e.clientY);
|
2013-07-31 02:55:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-21 03:15:22 +00:00
|
|
|
// Rediret all output to browser.
|
2013-08-25 12:54:15 +00:00
|
|
|
if (isCi) {
|
|
|
|
global.__defineGetter__('console', function() {
|
|
|
|
return {
|
|
|
|
log: function() {
|
|
|
|
args = Array.prototype.slice.call(arguments);
|
2015-11-12 10:28:04 +00:00
|
|
|
ipcRenderer.send('console.log', args);
|
2013-08-25 12:54:15 +00:00
|
|
|
},
|
|
|
|
error: function() {
|
|
|
|
args = Array.prototype.slice.call(arguments);
|
2015-11-12 10:28:04 +00:00
|
|
|
ipcRenderer.send('console.error', args);
|
2013-08-25 12:54:15 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-08-21 03:15:22 +00:00
|
|
|
|
2016-08-03 21:12:05 +00:00
|
|
|
var Coverage = require('electabul').Coverage;
|
|
|
|
|
2013-07-17 08:28:14 +00:00
|
|
|
var Mocha = require('mocha');
|
|
|
|
|
|
|
|
var mocha = new Mocha();
|
2016-06-09 23:55:05 +00:00
|
|
|
|
2013-08-21 03:35:39 +00:00
|
|
|
mocha.ui('bdd').reporter(isCi ? 'tap' : 'html');
|
2016-11-29 22:29:35 +00:00
|
|
|
mocha.timeout(isCi ? 30000 : 10000)
|
2013-07-17 08:28:14 +00:00
|
|
|
|
|
|
|
var query = Mocha.utils.parseQuery(window.location.search || '');
|
|
|
|
if (query.grep) mocha.grep(query.grep);
|
|
|
|
if (query.invert) mocha.invert();
|
|
|
|
|
|
|
|
// Read all test files.
|
2017-07-31 07:36:52 +00:00
|
|
|
var walker = require('walkdir').walk(path.dirname(__dirname), {
|
2013-12-06 14:23:02 +00:00
|
|
|
no_recurse: true
|
|
|
|
});
|
2013-07-17 08:28:14 +00:00
|
|
|
|
2013-07-22 08:41:52 +00:00
|
|
|
walker.on('file', function(file) {
|
2017-07-31 07:36:52 +00:00
|
|
|
if (/-spec\.js$/.test(file) && !file.includes('api-crash-reporter-spec.js'))
|
2013-07-17 08:28:14 +00:00
|
|
|
mocha.addFile(file);
|
|
|
|
});
|
|
|
|
|
2013-07-22 08:41:52 +00:00
|
|
|
walker.on('end', function() {
|
2017-07-31 07:36:52 +00:00
|
|
|
mocha.addFile(path.resolve(__dirname, '..', 'api-crash-reporter-spec.js'))
|
2013-08-21 03:15:22 +00:00
|
|
|
var runner = mocha.run(function() {
|
2016-11-22 21:06:18 +00:00
|
|
|
if (isCi && runner.hasOnly) {
|
|
|
|
try {
|
|
|
|
throw new Error('A spec contains a call to it.only or describe.only and should be reverted.')
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error.stack || error)
|
|
|
|
}
|
|
|
|
ipcRenderer.send('process.exit', 1)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2013-07-17 08:28:14 +00:00
|
|
|
Mocha.utils.highlightTags('code');
|
2016-08-03 21:12:05 +00:00
|
|
|
|
|
|
|
var coverage = new Coverage({
|
|
|
|
libPath: path.join(__dirname, '..', '..', 'lib'),
|
|
|
|
outputPath: path.join(__dirname, '..', '..', 'out', 'coverage'),
|
|
|
|
formats: ['text', 'lcov']
|
|
|
|
});
|
|
|
|
coverage.addCoverage(ipcRenderer.sendSync('get-main-process-coverage'))
|
|
|
|
coverage.generateReport()
|
|
|
|
|
2013-08-21 03:15:22 +00:00
|
|
|
if (isCi)
|
2015-11-12 10:28:04 +00:00
|
|
|
ipcRenderer.send('process.exit', runner.failures);
|
2013-07-17 08:28:14 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
})();
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|