Add sanity checks for contracts and coverageEnv folders

pull/140/head
cgewecke 7 years ago
parent da8f1e6882
commit f02cb7689e
  1. 14
      lib/app.js

@ -57,6 +57,8 @@ class App {
this.log('Generating coverage environment'); this.log('Generating coverage environment');
try { try {
this.sanityCheckContext();
let files = shell.ls(this.workingDir); let files = shell.ls(this.workingDir);
const nmIndex = files.indexOf('node_modules'); const nmIndex = files.indexOf('node_modules');
@ -188,7 +190,7 @@ class App {
` `
There was an error generating coverage. Possible reasons include: There was an error generating coverage. Possible reasons include:
1. Another application is using port ${this.port} 1. Another application is using port ${this.port}
2. Truffle crashed because your tests errored 2. Your test runner (Truffle?) crashed because the tests encountered an error.
`; `;
this.cleanUp(msg + err); this.cleanUp(msg + err);
@ -240,6 +242,16 @@ class App {
// ------------------------------------------ Utils ---------------------------------------------- // ------------------------------------------ Utils ----------------------------------------------
sanityCheckContext(){
if (!shell.test('-e', `${this.workingDir}/contracts`)){
this.cleanUp("Couldn't find a 'contracts' folder to instrument.");
}
if (shell.test('-e', `${this.workingDir}/${this.coverageDir}`)){
shell.rm('-Rf', this.coverageDir);
}
}
/** /**
* Relativizes path keys so that istanbul report can be read on Windows * Relativizes path keys so that istanbul report can be read on Windows
* @param {Object} map coverage map generated by coverageMap * @param {Object} map coverage map generated by coverageMap

Loading…
Cancel
Save