parent
5174ecdfce
commit
922365685b
@ -1,138 +0,0 @@ |
||||
# How to install 0.7.0 |
||||
|
||||
**Install** |
||||
``` |
||||
$ npm install --save-dev solidity-coverage |
||||
``` |
||||
|
||||
**Add** this package to your plugins array in `truffle-config.js` |
||||
```javascript |
||||
module.exports = { |
||||
networks: {...}, |
||||
plugins: ["solidity-coverage"] |
||||
} |
||||
``` |
||||
**Run** |
||||
``` |
||||
truffle run coverage [command-options] |
||||
``` |
||||
|
||||
A full list of options and other information are [available here][8] |
||||
|
||||
# Upgrading from 0.6.x to 0.7.x |
||||
|
||||
First, follow [the installation instructions](#how-to-install-070) and see if it works. |
||||
|
||||
:rabbit2: It does!? Bye. |
||||
|
||||
:elephant: It does not. |
||||
|
||||
#### Are you using Truffle V5? |
||||
|
||||
+ Everything works best with Truffle versions >= 5.0.31. |
||||
|
||||
#### Are you launching testrpc-sc yourself as a stand-alone client? |
||||
|
||||
+ Stop launching it. The coverage plugin needs to initialize the client itself so it can hook into the EVM. |
||||
|
||||
+ By default it uses the ganache bundled with Truffle, but you can use any version (see below). |
||||
|
||||
#### Were you passing testrpc-sc lots of options as flags? :jp: :jp: :jp: :jp: :jp: |
||||
|
||||
+ If the flags were `allowUnlimitedContractSize`, `gasLimit`, `gasPrice` or `emitFreeLogs`, |
||||
you can safely ignore them. Ditto if your port was `8555`. |
||||
|
||||
+ If the flags were things like `--account` or `-i`, you'll need to transfer them as |
||||
[ganache-core options][1] to the `providerOptions` key in .solcover.js. |
||||
|
||||
+ Ganache's "cli flag" and "js option" formats are slightly different. Check out [their docs][1] |
||||
|
||||
**Example** |
||||
|
||||
*Before (at the command line)* |
||||
``` |
||||
$ testrpc-sc --account="0x2b...7cd,1000000000000000000000000" -i 1999 --noVmErrorsOnRPCResponse |
||||
``` |
||||
|
||||
*Now (in .solcover.js)* |
||||
```javascript |
||||
providerOptions: { |
||||
accounts: [{ |
||||
secretKey: "0x2b.............7cd", |
||||
balance: "0xD3C21BCECCEDA1000000" // <-- Must be hex |
||||
}], |
||||
network_id: 1999, |
||||
vmErrorsOnRPCResponse: false |
||||
} |
||||
|
||||
#### Do you have a 'coverage' network in truffle-config.js? |
||||
|
||||
+ If you copy-pasted it from the <= 0.6.x docs, **you can safely delete it**. |
||||
|
||||
+ You should be able to `truffle run coverage --network <network-name>` and use the same config you |
||||
run your regular tests with. |
||||
|
||||
+ You can also omit the network flag and you'll be given default settings which look like this: |
||||
```javascript |
||||
'soliditycoverage': { |
||||
port: 8555, |
||||
host: "127.0.0.1", |
||||
network_id: "*", |
||||
} |
||||
``` |
||||
#### Do your tests depend on the specific ganache version you have as a local dependency? |
||||
|
||||
+ Declare it in .solcover.js using the client option |
||||
```javascript |
||||
client: require('ganache-cli'), |
||||
``` |
||||
|
||||
#### Does your config contain any deprecated options? |
||||
+ They are: |
||||
``` |
||||
accounts, # Now: `providerOptions: { total_accounts: <number> }` |
||||
buildDirPath, # Now: `--temp <path>` (At the command line, see Advanced Use) |
||||
copyPackages, |
||||
copyNodeModules, |
||||
deepSkip, |
||||
testCommand, |
||||
compileCommand, |
||||
noRpc |
||||
``` |
||||
|
||||
+ You can delete them. |
||||
|
||||
#### Do you usually: (1) launch testrpc-sc, (2) do something special, (3) run solidity-coverage? |
||||
|
||||
+ See [the workflow hooks documentation][3]. The "something special" will likely need to run within |
||||
an async function declared in .solcover.js |
||||
|
||||
#### Are you what some might call an 'advanced user'? |
||||
|
||||
+ See [Advanced Use][2] |
||||
|
||||
#### Would you like to see some real-world installation examples? |
||||
|
||||
+ [metacoin][4] |
||||
+ [openzeppelin-contracts][5] |
||||
+ [joinColony/colonyNetwork][6] |
||||
+ [aragon/aragon-court][7] |
||||
|
||||
#### :tada: It's still not working!! :tada: |
||||
|
||||
+ If your project is public, please open an issue linking to it and we will advise and/or |
||||
open a PR into your repo installing solidity-coverage after patching any relevant bugs here. |
||||
|
||||
+ If your project is private, see if you can generate a reproduction case for the |
||||
problem and we'll try to fix that. |
||||
|
||||
|
||||
[1]: https://github.com/trufflesuite/ganache-core#options |
||||
[2]: https://github.com/sc-forks/solidity-coverage/blob/master/docs/advanced.md |
||||
[3]: https://github.com/sc-forks/solidity-coverage/blob/master/docs/advanced.md#workflow-hooks |
||||
[4]: https://github.com/sc-forks/metacoin |
||||
[5]: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/1923 |
||||
[6]: https://github.com/JoinColony/colonyNetwork/pull/716 |
||||
[7]: https://github.com/aragon/aragon-court/pull/123 |
||||
[8]: https://github.com/sc-forks/solidity-coverage/tree/master#command-options |
||||
|
@ -0,0 +1,66 @@ |
||||
const UI = require('./../../lib/ui').UI; |
||||
|
||||
/** |
||||
* Plugin logging |
||||
*/ |
||||
class PluginUI extends UI { |
||||
constructor(log){ |
||||
super(log); |
||||
} |
||||
|
||||
/** |
||||
* Writes a formatted message via log |
||||
* @param {String} kind message selector |
||||
* @param {String[]} args info to inject into template |
||||
*/ |
||||
report(kind, args=[]){ |
||||
const c = this.chalk; |
||||
const ct = c.bold.green('>'); |
||||
const ds = c.bold.yellow('>'); |
||||
const w = ":warning:"; |
||||
|
||||
const kinds = { |
||||
|
||||
'instr-skip': `\n${c.bold('Coverage skipped for:')}` + |
||||
`\n${c.bold('=====================')}\n`, |
||||
|
||||
'instr-skipped': `${ds} ${c.grey(args[0])}`, |
||||
|
||||
'network': `\n${c.bold('Network Info')}` + |
||||
`\n${c.bold('============')}\n` + |
||||
`${ct} ${c.bold('id')}: ${args[1]}\n` + |
||||
`${ct} ${c.bold('port')}: ${args[2]}\n` + |
||||
`${ct} ${c.bold('network')}: ${args[0]}\n`, |
||||
|
||||
} |
||||
|
||||
this._write(kinds[kind]); |
||||
} |
||||
|
||||
/** |
||||
* Returns a formatted message. Useful for error message. |
||||
* @param {String} kind message selector |
||||
* @param {String[]} args info to inject into template |
||||
* @return {String} message |
||||
*/ |
||||
generate(kind, args=[]){ |
||||
const c = this.chalk; |
||||
const x = ":x:"; |
||||
|
||||
const kinds = { |
||||
|
||||
'sources-fail': `${c.red('Cannot locate expected contract sources folder: ')} ${args[0]}`, |
||||
|
||||
'solcoverjs-fail': `${c.red('Could not load .solcover.js config file. ')}` + |
||||
`${c.red('This can happen if it has a syntax error or ')}` + |
||||
`${c.red('the path you specified for it is wrong.')}`, |
||||
|
||||
'tests-fail': `${x} ${c.bold(args[0])} ${c.red('test(s) failed under coverage.')}`, |
||||
} |
||||
|
||||
|
||||
return this._format(kinds[kind]) |
||||
} |
||||
} |
||||
|
||||
module.exports = PluginUI; |
Loading…
Reference in new issue