Skip to content
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

Automate the carving process? #37

Open
AndreaCrotti opened this issue Nov 10, 2020 · 7 comments
Open

Automate the carving process? #37

AndreaCrotti opened this issue Nov 10, 2020 · 7 comments

Comments

@AndreaCrotti
Copy link
Contributor

Assuming someone has decent test coverage, it would be cool to semi automate the whole carving process, and one way would to:

  • set a command to run all the tests
  • make carve run that command after every form is deleted (either in interactive or non interactive mode), and if they pass just delete otherwise undo and add to .carveignore

I guess tests should be fast enough, but I think this would really help the initial carving on bigger projects.
What do you think @borkdude ?

@borkdude
Copy link
Owner

I think this could be done as a script outside of carve, using carve as a library, not as a test-runner.

@AndreaCrotti
Copy link
Contributor Author

Yes in theory but is there a way to remove only one thing? Or maybe eventually carve only one file at a time?

If yes I guess it could be scripted more or less easily, by backing up the file, running carve, running tests and restoring if tests failed.

@borkdude
Copy link
Owner

You're right, Carve could maybe have a :verify-fn hook in which you could run the tests (or lint the project, etc), if the function returns true or doesn't throw, then continue, else revert that step. Maybe the reverting could happen by backing up the file before carving and reverting that file in case of an error.

@AndreaCrotti
Copy link
Contributor Author

So btw I just added some hacky code locally to make it run only on N number of files at a time, which works, so in theory it would be possible to script from outside as well.

However I think that the analysis phase can be quite slow on a big project, and by driving it from the outside I guess that would have to be redone for every change right?
(tbf if it's fully automated it doesn't matter as much can just leave it running by itself, but still might be nice to not make it take forever)

@AndreaCrotti
Copy link
Contributor Author

AndreaCrotti commented Nov 10, 2020

Another thing is that potentially you don't want to run cljs tests if you are only carving clj files, so maybe the hook could be something like file-regexp => verify-fn
{#"*.clj$" "make unit-test-clj", not sure if that gets too complicated though, if tests are fast enough you can also just run them all every time.

@borkdude
Copy link
Owner

borkdude commented Nov 10, 2020

The :verify-fn could receive a map and also could return a map with :continue true or false. Map in, map out (mimo) is usually flexible enough for future extension. In the input map we could include the filename.

@AndreaCrotti
Copy link
Contributor Author

Yeah ok sounds good, I hacked something together externally for now to try it out but yeah it would be definitively useful to integrate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants