paypal / butterfly

Application transformation tool
https://paypal.github.io/butterfly/
MIT License
48 stars 50 forks source link

Add some useful commands to test output when folders differ #349

Open crankydillo opened 4 years ago

crankydillo commented 4 years ago

Related issue: #296

When a folder comparison assertion fails in butterfly-test, I was taking the output and constructing this command:

diff super-long-base-path/relative-concatenated-path  super-long-base-path2/relative-concatenated-path

I got tired constructing this command and made a local hack that adds the above to the output and would like to contribute. I know not every OS will have diff, but many will and hopefully the rest have some equivalent. Anyhow, this was a huge time saver for me.

May want to look at what diff options we have that work against folders.

I really use the awesome vimdiff, but I realize most won't want that:)

fabiocarvalho777 commented 4 years ago

Awesome Sam, thank you very much!! I know exactly where you are coming from, this is something I have thought about too. It would be nice to make it configurable though, so it is not ON for people using OSs that don't support it. Looking forward for your PR!

crankydillo commented 4 years ago

Fabio, do you have any current strategy for doing this? I can think of several ways, the most obvious being using CLI argument. That doesn't feel right though. I really think that this type of thing goes into a config file. Something like:

test.diff.output=diff {} {}

I don't want to reinvent the wheel if you already have a strategy/plan for such configuration.

fabiocarvalho777 commented 4 years ago

Please take at look at issue #41. If that was implemented already, it could help now.

However, when I first thought about an automatic diff tool being triggered after a test, I thought about having it configured from the IDE. I don't see this diff tool being applicable to a regular Butterfly execution from the CLI.

Maybe that is because I am used to always run Butterfly from the IDE when developing an extension (which is when a diff would be helpful after a test execution).

Do you run it from the CLI when developing an extension?

So, considering this issue here would be implemented without the help of #41 being done first, here are some options:

  1. Turn the diff output ON programmatically (by adding a new boolean parameter to the test method)
  2. Turn the diff output ON by setting a System.property (also helpful when running from the IDE)

I think number 2 is more appropriate, so user can control that without changing source code (when running it from different OSes, in case diff tool is OS specific)

One more important thing to consider. IntelliJ lets you configure an external diff tool, and lets you pass the path to the diff tool binary, and is able to direct to it its inputs (original, modified, and merge).

Instead of hardcoding a diff tool integration into Butterfly, maybe we could make it configurable, so it can detach to the user favorite diff tool, like IntellJ does. What do you think about this?