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

Diff::LCS::Hunk#diff(:unified) output changed between 1.3 and 1.4.1 #60

Closed
phiggins opened this issue Jun 24, 2020 · 0 comments · Fixed by #61
Closed

Diff::LCS::Hunk#diff(:unified) output changed between 1.3 and 1.4.1 #60

phiggins opened this issue Jun 24, 2020 · 0 comments · Fixed by #61
Assignees

Comments

@phiggins
Copy link

Hi,

The tests for chef/chef are seeing some failures related to diff output after upgrading from version 1.3 to 1.4.1 (see chef/chef#10057 for a bit more detail). I've distilled one of the failing test cases to a small script that demonstrates the changes between versions:

require 'diff/lcs'
require 'diff/lcs/hunk'

puts "::Diff::LCS::VERSION == #{::Diff::LCS::VERSION}"
puts

old_data = <<~DATA_OLD.strip.split("\n").map(&:chomp)
{
  "name": "x",
  "description": "hi"
}
DATA_OLD

new_data = <<~DATA_NEW.strip.split("\n").map(&:chomp)
{
  "name": "x",
  "description": "lo"
}
DATA_NEW

diff = ::Diff::LCS.diff(old_data, new_data)

abort "Got #{diff.size} chunks." unless diff.size == 1

hunk = ::Diff::LCS::Hunk.new(old_data, new_data, diff.first, 3, 0)

puts hunk.diff(:unified)

Running this with 1.3 I get this output:

Petes-MBP:chef pete$ ruby test_lcs_diff.rb
::Diff::LCS::VERSION == 1.3

@@ -1,5 +1,5 @@
 {
   "name": "x",
-  "description": "hi"
+  "description": "lo"
 }

Running the script with 1.4.1 I get this output:

Petes-MBP:chef pete$ ruby test_lcs_diff.rb
::Diff::LCS::VERSION == 1.4.1

@@ -1,3 +1,3 @@
 {
   "name": "x",
-  "description": "hi"
+  "description": "lo"
@halostatue halostatue self-assigned this Jun 24, 2020
halostatue added a commit that referenced this issue Jun 24, 2020
- This appears to satisfy the issues found in #60 as well as providing the
  additional fixes required to properly test ldiff.

Resolves #60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants