alexfertel / bulloak

A Solidity test generator based on the Branching Tree Technique.
Apache License 2.0
225 stars 13 forks source link

feat: vm.skip(true) #63

Closed drgorillamd closed 2 months ago

drgorillamd commented 2 months ago

Add a vm.skip(true); at the beginning of each function (closes #57)

Without this forge cheatcode, tests are being run and show as "Pass", even when empty (false positive). With this cheatcode, they would show as "Skipped"

function test_WhenXYZ() external {
    vm.skip(true);
    // It should do the thing
(...)

Implementation

A new node is added in the hir tree itself, after reading an optional bulloak.toml (which should contain a no_skip bool, set to true if this cheatcode should not be included in the final test)

drgorillamd commented 2 months ago

@alexfertel I'm opening this so you can take a quick look (I changed a bit the idea/added an optional toml for this kind of optional setup). Let me know what you think and I'll add docs/natspecs afterward, in the meantime, I'll replace the StringLiteral by the correct solang expression in the sol translator

alexfertel commented 2 months ago

Yo! If you need any help or anything at all lmk, quite excited about this getting merged!

drgorillamd commented 2 months ago

hmm, one small extra thingy to add: we now need forge-std as an import (but I guess it's not too opiniated to add it when a cheatcode is being inlined too, right @alexfertel ?)

alexfertel commented 2 months ago

we now need forge-std as an import (but I guess it's not too opiniated to add it when a cheatcode is being inlined too, right @alexfertel ?)

Yup, it's fine to do so since we are tied to foundry anyway for now.

It should be well-documented both in doc comments and the README.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 99.25651% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 93.2%. Comparing base (4c2002d) to head (dda4d18). Report is 2 commits behind head on main.

Additional details and impacted files | [Files](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez) | Coverage Δ | | |---|---|---| | [src/check/context.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fcheck%2Fcontext.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL2NoZWNrL2NvbnRleHQucnM=) | `87.6% <100.0%> (ø)` | | | [src/check/violation.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fcheck%2Fviolation.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL2NoZWNrL3Zpb2xhdGlvbi5ycw==) | `89.3% <100.0%> (+<0.1%)` | :arrow_up: | | [src/hir/combiner.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fhir%2Fcombiner.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL2hpci9jb21iaW5lci5ycw==) | `95.8% <100.0%> (+0.3%)` | :arrow_up: | | [src/hir/hir.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fhir%2Fhir.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL2hpci9oaXIucnM=) | `64.0% <ø> (ø)` | | | [src/hir/mod.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fhir%2Fmod.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL2hpci9tb2QucnM=) | `100.0% <100.0%> (ø)` | | | [src/hir/translator.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fhir%2Ftranslator.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL2hpci90cmFuc2xhdG9yLnJz) | `98.8% <100.0%> (+0.1%)` | :arrow_up: | | [src/scaffold/emitter.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fscaffold%2Femitter.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL3NjYWZmb2xkL2VtaXR0ZXIucnM=) | `98.0% <100.0%> (+0.2%)` | :arrow_up: | | [src/sol/fmt.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fsol%2Ffmt.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL3NvbC9mbXQucnM=) | `69.6% <100.0%> (+5.0%)` | :arrow_up: | | [src/sol/translator.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fsol%2Ftranslator.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL3NvbC90cmFuc2xhdG9yLnJz) | `98.8% <100.0%> (+0.8%)` | :arrow_up: | | [src/scaffold/mod.rs](https://app.codecov.io/gh/alexfertel/bulloak/pull/63?src=pr&el=tree&filepath=src%2Fscaffold%2Fmod.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexander+Gonz%C3%A1lez#diff-c3JjL3NjYWZmb2xkL21vZC5ycw==) | `88.2% <75.0%> (+4.0%)` | :arrow_up: |