Update coverage report after each step

This commit is contained in:
Andre Medeiros 2018-09-14 13:16:02 -04:00
parent 9887a2204d
commit cd8980151b
1 changed files with 9 additions and 6 deletions

View File

@ -24,12 +24,8 @@ class CodeCoverage {
this.coverageReport = {}; this.coverageReport = {};
this.contractSources = new ContractSources([]); this.contractSources = new ContractSources([]);
var self = this; this.dotEmbarkPath = fs.dappPath('.embark');
this.coverageReportPath = fs.dappPath('.embark', 'coverage.json');
process.on('exit', (_code) => {
const coverageReportPath = fs.dappPath('.embark', 'coverage.json');
fs.writeFileSync(coverageReportPath, JSON.stringify(self.coverageReport));
});
} }
compileSolc(input) { compileSolc(input) {
@ -42,6 +38,11 @@ class CodeCoverage {
this.contractSources.parseSolcOutput(output); this.contractSources.parseSolcOutput(output);
} }
updateCoverageReport() {
fs.mkdirpSync(this.dotEmbarkPath);
fs.writeFileSync(this.coverageReportPath, JSON.stringify(this.coverageReport));
}
async runSolc(receipt) { async runSolc(receipt) {
let block = await web3.eth.getBlock(receipt.number); let block = await web3.eth.getBlock(receipt.number);
if(block.transactions.length == 0) return; if(block.transactions.length == 0) return;
@ -61,6 +62,8 @@ class CodeCoverage {
for(let i in traces) { for(let i in traces) {
this.coverageReport = this.contractSources.generateCodeCoverage(traces[i]); this.coverageReport = this.contractSources.generateCodeCoverage(traces[i]);
} }
this.updateCoverageReport();
} }
} }