[WIP] Add script to generate tests cases for gix-diff
#2197
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is about 75–80 % done (hopefully). It still needs comments and there’s also a couple of
TODO
comments that I want to go through. I already wanted to open it at this early stage, kind of as a sneak preview of the things I’m currently working on. :-)What’s the context and what are the goals of this PR?
We assume that most people would expect the output of
gix-diff
to be identical to that ofgit diff
. Therefore, we want an easy way to compare the output ofgix-diff
andgit diff
on a large corpus of diffs to make sure they match.This PR tries to make as much of that process scripted and as easily reproducible as possible.
There is a repository that contains “[t]ools for experimenting [with] diff "slider" heuristics”: diff-slider-tools. We can use
diff-slider-tools
to, for any git repository, generate a list of locations where a diff between two files is not unambiguous.This PR creates a tool that takes this a list of locations generated by
diff-slider-tools
and turns it into test cases that can be run as part ofgix-diff
’s test suite.This enables us to, whenever we want, run large-scale tests comparing
gix-diff
togix diff
, hopefully uncovering any edge case we might have missed in our slider heuristic and making sure we conform to our users’ expectations.Usage
create-diff-cases
to create the script ingix-diff/tests/fixtures/
. The script which will be calledmake_diff_for_sliders_repo.sh
.cargo test sliders -- --nocapture
insidegix-diff/tests
to run the actual tests.Implementation details
The preamble to
make_diff_for_sliders_repo.sh
comes from a similar script ingix-diff
: https://github.com/cruessler/gitoxide/blob/f0ceafa62ff519484e016789c50fa49a79819a80/gix/tests/fixtures/make_diff_repos.sh#L1-L4.The repo created by
make_diff_for_sliders_repo.sh
follows a few conventions:The test runs assertions for each pair of commits. It reads the baseline the comes from
git diff
and compares it to the output ofgix-diff
.Open questions