fix: make coverage more forgiving

This commit is contained in:
Andre Medeiros 2019-04-18 14:11:17 -04:00 committed by Iuri Matias
parent 6b16f668e0
commit 0f4e554b22

View File

@ -32,13 +32,17 @@ export class ContractEnhanced {
constructor(public filepath: string, public solcVersion: string) { constructor(public filepath: string, public solcVersion: string) {
this.id = nextId(); this.id = nextId();
// silence compiler warnings.
this.source = this.originalSource = "";
try { try {
this.source = fs.readFileSync(filepath, "utf-8"); this.source = fs.readFileSync(filepath, "utf-8");
this.originalSource = this.source; this.originalSource = this.source;
this.ast = parser.parse(this.source, {loc: true, range: true}); this.ast = parser.parse(this.source, {loc: true, range: true});
} catch (error) { } catch (error) {
this.source = ""; const {line, column, message} = error.errors[0];
this.originalSource = ""; console.warn(`Error on ${this.filepath}:${line}:${column}: "${message}". Could not setup for coverage.`);
} }
this.coverageFilepath = path.join(coverageContractsPath(), this.filepath); this.coverageFilepath = path.join(coverageContractsPath(), this.filepath);