alexfertel / bulloak

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

feature request: `bulloak check --fix <file>` to automatically update a test file where the spec changed #30

Closed mds1 closed 7 months ago

mds1 commented 10 months ago

This is a half-baked idea, but the thinking is:

I'm picturing a bulloak check --fix or bulloak update command that, if I only added or moved lines in the tree, regenerates my test file with the code properly moved also. If lines were also changed, perhaps what it can do is something like this:

contract MyTest is Test {
  function test_123() {
    // bulloak automatically scaffolded everything and populated what it could
  }

  // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  // ======== BULLOAK AUTOGENERATED SEPARATOR ========
  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  // Code below this section could not be automatically moved by bulloak and must be manually moved.

  function test_456() {
    // bulloak never deletes your code so it places it here
  }
}
alexfertel commented 9 months ago

Yes, this definitely improves DX. I need to give it some thought because I'm not that happy with the current bulloak -wf flow, and this change would surely influence that part of the API.

alexfertel commented 8 months ago

Well, this is a bit harder than I anticipated because a few things I need from solang_parser are missing. I'll see if there is a solidity parser I can use, otherwise, I'll write one.

alexfertel commented 7 months ago

Ok, ended up using solang_parser but patched a few things on top, leveraging forge-fmt. This commit is a good foundation for this feature.

You can try it out with bulloak check --fix --stdout and let me know what you think!