Skip to content

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

Closed
wants to merge 1 commit into from

2 participants

@gphilipp

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

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

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

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

@gphilipp

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
Cucumber member

Merged. Great patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.