From cd8980151b4b464bba98e185b34765b8b4614c31 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Fri, 14 Sep 2018 13:16:02 -0400 Subject: [PATCH] Update coverage report after each step --- lib/modules/coverage/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/modules/coverage/index.js b/lib/modules/coverage/index.js index a9070a1d..a7dbbb7d 100644 --- a/lib/modules/coverage/index.js +++ b/lib/modules/coverage/index.js @@ -24,12 +24,8 @@ class CodeCoverage { this.coverageReport = {}; this.contractSources = new ContractSources([]); - var self = this; - - process.on('exit', (_code) => { - const coverageReportPath = fs.dappPath('.embark', 'coverage.json'); - fs.writeFileSync(coverageReportPath, JSON.stringify(self.coverageReport)); - }); + this.dotEmbarkPath = fs.dappPath('.embark'); + this.coverageReportPath = fs.dappPath('.embark', 'coverage.json'); } compileSolc(input) { @@ -42,6 +38,11 @@ class CodeCoverage { this.contractSources.parseSolcOutput(output); } + updateCoverageReport() { + fs.mkdirpSync(this.dotEmbarkPath); + fs.writeFileSync(this.coverageReportPath, JSON.stringify(this.coverageReport)); + } + async runSolc(receipt) { let block = await web3.eth.getBlock(receipt.number); if(block.transactions.length == 0) return; @@ -61,6 +62,8 @@ class CodeCoverage { for(let i in traces) { this.coverageReport = this.contractSources.generateCodeCoverage(traces[i]); } + + this.updateCoverageReport(); } }