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

Support Diff-1.0 #31

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

* Support Diff-1.0

## v0.1.0

Initial release
2 changes: 1 addition & 1 deletion skeletest.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ library
, aeson-pretty
, ansi-terminal >= 0.4.0
, containers
, Diff >= 0.5
, Diff >= 1.0
, directory
, filepath
, ghc ^>= 9.6 || ^>= 9.8 || ^>= 9.10
Expand Down
7 changes: 4 additions & 3 deletions src/Skeletest/Internal/Utils/Diff.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ module Skeletest.Internal.Utils.Diff (
showLineDiff,
) where

import Data.Algorithm.DiffContext (getContextDiffNew, prettyContextDiff)
import Data.Algorithm.DiffContext (getContextDiff, prettyContextDiff)
import Data.Algorithm.DiffContext qualified as Diff
import Data.Text (Text)
import Data.Text qualified as Text
import Text.PrettyPrint qualified as PP

showLineDiff :: (Text, Text) -> (Text, Text) -> Text
showLineDiff (fromName, fromContent) (toName, toContent) =
Text.pack . PP.render $
prettyContextDiff (ppText fromName) (ppText toName) ppText $
getContextDiffNew (Just 5) (Text.lines fromContent) (Text.lines toContent)
prettyContextDiff (ppText fromName) (ppText toName) (ppText . Diff.unnumber) $
getContextDiff (Just 5) (Text.lines fromContent) (Text.lines toContent)
where
ppText = PP.text . Text.unpack
2 changes: 1 addition & 1 deletion test/Skeletest/Internal/__snapshots__/SnapshotSpec.snap.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Example
Result differed from snapshot. Update snapshot with --update.
--- expected
+++ actual
@@
@@ -1,4 +1,4 @@
+new1
same1
-old1
Expand Down
Loading