-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
PHPUnit should not create a diff when expected or actual string are too large #4918
Comments
The same issue reproduced for me too |
Unless a bug can be found in the You might have better luck having this resolved by finding the original authors of the calculators and discuss the details based on you input with them, as the details in the current report(s) are not enough to work with. |
I guess that the algorithms are pretty standard, and that they work as intended. One is time efficient (but memory hungry), the other is memory efficient (and time hungry). If that's the case, and if there is no more efficient diffing algorithm, the issue is in PHPUnit: It should not try to generate a full minimal diff when it's not going to finish in an acceptable time. It could fallback to just finding the first difference in two inputs (which would not require to find the longuest common substring), or to use an algorithm that only tries to find an approximation of the minimal possible diff. |
I didn't check if PHPUnit has some logic to select a calculator, or leaves it to this package; @ see: It might be worth checking if this selection logic is working as intended. Maybe someone who is effected by this can check? |
I have the same issue, Can we use the |
Did you try to make diff with |
I've created a reproducer / demo here: sebastianbergmann/diff#107 I've also tried |
I've been working towards a solution. Rather than removing the diff, I think it would be nice to provide a hint about what's going wrong. To do this, we could implement a method "getPartialDiff" in the ComparisonFailure class (sebastian/comparator/src/ComparisonFailure.php); phpunit should then use this method instead of "getDiff" when printing the exception (in phpunit/src/Framework/TestFailure.php:47). Here is an example of output :
|
When comparing values that happen to not be equal, phpunit might try to display a nice diff. If the values are large enough, a memory-efficient implementation is used to compute the diff (MemoryEfficientLongestCommonSubsequenceCalculator).
The diff algorithm can take hours to compute a diff on accidentally large strings.
The text was updated successfully, but these errors were encountered: