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

Diffing tables doesn't work when delta span multiple lines #465

Closed
wants to merge 1 commit into from
Closed

Diffing tables doesn't work when delta span multiple lines #465

wants to merge 1 commit into from

Conversation

gphilipp
Copy link
Contributor

We noticed this rather annoying issue :

Diffing

| Aslak | aslak@email.com | 123 |
| Joe   | joe@email.com   | 234 |
| Bryan | bryan@email.org | 456 |
| Ni    | ni@email.com    | 654 |

with

| Aslak | aslak@email.com | 123 |
| Ni    | ni@email.com    | 654 |

will return the following delta :

Tables were not identical:
      | Aslak | aslak@email.com | 123 |
    - | Joe   | joe@email.com   | 234 |
    - | Bryan | bryan@email.org | 456 |
      | Bryan | bryan@email.org | 456 |
      | Ni    | ni@email.com    | 654 |

Notice that the Bryan line is listed twice.

I want to tackle the issue but would like you to confirm this is unexpected ?

@gphilipp
Copy link
Contributor Author

The culprit is the TableDiffer#createTableDiff method, the loop counter doesn't take into account the "size" of the delta. I'd like to update this PR with a fix but I can't manage to build cucumber-jvm : it fails the tests within .SubstitutionStepdefs.I_should_receive_an_email_with_the_body (even on v1.1.2).

@gphilipp
Copy link
Contributor Author

Ok I figured out the build issue. Adding a mental note to self to not set core.autocrlf to true ever again. Working on a fix for this issue now.

@gphilipp
Copy link
Contributor Author

Not passing yet, it fails the out of memory test...

@gphilipp
Copy link
Contributor Author

Ok actually it's not failing because of an OutMemoryError, but rather because of a wrong expectation (in my opinion) in TableDifferTest.should_not_fail_with_out_of_memor(). The expected diff should not be :

+ | I just woke up |

but :

 + | I just woke up    |
   | I'm going to work |

I'll update this PR with the latest commit which makes all tests pass, including 3 new ones that I wrote to cover multiline deltas.

@aslakhellesoy
Copy link
Contributor

Merged. Great patch!

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants