Skip to content

Commit a5e2496

Browse files
authored
Merge pull request #61 from sc-forks/memory-readme
README updates: remove require info, add memory info
2 parents 89b9a47 + fda1bb0 commit a5e2496

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ can be useful if you are using a different vm like the [sc-forks version of pyet
7575
+ **dir**: *{ String }* : Solidity-coverage usually looks for `contracts` and `test` folders in your root
7676
directory. `dir` allows you to define a relative path from the root directory to those assets.
7777
`dir: "./<dirname>"` would tell solidity-coverage to look for `./<dirname>/contracts/` and `./<dirname>/test/`
78-
+ **copyNodeModules**: *{ Boolean }* : When true, will copy `node_modules` into the coverage environment. False by default, and may significantly increase the time for coverage to complete if enabled. Only enable if required.
79-
+ **skipFiles**: *{ Array }* : An 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.
78+
+ **copyNodeModules**: *{ Boolean }* : When true, will copy `node_modules` into the coverage environment.
79+
False by default, and may significantly increase the time for coverage to complete if enabled. Only enable if required.
80+
+ **skipFiles**: *{ Array }* : An array of contracts (with paths expressed relative to the `contracts` directory)
81+
that should be skipped when doing instrumentation. `Migrations.sol` is skipped by default,
82+
and does not need to be added to this configuration option if it is used.
8083

8184
**Example .solcover.js config file**
8285
```javascript
@@ -116,22 +119,32 @@ MyContract.deployed().then(instance => {
116119
})
117120
});
118121
```
119-
**Using `require` in `migrations.js` files**: Truffle overloads Node's `require` function but
120-
implements a simplified search algorithm for node_modules packages
121-
([see Truffle issue #383](https://github.com/trufflesuite/truffle/issues/383)).
122-
Because solidity-coverage copies an instrumented version of your project into a temporary folder, `require`
123-
statements handled by Truffle internally won't resolve correctly.
124122

125123
**Using HDWalletProvider in `truffle.js`**: [See Truffle issue #348](https://github.com/trufflesuite/truffle/issues/348).
126124
HDWalletProvider crashes solidity-coverage, so its constructor shouldn't be invoked while running this tool.
127125
A workaround can be found at the zeppelin-solidity project
128126
[here](https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/truffle.js#L8-L10), where a
129127
shell script is used to set an environment variable which `truffle.js` checks before instantiating the wallet.
130128

131-
**Getting `Error: Invalid JSON RPC response: ""`** after the instrumentation or compilation steps. This can be resolved by setting the `norpc` option in `.solcover.js` to `true` and launching testrpc-sc from the command line in another window with:
129+
**Getting `Error: Invalid JSON RPC response: ""`** after the instrumentation or compilation steps.
130+
This error is intermittent and mysterious, affecting some projects more than others.
131+
Can be resolved by setting the `norpc` option in
132+
`.solcover.js` to `true` and launching testrpc-sc from the command line in another window with:
132133
+ `./node_modules/ethereumjs-testrpc-sc/bin/testrpc --gasLimit 0xfffffffffff --port 8555`.
133134
+ (ProTip courtesy of [@maurelian](https://github.com/maurelian) )
134135

136+
**Running out of memory**: (See [issue #59](https://github.com/sc-forks/solidity-coverage/issues/59)).
137+
If your target contains dozens of contracts, you may run up against node's 1.7MB memory cap during the
138+
contract compilation step. This can be addressed by setting the `testCommand` option in `.solcover.js` as
139+
below (note the path - it reaches outside a temporarily generated `coverageEnv` folder to access a locally
140+
installed version of truffle in your root directory's node_modules):
141+
```javascript
142+
testCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage'
143+
```
144+
Large projects may also hit their CI container memcap running coverage after unit tests. This can be
145+
addressed on TravisCI by adding `sudo: required` to the `travis.yml`, which raises the container's
146+
limit to 7.5MB (ProTip courtesy of [@federicobond](https://github.com/federicobond).
147+
135148
### Examples
136149

137150
**WARNING**: This utility is in development and its accuracy is unknown. If you

0 commit comments

Comments
 (0)