From 7bf86ef5f7f66ce9e247608cc7a6545dd052f306 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Sat, 13 May 2017 12:14:57 -0700 Subject: [PATCH 1/2] Reverts e7b6ee45af6aaeba04723f5fcb85e064737498d5 (b/c useless & incorrect). Small README edits --- README.md | 7 +------ bin/exec.js | 58 +++++++++++++++++++++++++++-------------------------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index e9e6c62..6355fee 100644 --- a/README.md +++ b/README.md @@ -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 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). -+ **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 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` @@ -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 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 -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. +[issue](https://github.com/sc-forks/solidity-coverage/issues). + **metacoin**: The default truffle project + [HTML reports](https://sc-forks.github.io/metacoin/) diff --git a/bin/exec.js b/bin/exec.js index 8a987e9..9af66b3 100644 --- a/bin/exec.js +++ b/bin/exec.js @@ -56,7 +56,6 @@ const config = reqCwd.silent('./.solcover.js') || {}; const workingDir = config.dir || '.'; // Relative path to contracts folder const port = config.port || 8555; // Port testrpc listens on 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 const defaultRpcOptions = `--gasLimit ${gasLimitString} --accounts ${accounts} --port ${port}`; @@ -82,39 +81,42 @@ if (!config.norpc) { // environment folder. log('Generating coverage environment'); try { - // Common environment: /contracts/ & /test/ + + // Truffle environment: + // contracts/ + // test/ + // migrations/ + // truffle.js + shell.mkdir(`${coverageDir}`); shell.cp('-R', `${workingDir}/contracts`, `${coverageDir}`); shell.cp('-R', `${workingDir}/test`, `${coverageDir}`); + shell.cp('-R', `${workingDir}/migrations`, `${coverageDir}`); - // Truffle environment: + /migrations/, truffle.js - if (isTruffle) { - shell.cp('-R', `${workingDir}/migrations`, `${coverageDir}`); - const truffleConfig = reqCwd(`${workingDir}/truffle.js`); - - // Coverage network opts specified: copy truffle.js whole to coverage environment - if (truffleConfig.networks.coverage) { - shell.cp(`${workingDir}/truffle.js`, `${coverageDir}/truffle.js`); - - // Coverage network opts NOT specified: default to the development network w/ modified - // port, gasLimit, gasPrice. Export the config object only. - } else { - const trufflejs = ` - module.exports = { - networks: { - development: { - host: "localhost", - network_id: "*", - port: ${port}, - gas: ${gasLimitHex}, - gasPrice: ${gasPriceHex} - } + const truffleConfig = reqCwd(`${workingDir}/truffle.js`); + + // Coverage network opts specified: copy truffle.js whole to coverage environment + if (truffleConfig.networks.coverage) { + shell.cp(`${workingDir}/truffle.js`, `${coverageDir}/truffle.js`); + + // Coverage network opts NOT specified: default to the development network w/ modified + // port, gasLimit, gasPrice. Export the config object only. + } else { + const trufflejs = ` + module.exports = { + networks: { + development: { + host: "localhost", + network_id: "*", + port: ${port}, + gas: ${gasLimitHex}, + gasPrice: ${gasPriceHex} } - };`; + } + };`; - coverageOption = ''; - fs.writeFileSync(`${coverageDir}/truffle.js`, trufflejs); - } + coverageOption = ''; + fs.writeFileSync(`${coverageDir}/truffle.js`, trufflejs); } } catch (err) { const msg = ('There was a problem generating the coverage environment: '); From 424d557fe40bbdff580451879bffc989fb9f09f6 Mon Sep 17 00:00:00 2001 From: c-g-e-w-e-k-e- Date: Sat, 13 May 2017 13:14:22 -0700 Subject: [PATCH 2/2] Change install instructions, small edits & formatting --- README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6355fee..61926d6 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ For more details about what this is, how it works and potential limitations, see [the accompanying article](https://blog.colony.io/code-coverage-for-solidity-eecfa88668c2). -(solidity-coverage is a stand-alone fork of [Solcover](https://github.com/JoinColony/solcover)) +**solidity-coverage** is a stand-alone fork of [Solcover](https://github.com/JoinColony/solcover) ### Install ``` -$ npm install --save-dev https://github.com/sc-forks/solidity-coverage.git +$ npm install --save-dev solidity-coverage ``` ### Run @@ -83,7 +83,7 @@ module.exports = { port: 6545, testrpcOptions: '-p 6545 -u 0x54fd80d6ae7584d8e9a19fe1df43f04e5282cc43', testCommand: 'mocha --timeout 5000', - norpc: true + norpc: true, dir: './secretDirectory' }; ``` @@ -130,14 +130,10 @@ find discrepancies between the coverage report and your suite's behavior, please Contributions are welcome! If you're opening a PR that adds features please consider writing some [unit tests](https://github.com/sc-forks/solidity-coverage/tree/master/test) for them. You could -also lint your submission by running 'npm run lint'. Bugs can be reported in the -[issues](https://github.com/sc-forks/solidity-coverage/issues) +also lint your submission with `npm run lint`. Bugs can be reported in the +[issues](https://github.com/sc-forks/solidity-coverage/issues). ### Contributors + [@area](https://github.com/area) + [@cgewecke](https://github.com/cgewecke) + [@adriamb](https://github.com/adriamb) - -### TODO - -- [ ] Release on NPM