Skip to content

Commit

Permalink
[ruby/yarp] Fix snapshot checking
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Jun 21, 2023
1 parent 4be594a commit 23e1c69
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/yarp/parse_test.rb
Expand Up @@ -75,12 +75,15 @@ def test_parse_takes_file_path
assert_empty result.errors, value

if File.exist?(snapshot)
expected = File.read(snapshot)
normalized = normalize_printed(expected)
if expected != normalized
normalized = normalize_printed(File.binread(snapshot))

# If the snapshot file exists, but the printed value does not match the
# snapshot, then update the snapshot file.
if normalized != printed
File.write(snapshot, normalized)
warn("Updated snapshot at #{snapshot}.")
end

# If the snapshot file exists, then assert that the printed value
# matches the snapshot.
assert_equal(normalized, printed)
Expand Down

0 comments on commit 23e1c69

Please sign in to comment.