Skip to content

Commit 9223656

Browse files
committed
Misc docs changes and rename plugin.ui.js
1 parent 5174ecd commit 9223656

File tree

5 files changed

+79
-206
lines changed

5 files changed

+79
-206
lines changed

README.md

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,11 @@
1616

1717
## Install
1818
```
19-
$ npm install --save-dev solidity-coverage
19+
$ yarn add solidity-coverage --dev
2020
```
2121

2222
**Resources**:
23-
+ [0.7.0 release notes][31]
24-
+ [A guide][29] to upgrading from 0.6.x to 0.7.x
25-
+ [0.6.3 docs][30]
26-
27-
### Truffle V5
28-
29-
**Add** this package to your plugins array in `truffle-config.js` ([Truffle docs][27])
30-
```javascript
31-
module.exports = {
32-
networks: {...},
33-
plugins: ["solidity-coverage"]
34-
}
35-
```
36-
**Run**
37-
```
38-
truffle run coverage [command-options]
39-
```
23+
+ [0.8.0 release notes][31]
4024

4125
### Hardhat
4226

@@ -70,10 +54,9 @@ A working example can be found at [openzeppelin-contracts, here.][35]
7054
## Command Options
7155
| Option <img width=200/> | Example <img width=750/>| Description <img width=1000/> |
7256
|--------------|------------------------------------|--------------------------------|
73-
| file | `--file="test/registry/*.js"` | (Truffle) Filename or glob describing a subset of tests to run. (Globs must be enclosed by quotes and use [globby matching patterns][38])|
74-
| testfiles | `--testfiles "test/registry/*.ts"` | (Buidler) Test file(s) to run. (Globs must be enclosed by quotes and use [globby matching patterns][38])|
57+
| testfiles | `--testfiles "test/registry/*.ts"` | Test file(s) to run. (Globs must be enclosed by quotes and use [globby matching patterns][38])|
7558
| solcoverjs | `--solcoverjs ./../.solcover.js` | Relative path from working directory to config. Useful for monorepo packages that share settings. (Path must be "./" prefixed) |
76-
| network | `--network development` | Use network settings defined in the Truffle or Buidler config |
59+
| network | `--network development` | Use network settings defined in the Hardhat config |
7760
| temp[<sup>*</sup>][14] | `--temp build` | :warning: **Caution** :warning: Path to a *disposable* folder to store compilation artifacts in. Useful when your test setup scripts include hard-coded paths to a build directory. [More...][14] |
7861

7962
[<sup>*</sup> Advanced use][14]

docs/advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ stage the compilation artifacts of instrumented contracts in before the tests ar
7575

7676
**Example**
7777
```
78-
$ truffle run coverage --temp build
78+
$ hardhat coverage --temp build
7979
```
8080

8181
By default this folder is called `.coverage_artifacts`. If you already have

docs/faq.md

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,15 @@
1010

1111
## Continuous Integration
1212

13-
An example using Truffle MetaCoin, TravisCI, and Coveralls:
13+
**Examples**
14+
+ [Github Actions and CodeCov][8] (OpenZeppelin)
15+
+ [CircleCI and Coveralls with coverage split into parallelized jobs][7] (SetProtocol)
1416

15-
**Step 1: Create a metacoin project & install coverage tools**
16-
17-
```bash
18-
$ mkdir metacoin && cd metacoin
19-
$ truffle unbox metacoin
20-
21-
# Install coverage and development dependencies
22-
$ npm init
23-
$ npm install --save-dev truffle
24-
$ npm install --save-dev coveralls
25-
$ npm install --save-dev solidity-coverage
26-
```
27-
28-
**Step 2: Add solidity-coverage to the plugins array in truffle-config.js:**
29-
30-
```javascript
31-
module.exports = {
32-
networks: {...},
33-
plugins: ["solidity-coverage"]
34-
}
35-
```
36-
37-
**Step 3: Create a .travis.yml:**
38-
39-
```yml
40-
dist: trusty
41-
language: node_js
42-
node_js:
43-
- '10'
44-
install:
45-
- npm install
46-
script:
47-
- npx truffle run coverage
48-
- cat coverage/lcov.info | coveralls
49-
```
5017
**NB:** It's best practice to run coverage as a separate CI job rather than assume its
5118
equivalence to `test`. Coverage uses block gas settings far above the network limits,
5219
ignores [EIP 170][4] and rewrites your contracts in ways that might affect
5320
their behavior.
5421

55-
**Step 4: Toggle the project on at Travis and Coveralls and push.**
56-
57-
[It should look like this][1]
58-
5922
**Appendix: Coveralls vs. Codecov**
6023

6124
**TLDR: We recommend Coveralls for the accuracy of its branch reporting.**
@@ -71,11 +34,8 @@ If your target contains dozens (and dozens) of large contracts, you may run up a
7134
contract compilation step. This can be addressed by setting the size of the memory space allocated to the command
7235
when you run it.
7336
```
74-
// Truffle
75-
$ node --max-old-space-size=4096 ./node_modules/.bin/truffle run coverage [options]
76-
77-
// Buidler
78-
$ node --max-old-space-size=4096 ./node_modules/.bin/buidler coverage [options]
37+
// Hardhat
38+
$ node --max-old-space-size=4096 ./node_modules/.bin/hardhat coverage [options]
7939
```
8040

8141
`solcjs` also has some limits on the size of the code bundle it can process. If you see errors like:
@@ -112,7 +72,7 @@ uint x = 5; uint y = 7;
11272

11373
## Running out of time
11474

115-
Truffle sets a default mocha timeout of 5 minutes. Because tests run slower under coverage, it's possible to hit this limit with a test that iterates hundreds of times before producing a result. Timeouts can be disabled by configuring the mocha option in `.solcover.js` as below: (ProTip courtesy of [@cag](https://github.com/cag))
75+
Because tests run slower under coverage, it's possible to hit default mocha time limits with a test that iterates hundreds of times before producing a result. Timeouts can be disabled by configuring the mocha option in `.solcover.js` as below: (ProTip courtesy of [@cag](https://github.com/cag))
11676

11777
```javascript
11878
module.exports = {
@@ -185,3 +145,5 @@ If an `assert` or `require` is marked with an `I` in the coverage report, then d
185145
[2]: https://codecov.io/
186146
[3]: https://user-images.githubusercontent.com/7332026/28502310-6851f79c-6fa4-11e7-8c80-c8fd80808092.png
187147
[4]: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-170.md
148+
[7]: https://github.com/SetProtocol/set-v2-strategies/blob/29db4a3de4a6ecd55a2c86d85a002b7e1106f8b2/.circleci/config.yml#L79-L143
149+
[8]: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/c12076fb7e3dfe48ef1d9c3bb2a58bdd3ffc0cee/.github/workflows/test.yml#L36-L56

docs/upgrade.md

Lines changed: 0 additions & 138 deletions
This file was deleted.

plugins/resources/plugin.ui.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const UI = require('./../../lib/ui').UI;
2+
3+
/**
4+
* Plugin logging
5+
*/
6+
class PluginUI extends UI {
7+
constructor(log){
8+
super(log);
9+
}
10+
11+
/**
12+
* Writes a formatted message via log
13+
* @param {String} kind message selector
14+
* @param {String[]} args info to inject into template
15+
*/
16+
report(kind, args=[]){
17+
const c = this.chalk;
18+
const ct = c.bold.green('>');
19+
const ds = c.bold.yellow('>');
20+
const w = ":warning:";
21+
22+
const kinds = {
23+
24+
'instr-skip': `\n${c.bold('Coverage skipped for:')}` +
25+
`\n${c.bold('=====================')}\n`,
26+
27+
'instr-skipped': `${ds} ${c.grey(args[0])}`,
28+
29+
'network': `\n${c.bold('Network Info')}` +
30+
`\n${c.bold('============')}\n` +
31+
`${ct} ${c.bold('id')}: ${args[1]}\n` +
32+
`${ct} ${c.bold('port')}: ${args[2]}\n` +
33+
`${ct} ${c.bold('network')}: ${args[0]}\n`,
34+
35+
}
36+
37+
this._write(kinds[kind]);
38+
}
39+
40+
/**
41+
* Returns a formatted message. Useful for error message.
42+
* @param {String} kind message selector
43+
* @param {String[]} args info to inject into template
44+
* @return {String} message
45+
*/
46+
generate(kind, args=[]){
47+
const c = this.chalk;
48+
const x = ":x:";
49+
50+
const kinds = {
51+
52+
'sources-fail': `${c.red('Cannot locate expected contract sources folder: ')} ${args[0]}`,
53+
54+
'solcoverjs-fail': `${c.red('Could not load .solcover.js config file. ')}` +
55+
`${c.red('This can happen if it has a syntax error or ')}` +
56+
`${c.red('the path you specified for it is wrong.')}`,
57+
58+
'tests-fail': `${x} ${c.bold(args[0])} ${c.red('test(s) failed under coverage.')}`,
59+
}
60+
61+
62+
return this._format(kinds[kind])
63+
}
64+
}
65+
66+
module.exports = PluginUI;

0 commit comments

Comments
 (0)