-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Produce tests per line data #430
Comments
Cool! I think this issue moves solidity-coverage from a pure utility to become a more framework or library-like project :) |
It's been a while 😅. If you could point me in the right direction then I might be able to contribute this feature. |
Hi @JoranHonig! That sounds great. Am about to make a set of +/- large changes here as part of #541. Could I get back to you next week on this? (Will have a better sense of how this might be possible then.) Am copying over some of the design details from the Vertigo discussion. The generated object might look something like this? {
File.sol: {
8: [
{
test: 'it errors when called by alice',
file: '/Users/area/code/tests/alice.js'
}, ...
], ...
},
AnotherFile.sol: {...},
} The test names would come from a custom mocha reporter attached before the test command is run. Mocha details are: reporter's 'test' hook (for runner.on("test", info => {
} info (much abbreviated) info: {
suite: {
title: 'Contract: EtherRouter Proxy',
file: '/Users/cgewecke/code/eth-gas-reporter/mock/test/etherrouter.js'
},
test: {
"title": "Resolves methods routed through an EtherRouter proxy",
"file": "/Users/cgewecke/code/eth-gas-reporter/mock/test/etherrouter.js",
}
}, |
Thanks! Take your time with #541 👍. The dataformat looks good to me! It'd be perfect for mutation testing. |
Update: have a working version of this in #593 which will published as part of the new Am calling this data a "test matrix". It can be generated using the Output for Truffle's metacoin repository looks like:
|
@cgewecke 🎉 This is awesome! Thanks for this feature! |
@cgewecke I'm playing around with this right now (doing an implementation of the fault localisation algorithm you mentioned 😄).
I think it might be necessary to use the fullTitle for each test, otherwise you might be able to get collisions (multiple tests with the same title in a file). |
Another question: I think mocha doesn't give a "file" for the tests that are actually written in solidity (if I'm using truffle). Is the "file" param also optional in solidity-coverage's results? |
@JoranHonig Wow! Super cool.
These are filtered out while generating the matrix. If a title occurs twice for the same line & test file it's skipped. Please let me know if you see these in the output though since they shouldn't be there.
Unfortunately solidity-coverage doesn't support Truffle's native solidity testing framework atm. (Issue #578) It's disabled because of a bug in the Truffle compilation pipeline. Will need to revisit this |
@cgewecke do you know a clean way of getting out the test results (passed/failed) when checking test coverage?
|
@JoranHonig It's possible to start collecting it - the mocha reporter has 'pass' and 'fail' hooks that could be repurposed for this. Out of curiosity - is this data useful for the mutation tester or fault localization or something else? One (possibly incorrect) premise I've had is that matrix reporter would be run once just to generate a map. And that the execution context is a test suite with probably all passing tests. |
@JoranHonig How did you produce the test data in your tarantula unit test? Perhaps the |
@cgewecke this data could actually be useful for both mutation testing and fault localization. But I'm asking specifically for fault localisation. I would like to have some setup where people will run Vertigo currently reads the standard output of truffle (after configuring it to use the json reporter) and parses it. This is super unclean bc truffle also outputs a bunch of other stuff over stdout, which Vertigo needs to filter.
The other testdata is the output of mocha's json reporter on Metacoin contract. If |
Oh! Perfect, I'll add that rn. |
Ok... from commit ac532d6, mocha json output is written separately to I ran the tarantula lib against sushiswap. All the tests pass so suspiciousness is either 1 or 0. I think further refinements may be required at solidity-coverage but I'm not sure what would be helpful...please just lmk the short-comings you see on your side. One issue I noticed is that I adapted the mocha json reporter here. A reporter like that might be useful if you're programatically introducing failures. |
Hi @cgewecke, @tintinweb (and me a bit) built a VSCode plugin that does fault localisation. https://marketplace.visualstudio.com/items?itemName=tintinweb.vscode-tarantula It looks for 💪 wouldn't have been possible without this coverage feature! Thanks! |
@JoranHonig Oh great!! Looks super cool. Thanks for doing all this Joran! Just incredible :) |
v0.8.0 |
It has been proposed in JoranHonig/vertigo 20 that being able to identify exactly which tests exercise which line of Solidity would be useful data for mutation testing and fault-localization techniques.
The issue linked to above includes lots of discussion about how to achieve this. Would probably be a command separate from coverage & just consume some services available through the beta's new API.
Maybe even in it's own repo at sc-forks org? With SC as a dependency?
See also: #209
The text was updated successfully, but these errors were encountered: