Skip to content

Commit

Permalink
Screenshot diffing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Sydney Kerckhove committed Aug 4, 2024
1 parent a6889a4 commit 23baea5
Show file tree
Hide file tree
Showing 30 changed files with 182 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
name: "Use const"
- ignore:
name: "Use ||"
- ignore:
name: "Use &&"
- ignore:
name: "Avoid reverse"
- ignore:
Expand Down
6 changes: 6 additions & 0 deletions sydtest-aeson/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.2.0.0] - 2024-08-04

### Changed

* Compatibility with `sydtest >=0.17`

## [0.1.0.0] - 2022-04-28

### Changed
Expand Down
2 changes: 1 addition & 1 deletion sydtest-aeson/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}:
mkDerivation {
pname = "sydtest-aeson";
version = "0.1.0.0";
version = "0.2.0.0";
src = ./.;
libraryHaskellDepends = [
aeson aeson-pretty base bytestring deepseq path path-io sydtest
Expand Down
4 changes: 2 additions & 2 deletions sydtest-aeson/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sydtest-aeson
version: 0.1.0.0
version: 0.2.0.0
github: "NorfairKing/sydtest"
license: OtherLicense
license-file: LICENSE.md
Expand All @@ -25,7 +25,7 @@ library:
- deepseq
- path
- path-io
- sydtest
- sydtest >=0.17
- text

tests:
Expand Down
30 changes: 16 additions & 14 deletions sydtest-aeson/src/Test/Syd/Aeson.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ goldenJSONFile fp produceActualValue =
ensureDir (parent p)
SB.writeFile (fromAbsFile p) $ LB.toStrict $ JSON.encodePretty value,
goldenTestCompare = \actual expected ->
if actual == expected
then Nothing
else
Just
( Context
( textsNotEqualButShouldHaveBeenEqual
(TE.decodeUtf8 (LB.toStrict (JSON.encodePretty actual)))
(TE.decodeUtf8 (LB.toStrict (JSON.encodePretty expected)))
)
(goldenContext fp)
)
pure $
if actual == expected
then Nothing
else
Just
( Context
( textsNotEqualButShouldHaveBeenEqual
(TE.decodeUtf8 (LB.toStrict (JSON.encodePretty actual)))
(TE.decodeUtf8 (LB.toStrict (JSON.encodePretty expected)))
)
(goldenContext fp)
)
}

-- | Test that the given 'JSON.Value' is the same as what we find in the given golden file.
Expand Down Expand Up @@ -82,9 +83,10 @@ goldenJSONValueFile fp produceActualValue =
ensureDir (parent p)
SB.writeFile (fromAbsFile p) $ LB.toStrict $ JSON.encodePretty value,
goldenTestCompare = \actual expected ->
if actual == expected
then Nothing
else Just (Context (stringsNotEqualButShouldHaveBeenEqual (ppShow actual) (ppShow expected)) (goldenContext fp))
pure $
if actual == expected
then Nothing
else Just (Context (stringsNotEqualButShouldHaveBeenEqual (ppShow actual) (ppShow expected)) (goldenContext fp))
}

-- | Test that the given 'JSON.Value' is the same as what we find in the given golden file.
Expand Down
4 changes: 2 additions & 2 deletions sydtest-aeson/sydtest-aeson.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: sydtest-aeson
version: 0.1.0.0
version: 0.2.0.0
synopsis: An aeson companion library for sydtest
category: Testing
homepage: https://github.com/NorfairKing/sydtest#readme
Expand Down Expand Up @@ -42,7 +42,7 @@ library
, deepseq
, path
, path-io
, sydtest
, sydtest >=0.17
, text
default-language: Haskell2010

Expand Down
7 changes: 7 additions & 0 deletions sydtest-mongo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## [0.1.0.0] - 2024-08-04

### Changed

* Compatibility with `sydtest >=0.17`
2 changes: 1 addition & 1 deletion sydtest-mongo/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}:
mkDerivation {
pname = "sydtest-mongo";
version = "0.0.0.0";
version = "0.1.0.0";
src = ./.;
libraryHaskellDepends = [
base binary bson bytestring mongoDB network path path-io port-utils
Expand Down
5 changes: 3 additions & 2 deletions sydtest-mongo/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sydtest-mongo
version: 0.0.0.0
version: 0.1.0.0
github: "NorfairKing/sydtest"
license: OtherLicense
license-file: LICENSE.md
Expand All @@ -11,6 +11,7 @@ synopsis: An mongoDB companion library for sydtest

extra-source-files:
- LICENSE.md
- CHANGELOG.md
- test_resources/**/*

dependencies:
Expand All @@ -28,7 +29,7 @@ library:
- path-io
- port-utils
- process
- sydtest
- sydtest >=0.17
- sydtest-process
- text
- yaml
Expand Down
7 changes: 4 additions & 3 deletions sydtest-mongo/src/Test/Syd/MongoDB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ goldenBSONDocumentFile fp produceActualDocument =
ensureDir (parent ap)
SB.writeFile (fromAbsFile ap) $ LB.toStrict $ runPut $ putDocument d,
goldenTestCompare = \actual expected ->
if actual == expected
then Nothing
else Just (Context (stringsNotEqualButShouldHaveBeenEqual (ppShow actual) (ppShow expected)) (goldenContext fp))
pure $
if actual == expected
then Nothing
else Just (Context (stringsNotEqualButShouldHaveBeenEqual (ppShow actual) (ppShow expected)) (goldenContext fp))
}

-- | Test that the given 'Bson.Document' is the same as what we find in the given golden file.
Expand Down
5 changes: 3 additions & 2 deletions sydtest-mongo/sydtest-mongo.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: sydtest-mongo
version: 0.0.0.0
version: 0.1.0.0
synopsis: An mongoDB companion library for sydtest
category: Testing
homepage: https://github.com/NorfairKing/sydtest#readme
Expand All @@ -18,6 +18,7 @@ license-file: LICENSE.md
build-type: Simple
extra-source-files:
LICENSE.md
CHANGELOG.md
test_resources/example.bson
test_resources/pure-example.bson

Expand Down Expand Up @@ -48,7 +49,7 @@ library
, path-io
, port-utils
, process
, sydtest
, sydtest >=0.17
, sydtest-process
, text
, yaml
Expand Down
6 changes: 6 additions & 0 deletions sydtest-persistent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.1.0.0] - 2024-08-04

### Changed

* Compatibility with `sydtest >=0.17`

## [0.0.0.2] - 2023-10-09

### Added
Expand Down
2 changes: 1 addition & 1 deletion sydtest-persistent/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}:
mkDerivation {
pname = "sydtest-persistent";
version = "0.0.0.2";
version = "0.1.0.0";
src = ./.;
libraryHaskellDepends = [
base bytestring mtl persistent sydtest text unliftio
Expand Down
4 changes: 2 additions & 2 deletions sydtest-persistent/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sydtest-persistent
version: 0.0.0.2
version: 0.1.0.0
github: "NorfairKing/sydtest"
license: OtherLicense
license-file: LICENSE.md
Expand All @@ -22,6 +22,6 @@ library:
- bytestring
- mtl
- persistent
- sydtest
- sydtest >=0.17
- text
- unliftio
2 changes: 1 addition & 1 deletion sydtest-persistent/src/Test/Syd/Persistent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ migrationsSucceedsSpecHelper connectionPoolSetupFunc migrationFile currentMigrat
in gt
{ goldenTestCompare = \actual expected ->
let addHelpContext a = Context a helpText
in addHelpContext <$> goldenTestCompare gt actual expected
in fmap addHelpContext <$> goldenTestCompare gt actual expected
}

it migrationTestDescription $ do
Expand Down
4 changes: 2 additions & 2 deletions sydtest-persistent/sydtest-persistent.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: sydtest-persistent
version: 0.0.0.2
version: 0.1.0.0
synopsis: A persistent companion library for sydtest
category: Testing
homepage: https://github.com/NorfairKing/sydtest#readme
Expand Down Expand Up @@ -36,7 +36,7 @@ library
, bytestring
, mtl
, persistent
, sydtest
, sydtest >=0.17
, text
, unliftio
default-language: Haskell2010
8 changes: 4 additions & 4 deletions sydtest-test/output-test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,29 @@ spec = do
goldenTestProduce = pure (),
goldenTestWrite = \() -> do
pure (),
goldenTestCompare = \() () -> Nothing
goldenTestCompare = \() () -> pure Nothing
}
it "does not fail the suite when an exception happens while producing" $
GoldenTest
{ goldenTestRead = pure Nothing,
goldenTestProduce = die "test",
goldenTestWrite = \() -> do
pure (),
goldenTestCompare = \() () -> Nothing
goldenTestCompare = \() () -> pure Nothing
}
it "does not fail the suite when an exception happens while writing" $
GoldenTest
{ goldenTestRead = pure Nothing,
goldenTestProduce = pure (),
goldenTestWrite = \() -> die "test",
goldenTestCompare = \() () -> Nothing
goldenTestCompare = \() () -> pure Nothing
}
it "does not fail the suite when an exception happens while checking for equality" $
GoldenTest
{ goldenTestRead = pure (Just ()),
goldenTestProduce = pure (),
goldenTestWrite = \() -> pure (),
goldenTestCompare = \actual expected -> case 1 `div` (0 :: Int) of
goldenTestCompare = \actual expected -> pure $ case 1 `div` (0 :: Int) of
1 -> Nothing
_ ->
if actual == expected
Expand Down
2 changes: 1 addition & 1 deletion sydtest-test/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ tests:
- path-io
- safe-coloured-text
- stm
- sydtest
- sydtest >=0.17
- text
- vector

Expand Down
2 changes: 1 addition & 1 deletion sydtest-test/sydtest-test.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ test-suite sydtest-test
, path-io
, safe-coloured-text
, stm
, sydtest
, sydtest >=0.17
, text
, vector
default-language: Haskell2010
10 changes: 10 additions & 0 deletions sydtest-webdriver-screenshot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [0.1.0.0] - 2024-08-04

### Added

* Screenshot diff and similarity score

### Changed

* Compatibility with `sydtest >=0.17`

## [0.0.0.2] - 2023-10-09

### Added
Expand Down
6 changes: 3 additions & 3 deletions sydtest-webdriver-screenshot/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{ mkDerivation, base, bytestring, http-types, JuicyPixels, lib, mtl
, network-uri, path, path-io, sydtest, sydtest-discover
, sydtest-wai, sydtest-webdriver, wai, webdriver
, sydtest-wai, sydtest-webdriver, vector, wai, webdriver
}:
mkDerivation {
pname = "sydtest-webdriver-screenshot";
version = "0.0.0.2";
version = "0.1.0.0";
src = ./.;
libraryHaskellDepends = [
base bytestring JuicyPixels mtl path path-io sydtest
sydtest-webdriver webdriver
sydtest-webdriver vector webdriver
];
testHaskellDepends = [
base http-types network-uri sydtest sydtest-wai sydtest-webdriver
Expand Down
3 changes: 2 additions & 1 deletion sydtest-webdriver-screenshot/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sydtest-webdriver-screenshot
version: 0.0.0.2
version: 0.1.0.0
license: OtherLicense
license-file: LICENSE.md
author: "Tom Sydney Kerckhove"
Expand All @@ -25,6 +25,7 @@ library:
- path-io
- sydtest
- sydtest-webdriver
- vector
- webdriver

tests:
Expand Down
Loading

0 comments on commit 23baea5

Please sign in to comment.