Add ability to run tests with coverage report

This commit is contained in:
Kevin Sawicki 2016-08-02 11:53:13 -07:00
parent e17e195479
commit 491f69df80
5 changed files with 36 additions and 27 deletions

View file

@ -22,7 +22,7 @@ glob.sync('**/*.js', {cwd: libPath}).forEach(function (relativePath) {
fs.writeFileSync(generatedPath, generated)
})
var asarPath = path.join(outputPath, 'electron-instrumented.asar')
var asarPath = path.join(outputPath, 'electron.asar')
asar.createPackageWithOptions(path.join(outputPath, 'lib'), asarPath, {}, function (error) {
if (error) {
console.error(error.stack || error)

View file

@ -33,7 +33,7 @@ const addUnrequiredFiles = (coverage) => {
}
// Generate a code coverage report in out/coverage/lcov-report
exports.generate = () => {
exports.generateReport = () => {
const coverage = window.__coverage__
if (coverage == null) return
@ -49,27 +49,3 @@ exports.generate = () => {
reporter.addAll(['text', 'lcov'])
reporter.write(collector, true, function () {})
}
// Generate an instrumented .asar file for all the files in lib/ and save it
// to out/coverage/electron-instrumented.asar
exports.instrument = () => {
const instrumenter = new Instrumenter()
glob.sync('**/*.js', {cwd: libPath}).forEach(function (relativePath) {
const rawPath = path.join(libPath, relativePath)
const raw = fs.readFileSync(rawPath, 'utf8')
const generatedPath = path.join(outputPath, 'lib', relativePath)
const generated = instrumenter.instrumentSync(raw, rawPath)
mkdirp.sync(path.dirname(generatedPath))
fs.writeFileSync(generatedPath, generated)
})
const asarPath = path.join(outputPath, 'electron-instrumented.asar')
asar.createPackageWithOptions(path.join(outputPath, 'lib'), asarPath, {}, function (error) {
if (error) {
console.error(error.stack || error)
process.exit(1)
}
})
}

View file

@ -83,7 +83,7 @@
Mocha.utils.highlightTags('code');
if (isCi)
ipcRenderer.send('process.exit', runner.failures);
require('./coverage').generate()
require('../coverage/reporter').generateReport()
});
});
})();