This is an implementation of a modified version of delta debugging
The main idea is that instead of returning the minimum failing test case, it is better for developers to receive a failing test case that has a minimal difference from passing test cases.
In our modified implementation of Zeller's original delta debugging work [1], [2], [3], we achieve this in a 2-step process:
-
Delta Debugging (dd):
- Minimize the failing test case to isolate the smallest configuration that still fails.
-
Maximal Expansion (ddmax):
- Expand the minimized failing test case by adding elements from the passing test case, ensuring it remains failing, until no further expansion is possible.
The result is a maximal failing test case that is as close as possible to the passing test case. This test case is more readable for programmers and allows them to better discover the root cause of the test failure.
-
Input:
- A failing test case (
c1) and a passing test case (c2). - A granularity level (
n) that determines how the difference betweenc1andc2is split.
- A failing test case (
-
Initialization:
- Compute the difference (
c) betweenc2andc1. - Ensure that
c1is a subset ofc2and thatc1fails whilec2passes.
- Compute the difference (
-
Iterative Expansion:
- Split the difference (
c) intonsubsets. - For each subset, attempt to add it to
c1and test the resulting configuration:- If the expanded configuration still fails, keep the subset and update
c1. - If it passes, discard the subset.
- If the expanded configuration still fails, keep the subset and update
- Adjust the granularity (
n) dynamically based on progress.
- Split the difference (
-
Termination:
- Stop when no further subsets can be added to
c1without causing it to pass, or when the granularity exceeds the size ofc.
- Stop when no further subsets can be added to
-
Output:
- Return the maximal failing test case (
c1), the remaining difference (c), and the original passing test case (c2).
- Return the maximal failing test case (
This algorithm ensures that the failing test case is expanded as much as possible while remaining within the boundaries of the passing test case.
The files in this repository marked as showcase*.py (* being a number) can be run using the following instructions. Each file contains few test examples to show how our dd algorithm (in humandeltadebug.py) works. The descriptions of each showcase are in their respective files.
You can run all the showcases at once using the provided scripts:
On Unix/macOS (with sh):
./runshowcases.shOn Windows:
.\runshowcases.batThis will execute all showcase*.py files in the directory and store their outputs in a folder called showcase_output as showcase*.out files.
If you wish to see a more verbose output, albeit hard to interpret, add the --verbose flag
On Unix/macOS (with sh):
./runshowcases.sh --verboseOn Windows:
.\runshowcases.bat --verboseThis would create verbose-showcase*.out in showcase_output which contain the verbose output of running the showcases.
To run individual showcases, you may run the commands (python or python3 based on the way the command is configured on your system)
python3 showcase1.pypython3 showcase2.pypython3 showcase3.pyThis, for example would run the first showcase, second showcase, and third showcase respectfully.
In order to view the verbose output, simply add the --verbose flag to the end of the command
For example,
python3 showcase1.py --verbose- Explore using other minimisation/maximisation metrics, for example edit distance or hamming distance.
- Explore minimising the passing test case, as opposed to our current approach of maximising the failing test case.
[1] A. Zeller and R. Hildebrandt, "Simplifying and isolating failure-inducing input," in IEEE Transactions on Software Engineering, vol. 28, no. 2, pp. 183-200, Feb. 2002, doi: 10.1109/32.988498
[2] A. Zeller, Original DD.py implementation, https://www.st.cs.uni-saarland.de/dd/DD.py
[3] grimm-co, “GitHub - grimm-co/delta-debugging: Debugging library to quickly get the minimal crashing test case,” GitHub, 2016. https://github.com/grimm-co/delta-debugging