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

Approve behavioural changes by some "oracle" #18

Open
maxbechtold opened this issue Feb 12, 2020 · 2 comments
Open

Approve behavioural changes by some "oracle" #18

maxbechtold opened this issue Feb 12, 2020 · 2 comments

Comments

@maxbechtold
Copy link
Owner

maxbechtold commented Feb 12, 2020

This is related to #2 in that it allows approval on-the-fly, but in a more elaborated manner.

E.g. there's a use case to adjust a program while it is only covered by golden master tests. This could be as simple as adapting the output format, or more complex changes. For very regular changes (e.g replace space by tab) there could be an automatic way to approve changes, if the output changes in the described way. This could leverage the power of tools like kdiff3 and sed.

Questions:

  • is it enough to let the user provide an "oracle" method like assess(input, output)?
  • how to ensure this "oracle" is only active once/for the current change?
  • how does this relate to the comparison built into FastApproval (cf. ExecutableDifferenceReporter)?
@maxbechtold
Copy link
Owner Author

I did a rough sketch of using native programs as oracles on the branch oracle-issue18.

The ExampleGoldenMasterTest shows how a ExecutableDifferenceReporter can be used as an oracle to judge differences, where it compares text disregarding case (using Windows' FC). It uses a locked oracle that applies once, then generates a .lock file. With the .lock file in place, the oracle is not asked (avoiding accidental approval of mismatching outputs). The user can reenable the oracle (without changing code) by removing the .lock file.

Similarly, one can define an oracle that is always asked to approve mismatching outputs, e.g. one that treats "__" and \t as equivalent (i.e. accepts tab for 2 consecutive spaces and v.v.).

maxbechtold added a commit that referenced this issue Mar 18, 2020
@maxbechtold
Copy link
Owner Author

maxbechtold commented May 6, 2020

Also, one could provide a method for comparison of master files and output files instead of falling back to an assess method.

Objects serialized to JSON is also a use case where there's a lot of textual flexibility that should probably not lead to failing master tests.

Thanks to @almondtools for the suggestion.

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

No branches or pull requests

1 participant