Merge pull request #8 from sc-forks/revert-isTruffle

Revert 'isTruffle' option (b/c useless & incorrect). Small README edits.
pull/21/head
c-g-e-w-e-k-e- 8 years ago committed by GitHub
commit 6317013e9c
  1. 7
      README.md
  2. 58
      bin/exec.js

@ -71,8 +71,6 @@ testrpc is set to run on, e.g:
+ **norpc**: {Boolean} When true, solidity-coverage will not launch its own testrpc instance. This + **norpc**: {Boolean} When true, solidity-coverage will not launch its own testrpc instance. This
can be useful if you are running tests using a different vm like the can be useful if you are running tests using a different vm like the
[`sc-forks` version of `pyethereum`](https://github.com/sc-forks/pyethereum). (Default: false). [`sc-forks` version of `pyethereum`](https://github.com/sc-forks/pyethereum). (Default: false).
+ **isTruffle**: {Boolean}: Set to false if your project does not have a migrations folder or a
`truffle.js` config file.
+ **dir**: {String} : By default, solidity-coverage looks for a `contracts` folder in your root + **dir**: {String} : By default, solidity-coverage looks for a `contracts` folder in your root
directory. `dir` allows you to define a relative path from the root directory to the contracts directory. `dir` allows you to define a relative path from the root directory to the contracts
folder. A `dir` of `./secretDirectory` would tell solidity-coverage to look for `./secretDirectory/contracts` folder. A `dir` of `./secretDirectory` would tell solidity-coverage to look for `./secretDirectory/contracts`
@ -116,10 +114,7 @@ your tests actually reach all the conditional branches in your code. It can be f
**WARNING**: This utility is in development and its accuracy is unknown. If you **WARNING**: This utility is in development and its accuracy is unknown. If you
find discrepancies between the coverage report and your suite's behavior, please open an find discrepancies between the coverage report and your suite's behavior, please open an
[issue](https://github.com/sc-forks/solidity-coverage/issues). The purpose of [issue](https://github.com/sc-forks/solidity-coverage/issues).
the following examples is to help you install solidity-coverage in your own project and evaluate the
coverage of your own tests. The reports below are **not** meaningful analyses of the
the past or present state of any project's testing regime.
+ **metacoin**: The default truffle project + **metacoin**: The default truffle project
+ [HTML reports](https://sc-forks.github.io/metacoin/) + [HTML reports](https://sc-forks.github.io/metacoin/)

@ -56,7 +56,6 @@ const config = reqCwd.silent('./.solcover.js') || {};
const workingDir = config.dir || '.'; // Relative path to contracts folder const workingDir = config.dir || '.'; // Relative path to contracts folder
const port = config.port || 8555; // Port testrpc listens on const port = config.port || 8555; // Port testrpc listens on
const accounts = config.accounts || 35; // Number of accounts to testrpc launches with const accounts = config.accounts || 35; // Number of accounts to testrpc launches with
const isTruffle = config.isTruffle || true; // Is target a truffle project?
// Set testrpc options // Set testrpc options
const defaultRpcOptions = `--gasLimit ${gasLimitString} --accounts ${accounts} --port ${port}`; const defaultRpcOptions = `--gasLimit ${gasLimitString} --accounts ${accounts} --port ${port}`;
@ -82,39 +81,42 @@ if (!config.norpc) {
// environment folder. // environment folder.
log('Generating coverage environment'); log('Generating coverage environment');
try { try {
// Common environment: /contracts/ & /test/
// Truffle environment:
// contracts/
// test/
// migrations/
// truffle.js
shell.mkdir(`${coverageDir}`); shell.mkdir(`${coverageDir}`);
shell.cp('-R', `${workingDir}/contracts`, `${coverageDir}`); shell.cp('-R', `${workingDir}/contracts`, `${coverageDir}`);
shell.cp('-R', `${workingDir}/test`, `${coverageDir}`); shell.cp('-R', `${workingDir}/test`, `${coverageDir}`);
shell.cp('-R', `${workingDir}/migrations`, `${coverageDir}`);
const truffleConfig = reqCwd(`${workingDir}/truffle.js`);
// Truffle environment: + /migrations/, truffle.js // Coverage network opts specified: copy truffle.js whole to coverage environment
if (isTruffle) { if (truffleConfig.networks.coverage) {
shell.cp('-R', `${workingDir}/migrations`, `${coverageDir}`); shell.cp(`${workingDir}/truffle.js`, `${coverageDir}/truffle.js`);
const truffleConfig = reqCwd(`${workingDir}/truffle.js`);
// Coverage network opts NOT specified: default to the development network w/ modified
// Coverage network opts specified: copy truffle.js whole to coverage environment // port, gasLimit, gasPrice. Export the config object only.
if (truffleConfig.networks.coverage) { } else {
shell.cp(`${workingDir}/truffle.js`, `${coverageDir}/truffle.js`); const trufflejs = `
module.exports = {
// Coverage network opts NOT specified: default to the development network w/ modified networks: {
// port, gasLimit, gasPrice. Export the config object only. development: {
} else { host: "localhost",
const trufflejs = ` network_id: "*",
module.exports = { port: ${port},
networks: { gas: ${gasLimitHex},
development: { gasPrice: ${gasPriceHex}
host: "localhost",
network_id: "*",
port: ${port},
gas: ${gasLimitHex},
gasPrice: ${gasPriceHex}
}
} }
};`; }
};`;
coverageOption = ''; coverageOption = '';
fs.writeFileSync(`${coverageDir}/truffle.js`, trufflejs); fs.writeFileSync(`${coverageDir}/truffle.js`, trufflejs);
}
} }
} catch (err) { } catch (err) {
const msg = ('There was a problem generating the coverage environment: '); const msg = ('There was a problem generating the coverage environment: ');

Loading…
Cancel
Save