Skip to content

Commit 212c88f

Browse files
authored
Merge pull request #421 from sc-forks/buidler-plugin
Add Buidler plugin / Finalize API
2 parents a43ee65 + 28ab3d2 commit 212c88f

File tree

104 files changed

+3731
-1243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+3731
-1243
lines changed

.circleci/config.yml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: 2.0
2-
# Necessary for running in machine mode, which is necessary to execute the
3-
# Zeppelin and MetaCoin E2E scripts
2+
3+
# Necessary for running in machine mode,
4+
# which is necessary to execute the E2E scripts
45
step_install_nvm: &step_install_nvm
56
run:
67
name: "Install nvm for machine"
@@ -12,6 +13,7 @@ step_install_nvm: &step_install_nvm
1213
nvm alias default v8.15.0
1314
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
1415
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
16+
1517
jobs:
1618
unit-test:
1719
machine: true
@@ -73,23 +75,30 @@ jobs:
7375
name: MetaCoin E2E
7476
command: |
7577
./scripts/run-metacoin.sh
78+
e2e-buidler:
79+
machine: true
80+
steps:
81+
- checkout
82+
- <<: *step_install_nvm
83+
- run:
84+
name: Buidler E2E
85+
command: |
86+
./scripts/run-buidler.sh
87+
e2e-moloch:
88+
machine: true
89+
steps:
90+
- checkout
91+
- <<: *step_install_nvm
92+
- run:
93+
name: Moloch E2E
94+
command: |
95+
./scripts/run-moloch.sh
7696
workflows:
7797
version: 2
7898
build:
7999
jobs:
80100
- unit-test
81101
- e2e-zeppelin
82102
- e2e-metacoin
83-
# TODO: re-enable.
84-
# At the moment we're using forks so this is pointless
85-
#nightly:
86-
# triggers:
87-
# - schedule:
88-
# cron: "0 1 * * *" # 1am UTC
89-
# filters:
90-
# branches:
91-
# only:
92-
# - master
93-
# jobs:
94-
#- e2e-zeppelin
95-
#- e2e-colony
103+
- e2e-buidler
104+
- e2e-moloch

README.md

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
![npm (tag)](https://img.shields.io/npm/v/solidity-coverage/beta)
55
[![CircleCI](https://circleci.com/gh/sc-forks/solidity-coverage.svg?style=svg)][20]
66
[![codecov](https://codecov.io/gh/sc-forks/solidity-coverage/branch/beta/graph/badge.svg)][21]
7+
[![buidler](https://buidler.dev/buidler-plugin-badge.svg?1)][26]
8+
79

810
## Code coverage for Solidity testing
911
![coverage example][22]
@@ -17,9 +19,9 @@
1719
$ npm install --save-dev solidity-coverage@beta
1820
```
1921

20-
## Truffle V5
22+
### Truffle V5
2123

22-
**Add** this package to your plugins array in `truffle-config.js`
24+
**Add** this package to your plugins array in `truffle-config.js` ([Truffle docs][27])
2325
```javascript
2426
module.exports = {
2527
networks: {...},
@@ -31,22 +33,36 @@ module.exports = {
3133
truffle run coverage [command-options]
3234
```
3335

36+
### Buidler
37+
38+
**Add** the plugin in `buidler.config.js` ([Buidler docs][26])
39+
```javascript
40+
usePlugin('solidity-coverage')
41+
42+
module.exports = {
43+
networks: {...},
44+
}
45+
```
46+
**Run**
47+
```
48+
npx buidler coverage [command-options]
49+
```
50+
3451
## Usage notes:
3552
+ Coverage runs tests a little more slowly.
3653
+ Coverage launches its own in-process ganache server.
3754
+ You can set [ganache options][1] using the `providerOptions` key in your `.solcover.js` [config][15].
3855
+ Coverage [distorts gas consumption][13]. Tests that check exact gas consumption should be [skipped][24].
39-
+ :warning: Contracts are compiled **without optimization**. Please report unexpected compilation faults to [issue 417][25]
56+
+ :warning: Contracts are compiled **without optimization**. Please report unexpected compilation faults to [issue 417][25]
4057

4158
## Command Options
4259
| Option <img width=200/> | Example <img width=750/>| Description <img width=1000/> |
4360
|--------------|------------------------------------|--------------------------------|
44-
| file | `--file="test/registry/*.js"` | Filename or glob describing a subset of JS tests to run. (Globs must be enclosed by quotes.)|
61+
| file | `--file="test/registry/*.js"` | (Truffle) Filename or glob describing a subset of JS tests to run. (Globs must be enclosed by quotes.)|
62+
| testfiles | `--testfiles test/file.js` | (Buidler) JS test file(s) to run.|
4563
| solcoverjs | `--solcoverjs ./../.solcover.js` | Relative path from working directory to config. Useful for monorepo packages that share settings. (Path must be "./" prefixed) |
46-
| network | `--network development` | Use network settings defined in the Truffle config |
64+
| network | `--network development` | Use network settings defined in the Truffle or Buidler config |
4765
| 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] |
48-
| version | | Version info |
49-
| help | | Usage notes |
5066

5167
[<sup>*</sup> Advanced use][14]
5268

@@ -63,21 +79,32 @@ module.exports = {
6379
```
6480

6581

66-
| Option <img width=200/>| Type <img width=200/> | Default <img width=700/> | Description <img width=1000/> |
82+
| Option <img width=200/>| Type <img width=200/> | Default <img width=1300/> | Description <img width=800/> |
6783
| ------ | ---- | ------- | ----------- |
6884
| silent | *Boolean* | false | Suppress logging output |
6985
| client | *Object* | `require("ganache-core")` | Useful if you need a specific ganache version. |
7086
| providerOptions | *Object* | `{ }` | [ganache-core options][1] |
7187
| skipFiles | *Array* | `['Migrations.sol']` | Array of contracts or folders (with paths expressed relative to the `contracts` directory) that should be skipped when doing instrumentation. |
72-
| istanbulReporter | *Array* | `['html', 'lcov', 'text']` | [Istanbul coverage reporters][2] |
88+
| istanbulFolder | *String* | `./coverage` | Folder location for Istanbul coverage reports. |
89+
| istanbulReporter | *Array* | `['html', 'lcov', 'text', 'json']` | [Istanbul coverage reporters][2] |
7390
| mocha | *Object* | `{ }` | [Mocha options][3] to merge into existing mocha config. `grep` and `invert` are useful for skipping certain tests under coverage using tags in the test descriptions.|
7491
| onServerReady[<sup>*</sup>][14] | *Function* | | Hook run *after* server is launched, *before* the tests execute. Useful if you need to use the Oraclize bridge or have setup scripts which rely on the server's availability. [More...][23] |
7592
| onCompileComplete[<sup>*</sup>][14] | *Function* | | Hook run *after* compilation completes, *before* tests are run. Useful if you have secondary compilation steps or need to modify built artifacts. [More...][23]|
76-
| onTestsComplete[<sup>*</sup>][14] | *Function* | | Hook run *after* the tests complete, *before* Istanbul reports are generated.|
77-
| onIstanbulComplete[<sup>*</sup>][14] | *Function* | | Hook run *after* the Istanbul reports are generated, *before* the ganache server is shut down. Useful if you need to clean resources up.|
93+
| onTestsComplete[<sup>*</sup>][14] | *Function* | | Hook run *after* the tests complete, *before* Istanbul reports are generated. [More...][23]|
94+
| onIstanbulComplete[<sup>*</sup>][14] | *Function* | | Hook run *after* the Istanbul reports are generated, *before* the ganache server is shut down. Useful if you need to clean resources up. [More...][23]|
7895

7996
[<sup>*</sup> Advanced use][14]
8097

98+
## API
99+
100+
Solidity-coverage's core methods and many utilities are available as an API.
101+
102+
```javascript
103+
const CoverageAPI = require('solidity-coverage/api');
104+
```
105+
106+
[Documentation available here][28].
107+
81108
## FAQ
82109

83110
Common problems & questions:
@@ -152,3 +179,6 @@ $ yarn
152179
[23]: https://github.com/sc-forks/solidity-coverage/blob/beta/docs/advanced.md#workflow-hooks
153180
[24]: https://github.com/sc-forks/solidity-coverage/blob/beta/docs/advanced.md#skipping-tests
154181
[25]: https://github.com/sc-forks/solidity-coverage/issues/417
182+
[26]: https://buidler.dev/
183+
[27]: https://www.trufflesuite.com/docs
184+
[28]: https://github.com/sc-forks/solidity-coverage/blob/beta/docs/api.md

api.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// For require('solidity-coverage/api');
2+
const api = require('./lib/api');
3+
4+
module.exports = api;

buidler.config.js

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

dist/buidler.plugin.js

Whitespace-only changes.

0 commit comments

Comments
 (0)