Skip to content

Commit bc7d076

Browse files
authored
0.8.0 Additional Coverage Measurements & Restructure (Merge)
2 parents 9223656 + a7db2fe commit bc7d076

File tree

265 files changed

+7040
-7639
lines changed

Some content is hidden

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

265 files changed

+7040
-7639
lines changed

.circleci/config.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ jobs:
2727
name: Delete any old node_modules
2828
command: |
2929
rm -rf node_modules/
30-
- run:
31-
name: Install truffle (globally)
32-
command: |
33-
sudo npm install -g truffle
3430
- run:
3531
name: Install dependencies
3632
command: |
@@ -54,23 +50,6 @@ jobs:
5450
name: Zeppelin E2E
5551
command: |
5652
./scripts/run-zeppelin.sh
57-
e2e-metacoin:
58-
machine: true
59-
steps:
60-
- checkout
61-
- <<: *step_install_nvm
62-
- run:
63-
name: MetaCoin E2E
64-
command: |
65-
./scripts/run-metacoin.sh
66-
e2e-metacoin-windows:
67-
executor: win/default
68-
steps:
69-
- checkout
70-
- run:
71-
name: Windows Metacoin E2E
72-
command: |
73-
bash ./scripts/run-metacoin.sh
7453
e2e-nomiclabs:
7554
machine: true
7655
steps:
@@ -86,6 +65,4 @@ workflows:
8665
jobs:
8766
- unit-test
8867
- e2e-zeppelin
89-
- e2e-metacoin
90-
- e2e-metacoin-windows
9168
- e2e-nomiclabs

BUIDLER_README.md

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

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ A working example can be found at [openzeppelin-contracts, here.][35]
5858
| solcoverjs | `--solcoverjs ./../.solcover.js` | Relative path from working directory to config. Useful for monorepo packages that share settings. (Path must be "./" prefixed) |
5959
| network | `--network development` | Use network settings defined in the Hardhat config |
6060
| 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] |
61+
| matrix | `--matrix` | Generate a JSON object that maps which mocha tests hit which lines of code. (Useful
62+
as an input for some fuzzing, mutation testing and fault-localization algorithms.) [More...][39]|
6163

6264
[<sup>*</sup> Advanced use][14]
6365

@@ -76,11 +78,14 @@ module.exports = {
7678
| Option <img width=200/>| Type <img width=200/> | Default <img width=1300/> | Description <img width=800/> |
7779
| ------ | ---- | ------- | ----------- |
7880
| silent | *Boolean* | false | Suppress logging output |
79-
| client | *Object* | `require("ganache-core")` | Useful if you need a specific ganache version. |
80-
| providerOptions | *Object* | `{ }` | [ganache-core options][1] |
8181
| skipFiles | *Array* | `['Migrations.sol']` | Array of contracts or folders (with paths expressed relative to the `contracts` directory) that should be skipped when doing instrumentation. |
8282
| measureStatementCoverage | *boolean* | `true` | Computes statement (in addition to line) coverage. [More...][34] |
8383
| measureFunctionCoverage | *boolean* | `true` | Computes function coverage. [More...][34] |
84+
| measureModifierCoverage | *boolean* | `true` | Computes each modifier invocation as a code branch. [More...][34] |
85+
| modifierWhitelist | *String[]* | `[]` | List of modifier names (ex: "onlyOwner") to exclude from branch measurement. (Useful for modifiers which prepare something instead of acting as a gate.)) |
86+
| matrixOutputPath | *String* | `./testMatrix.json` | Relative path to write test matrix JSON object to. [More...][39]|
87+
| mochaJsonOutputPath | *String* | `./mochaOutput.json` | Relative path to write mocha JSON reporter object to. [More...][39]|
88+
| abiOutputPath | *String* | `./humanReadableAbis.json` | Relative path to write diff-able ABI data to |
8489
| istanbulFolder | *String* | `./coverage` | Folder location for Istanbul coverage reports. |
8590
| istanbulReporter | *Array* | `['html', 'lcov', 'text', 'json']` | [Istanbul coverage reporters][2] |
8691
| 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.|
@@ -92,6 +97,9 @@ module.exports = {
9297
| 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]|
9398
| configureYulOptimizer | *Boolean* | false | (Experimental) Setting to `true` should resolve "stack too deep" compiler errors in large projects using ABIEncoderV2 |
9499
| solcOptimizerDetails | *Object* | `undefined` |(Experimental) Must be used in combination with `configureYulOptimizer`. Allows you configure solc's [optimizer details][1001]. Useful if the default remedy for stack-too-deep errors doesn't work in your case (See FAQ below). |
100+
| client | *Object* | `require("ganache-core")` | Ganache only: useful if you need a specific ganache version |
101+
| providerOptions | *Object* | `{ }` | Ganache only: [ganache-core options][1] |
102+
95103

96104
[<sup>*</sup> Advanced use][14]
97105

@@ -211,6 +219,7 @@ $ yarn
211219
[36]: https://hardhat.org/
212220
[37]: https://github.com/sc-forks/solidity-coverage/blob/master/HARDHAT_README.md
213221
[38]: https://github.com/sindresorhus/globby#globbing-patterns
222+
[39]: https://github.com/sc-forks/solidity-coverage/blob/master/docs/advanced.md#generating-a-test-matrix
214223
[1001]: https://docs.soliditylang.org/en/v0.8.0/using-the-compiler.html#input-description
215224
[1002]: https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-out-of-stack
216225

docs/advanced.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,27 @@ Setting the `measureStatementCoverage` and/or `measureFunctionCoverage` options
106106
improve performance, lower the cost of execution and minimize complications that arise from `solc`'s
107107
limits on how large the compilation payload can be.
108108

109+
## Generating a test matrix
110+
111+
Some advanced testing strategies benefit from knowing which tests in a suite hit a
112+
specific line of code. Examples include:
113+
+ [mutation testing][22], where this data lets you select the correct subset of tests to check
114+
a mutation with.
115+
+ [fault localization techniques][23], where the complete data set is a key input to algorithms that try
116+
to guess where bugs might exist in a given codebase.
117+
118+
Running the coverage command with `--matrix` will write [a JSON test matrix][25] which maps greppable
119+
test names to each line of code to a file named `testMatrix.json` in your project's root.
120+
121+
It also generates a `mochaOutput.json` file which contains test run data similar to that
122+
generated by mocha's built-in [JSON reporter][27].
123+
124+
In combination these data sets can be passed to Joram's Honig's [tarantula][29] tool which uses
125+
a fault localization algorithm to generate 'suspiciousness' ratings for each line of
126+
Solidity code in your project.
127+
128+
[22]: https://github.com/JoranHonig/vertigo#vertigo
129+
[23]: http://spideruci.org/papers/jones05.pdf
130+
[25]: https://github.com/sc-forks/solidity-coverage/blob/master/docs/matrix.md
131+
[27]: https://mochajs.org/api/reporters_json.js.html
132+
[29]: https://github.com/JoranHonig/tarantula

0 commit comments

Comments
 (0)