From 08ea7e185c4074f28852d2d98ac3fe75a2405bce Mon Sep 17 00:00:00 2001 From: Experimental Team Date: Wed, 22 Nov 2017 17:36:28 -0300 Subject: [PATCH 1/3] Add specific packages into coverageEnv --- lib/app.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/app.js b/lib/app.js index d1027df..8b56c13 100644 --- a/lib/app.js +++ b/lib/app.js @@ -42,6 +42,7 @@ class App { this.port = config.port || 8555; // Port testrpc should listen on this.copyNodeModules = config.copyNodeModules || false; // Copy node modules into coverageEnv? + this.copyPackages = config.copyPackages || []; // Only copy specific node_modules packages into coverageEnv this.testrpcOptions = config.testrpcOptions || null; // Options for testrpc-sc this.testCommand = config.testCommand || null; // Optional test command @@ -72,6 +73,14 @@ class App { shell.mkdir(this.coverageDir); shell.cp('-R', files, this.coverageDir); + // Add specific node_modules packages. + if (!this.copyNodeModules && this.copyPackages.length) { + shell.mkdir(this.coverageDir + '/node_modules'); + this.copyNodeModulesPackages.forEach((nodePackage) => { + shell.cp('-rf', 'node_modules/' + nodePackage, this.coverageDir + '/node_modules/'); + }); + } + // Load config if present, accomodate common windows naming. let truffleConfig; From cb50a7b12a49a3177b2ac4e68ae6cf7c4f1696b1 Mon Sep 17 00:00:00 2001 From: Experimental Team Date: Wed, 22 Nov 2017 17:41:18 -0300 Subject: [PATCH 2/3] copyPackages readme update --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 20dbb26..2c7df82 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ module.exports = { testCommand: 'mocha --timeout 5000', norpc: true, dir: './secretDirectory', + copyPackages: ['zeppelin-solidity'], skipFiles: ['Routers/EtherRouter.sol'] }; ``` @@ -94,6 +95,7 @@ module.exports = { | testCommand | *String* | `truffle test` | Run an arbitrary test command. ex: `mocha --timeout 5000`. NB: Also set the `port` option to whatever your tests require (probably 8545). | | testrpcOptions | *String* | `--port 8555` | options to append to a command line invocation of testrpc. NB: Using this overwrites the defaults so always specify a port in this string *and* in the `port` option | | copyNodeModules | *Boolean* | false | Copies `node_modules` into the coverage environment. May significantly increase the time for coverage to complete if enabled. Useful if your contracts import solidity files from an npm installed package. | +| copyPackages | *Array* | `[]` | Copies specific `node_modules` packages into the coverage environment. May significantly reduce the time for coverage to complete compared to `copyNodeModules`. Useful if your contracts import solidity files from an npm installed package. | | skipFiles | *Array* | `['Migrations.sol']` | Array of contracts (with paths expressed relative to the `contracts` directory) that should be skipped when doing instrumentation. `Migrations.sol` is skipped by default, and does not need to be added to this configuration option if it is used. | | dir | *String* | `.` | Solidity-coverage copies all the assets in your root directory (except `node_modules`) to a special folder where it instruments the contracts and executes the tests. `dir` allows you to define a relative path from the root directory to those assets. Useful if your contracts & tests are within their own folder as part of a larger project.| From d3b1a0dbd5075a061bc311d061d82e03bc65f22d Mon Sep 17 00:00:00 2001 From: Experimental Team Date: Wed, 22 Nov 2017 17:54:58 -0300 Subject: [PATCH 3/3] copyNodeModulesPackages -> copyPackages fix --- lib/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app.js b/lib/app.js index 8b56c13..1dffa87 100644 --- a/lib/app.js +++ b/lib/app.js @@ -76,7 +76,7 @@ class App { // Add specific node_modules packages. if (!this.copyNodeModules && this.copyPackages.length) { shell.mkdir(this.coverageDir + '/node_modules'); - this.copyNodeModulesPackages.forEach((nodePackage) => { + this.copyPackages.forEach((nodePackage) => { shell.cp('-rf', 'node_modules/' + nodePackage, this.coverageDir + '/node_modules/'); }); }