Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b1fa110
Add truffle fork dep, exec.js
cgewecke Mar 28, 2017
f1de0f4
exec.js test suite updated for truffle 3
cgewecke Mar 29, 2017
31125bf
Toggle silence off to debug CI failures
cgewecke Mar 29, 2017
bb50f66
Comment out suite flush test, remove truffle -g from circle.yml
cgewecke Mar 29, 2017
fa903ec
Comments/cleanup in exec.js. Add --test flag, add CI logic to flush test
cgewecke Mar 29, 2017
95f0580
Remove .only on run tests
cgewecke Mar 29, 2017
d9d9789
Attempt to normalize paths for "npm install --save-dev" use
cgewecke Mar 30, 2017
b24dbc0
Remove patching - replace with testrpc/ethereumjs-vm forks
cgewecke Mar 30, 2017
6de8846
Remove silence to debug CI failure, lengthen timeout, npm bin
cgewecke Mar 30, 2017
6fb6f0b
Add debugging line for norpc, explicitly include yargs
cgewecke Mar 30, 2017
adbdf8e
Try removing shebang to get CI to pass
cgewecke Mar 30, 2017
60c9332
Try to fix CI: remove yargs, add commander for argv processing
cgewecke Mar 30, 2017
9f770c8
Move to config file based options, allow use of coverage network in t…
cgewecke Mar 31, 2017
c98c53b
Debug CI - untoggle silent
cgewecke Mar 31, 2017
1bf4ac3
Only run single testrpc instance in tests
cgewecke Mar 31, 2017
e075842
Use istanbul API instead of shell.exec b/c incompatible w/ npm insta…
cgewecke Mar 31, 2017
f6b617e
Debug CI: run flush test
cgewecke Mar 31, 2017
5228fe7
Exit process at end (travis got stuck if not)
Apr 12, 2017
da24a90
Allows contract inheritance
Apr 12, 2017
128dd31
Added keccakjs dependency
Apr 12, 2017
fbfd049
eslint-ed
Apr 12, 2017
2004589
Updated solc to 0.4.10
Apr 12, 2017
7012cda
reverted version to solc 0.4.8
Apr 12, 2017
9d24ac7
Remove some extraneous deps, use sc-forks testrpc
cgewecke Apr 17, 2017
440e685
Use sc-forks, add inheritance test, fix report bug
cgewecke Apr 18, 2017
108d7a0
Try resolving merge conflict
cgewecke Apr 19, 2017
4cc0ad5
Remove runCoveredTests.js
cgewecke Apr 19, 2017
cb833aa
Merge branch 'adriamb-master' into truffle3-adriamb
cgewecke Apr 19, 2017
d8eafb8
Merge adriamb inheritance fix, use non-forked (global) truffle
cgewecke Apr 19, 2017
c4f03dc
Lint
cgewecke Apr 19, 2017
af94780
Lint II
cgewecke Apr 19, 2017
1bea757
Lint III: add .eslintignore for truffle-crash test (intentional synta…
cgewecke Apr 19, 2017
3fd5e32
Merge pull request #58 from cgewecke/truffle3-adriamb
cgewecke Apr 19, 2017
c98d085
Fix testrpc fork name in pkg, remove unused testing utils
cgewecke Apr 19, 2017
a46f733
Accomodate both locations NPM might install testrpc-sc
cgewecke Apr 19, 2017
52f0a4b
Add assembly AST node names, edit README for npm install
cgewecke Apr 19, 2017
7d652aa
Generate a config for truffle.js networks -> development, instead of …
cgewecke Apr 19, 2017
9af5c30
Revert previous config fix, update README to require a development ne…
cgewecke Apr 19, 2017
3e53edc
Add missing assembly AST node type, ignore client truffle.js, revert …
cgewecke Apr 20, 2017
0b57ebc
Accomodate LibraryStatements in instrumentSolidity.js
cgewecke Apr 21, 2017
695b2fe
Get truffle exec to recognize networks option flag
cgewecke Apr 21, 2017
818689d
Update readme for networks option
cgewecke Apr 21, 2017
eacbe63
Run testrpc with 35 accounts (uport-proxy) / allow configuration
cgewecke Apr 21, 2017
440bd8b
Fix chained constructor/method call bug. Add compilation unit test fo…
cgewecke Apr 23, 2017
769c7f8
Add lint script to package.json
cgewecke Apr 23, 2017
21d3c04
Fix empty contract body parsing bug. Add coverage unit test for case
cgewecke Apr 24, 2017
e65a035
Update README with known issues, links to zeppelin example report
cgewecke Apr 24, 2017
381285c
Allow testrpc options string in config, rename run to cli (test seque…
cgewecke Apr 24, 2017
7617134
Add unit test for arbitrary testing command config option, remove tes…
cgewecke Apr 24, 2017
4b627f6
Fix broken chained call handling, add unit tests to verify cases get …
cgewecke Apr 24, 2017
8223aec
Rename "run" folders/files "cli" for consistency
cgewecke Apr 24, 2017
2f933a6
Disable two "config" tests for CI - multiple testrpc launches max out…
cgewecke Apr 24, 2017
c47f160
README updates for .solcover.js config options, more example reports
cgewecke Apr 25, 2017
48e77b2
Misc edits for clarity
cgewecke Apr 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Misc edits for clarity
  • Loading branch information
cgewecke committed Apr 25, 2017
commit 48e77b290f571cb787eec1bce173c0583a247cc3
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
### Code coverage for Solidity testing
![coverage example](https://cdn-images-1.medium.com/max/800/1*uum8t-31bUaa6dTRVVhj6w.png)

For more details about what this is, how it work and potential limitations, see
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).

This branch is an attempt to prepare solcover for npm publication and simplify its use as a
command line utility. Gas cost issues are managed under the hood and the tool cleans up after
itself if (when) it crashes.

### Install
```
$ npm install --save-dev https://github.com/JoinColony/solcover.git#truffle3
Expand All @@ -24,18 +20,19 @@ $ ./node_modules/solcover/exec.js
```

Tests run signficantly slower while coverage is being generated. A 1 to 2 minute delay
between the end of Truffle compilation and the beginning of test execution is not impossible if your
between the end of Truffle compilation and the beginning of test execution is possible if your
test suite is large. Large solidity files can also take a while to instrument.

### Configuration

By default, solcover generates a stub `truffle.js` that accomodates its special gas needs and
connects to a modified version of testrpc on port 8555. If your tests can run on the development network
By default, Solcover generates a stub `truffle.js` that accomodates its special gas needs and
connects to a modified version of testrpc on port 8555. If your tests will run on the development network
using a standard `truffle.js` and a testrpc instance with no special options, you shouldn't have to
do any configuration. If your tests depend on logic added to `truffle.js` - for example:
[zeppelin-solidity](https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/truffle.js)
uses the file to expose a babel polyfill that its suite needs to run correctly - you can override the
default behavior by specifying a coverage network in `truffle.js`.
uses the file to expose a babel polyfill that its suite requires - you can override the
default behavior by declaring a coverage network in `truffle.js`. Solcover will use your 'truffle.js'
instead of a dynamically generated one.

**Example coverage network config**
```javascript
Expand All @@ -61,12 +58,14 @@ You can also create a `.solcover.js` config file in the root directory of your p
some additional options:
+ **port**: <Number> The port you want Solcover to run testrpc on / have truffle connect to.
+ **testrpcOptions**: <String> A string of options to be appended to a command line invocation
of testrpc. Ex: `--account="0x89a..f',10000" --port 8777`". If you use this option specify the port
in your testrpcOptions string AND as a `port` option.
of testrpc.
+ Example: `--account="0x89a...b1f',10000" --port 8777`".
+ Note: you should specify the port in your `testrpcOptions` string AND as a `port` option.
+ **testCommand**: <String> By default Solcover runs `truffle test` or `truffle test --network coverage`.
`testCommand` let you run tests some other way: ex: `mocha --timeout 5000`. If you're doing this, you
will probably need to make sure the web3 provider for your tests explicitly connects to the port solcover's
testrpc is set to run on, e.g: `var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8555"))`
This option lets you run tests some other way: ex: `mocha --timeout 5000`. You
will probably also need to make sure the web3 provider for your tests explicitly connects to the port Solcover's
testrpc is set to run on, e.g:
+ `var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8555"))`

**Example .solcover.js config file**
```
Expand All @@ -84,20 +83,20 @@ This is because the instrumentation process increases the gas costs for using th
the extra events. If this is the case, then the coverage may be incomplete. To avoid this, using
`estimateGas` to estimate your gas costs should be more resilient in most cases.

**Events testing**: Solcover injects events into your solidity files to log which lines your tests reach,
so any tests that depend on how many events are fired or where the event sits in the logs array
**Events testing**: Because Solcover injects events into your contracts to log which lines your tests reach,
any tests that ask how many events are fired or where the event sits in the logs array
will probably error while coverage is being generated.

**Using `require` in `migrations.js` files**: Truffle overloads Node's `require` function but
implements a simplified search algorithm for node_modules packages
([see issue #383 at Truffle](https://github.com/trufflesuite/truffle/issues/383)).
Because Solcover copies an instrumented version of your project into a temporary folder, `require`
statements handled by Truffle internally don't resolve correctly.
statements handled by Truffle internally won't resolve correctly.

**Coveralls / CodeCov**: These CI services take the Istanbul reports generated by Solcover and display
line coverage. Istanbul's own html report provides significantly more detailed
reporting and can show whether your tests actually cover all the conditional branches
in your code. It can be found inside the `coverage` folder at `index.html` after you run the tool.
line coverage. Istanbul's own html report publishes significantly more detail and can show whether
your tests actually reach all the conditional branches in your code. It can be found inside the
`coverage` folder at `index.html` after you run the tool.

### Examples

Expand Down