Merge pull request #140 from sc-forks/sanity-checks

Add sanity checks for contracts and coverageEnv folders
pull/142/head
c-g-e-w-e-k-e- 7 years ago committed by GitHub
commit 160956d387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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