Skip to content
Snippets Groups Projects
Commit cf9284c8 authored by chrg's avatar chrg
Browse files

Moved glitter test to other repository

parent d0ff68c4
Branches
No related tags found
No related merge requests found
...@@ -18,6 +18,44 @@ ...@@ -18,6 +18,44 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"hspec-glitter": {
"inputs": {
"flake-utils": "flake-utils_2",
"nix-filter": "nix-filter",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1708355228,
"narHash": "sha256-UqWqoxTr5cbTSdIPUtVp22xhBMaBy3VbbFrp1SMr424=",
"ref": "refs/heads/main",
"rev": "80fd7821b0e55ec6706d638a6303c9ead2cd1059",
"revCount": 1,
"type": "git",
"url": "file:///Users/chrg/Develop/repos/hspec-glitter"
},
"original": {
"type": "git",
"url": "file:///Users/chrg/Develop/repos/hspec-glitter"
}
},
"language-c": { "language-c": {
"flake": false, "flake": false,
"locked": { "locked": {
...@@ -49,6 +87,21 @@ ...@@ -49,6 +87,21 @@
"type": "github" "type": "github"
} }
}, },
"nix-filter_2": {
"locked": {
"lastModified": 1705332318,
"narHash": "sha256-kcw1yFeJe9N4PjQji9ZeX47jg0p9A0DuU4djKvg1a7I=",
"owner": "numtide",
"repo": "nix-filter",
"rev": "3449dc925982ad46246cfc36469baf66e1b64f17",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "nix-filter",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1707939175, "lastModified": 1707939175,
...@@ -65,12 +118,29 @@ ...@@ -65,12 +118,29 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1707939175,
"narHash": "sha256-D1xan0lgxbmXDyzVqXTiSYHLmAMrMRdD+alKzEO/p3w=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "f7e8132daca31b1e3859ac0fb49741754375ac3d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"hspec-glitter": "hspec-glitter",
"language-c": "language-c", "language-c": "language-c",
"nix-filter": "nix-filter", "nix-filter": "nix-filter_2",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs_2"
} }
}, },
"systems": { "systems": {
...@@ -87,6 +157,21 @@ ...@@ -87,6 +157,21 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
url = github:kalhauge/language-c; url = github:kalhauge/language-c;
flake = false; flake = false;
}; };
hspec-glitter.url = "/Users/chrg/Develop/repos/hspec-glitter";
}; };
outputs = { outputs = {
self, self,
...@@ -27,11 +28,6 @@ ...@@ -27,11 +28,6 @@
(p.callCabal2nixWithOptions "language-c" inputs.language-c "" {}) { (p.callCabal2nixWithOptions "language-c" inputs.language-c "" {}) {
doCheck = false; doCheck = false;
}; };
# "hspec" = p.hspec_2_11_7;
# "hspec-discover" = p.hspec-discover_2_11_7;
# "hspec-core" = p.hspec-core_2_11_7;
# "hspec-api" = final.haskell.lib.overrideCabal (p.hspec-api) {doCheck = false;};
# "tasty-hspec" = p.tasty-hspec_1_2_0_4;
} }
// load p "rtree" // load p "rtree"
// load p "rtree-c"; // load p "rtree-c";
...@@ -47,7 +43,7 @@ ...@@ -47,7 +43,7 @@
hpkgs = hpkgs =
(import nixpkgs { (import nixpkgs {
inherit system; inherit system;
overlays = [overlays]; overlays = [inputs.hspec-glitter.overlays.default overlays];
}) })
.haskellPackages; .haskellPackages;
in rec { in rec {
......
...@@ -30,8 +30,5 @@ tests: ...@@ -30,8 +30,5 @@ tests:
- hspec-discover - hspec-discover
- hspec-expectations-pretty-diff - hspec-expectations-pretty-diff
- hspec-hedgehog - hspec-hedgehog
- hspec-core - hspec-glitter
- typed-process
- directory
- filepath
- bytestring - bytestring
...@@ -38,7 +38,6 @@ test-suite rtree-test ...@@ -38,7 +38,6 @@ test-suite rtree-test
Control.Monad.RTreeSpec Control.Monad.RTreeSpec
Data.Expr Data.Expr
Spec Spec
Test.Hspec.GitGolden
Paths_rtree Paths_rtree
hs-source-dirs: hs-source-dirs:
test/src test/src
...@@ -47,19 +46,16 @@ test-suite rtree-test ...@@ -47,19 +46,16 @@ test-suite rtree-test
base >=4.9 && <5 base >=4.9 && <5
, bytestring , bytestring
, containers , containers
, directory
, filepath
, hedgehog , hedgehog
, hspec , hspec
, hspec-core
, hspec-discover , hspec-discover
, hspec-expectations-pretty-diff , hspec-expectations-pretty-diff
, hspec-glitter
, hspec-hedgehog , hspec-hedgehog
, indexed-traversable , indexed-traversable
, mtl , mtl
, rtree , rtree
, text , text
, transformers , transformers
, typed-process
, vector , vector
default-language: Haskell2010 default-language: Haskell2010
...@@ -12,7 +12,7 @@ import Data.List.NonEmpty (nonEmpty) ...@@ -12,7 +12,7 @@ import Data.List.NonEmpty (nonEmpty)
import qualified Data.List.NonEmpty as NE import qualified Data.List.NonEmpty as NE
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
import Test.Hspec import Test.Hspec
import Test.Hspec.GitGolden import Test.Hspec.Glitter
spec :: Spec spec :: Spec
spec = describe "examples" do spec = describe "examples" do
...@@ -45,12 +45,12 @@ spec = describe "examples" do ...@@ -45,12 +45,12 @@ spec = describe "examples" do
it "should find an opr" do it "should find an opr" do
(mex, result) <- runWriterT (IRTree.reduce (debugPredicate showString (prettyExprS 0) predicate) me) (mex, result) <- runWriterT (IRTree.reduce (debugPredicate showString (prettyExprS 0) predicate) me)
rex `shouldBe` mex rex `shouldBe` mex
pure $ golden ("test/expected/" <> str <> "-red") (appEndo result "") pure $ glitter ("test/expected/" <> str <> "-red") (appEndo result "")
it "should find an opr exponentially" do it "should find an opr exponentially" do
(mex, result) <- runWriterT (IRTree.reduceExp (debugPredicate showString (prettyExprS 0) predicate) me) (mex, result) <- runWriterT (IRTree.reduceExp (debugPredicate showString (prettyExprS 0) predicate) me)
rex `shouldBe` mex rex `shouldBe` mex
pure $ golden ("test/expected/" <> str <> "-red-exp") (appEndo result "") pure $ glitter ("test/expected/" <> str <> "-red-exp") (appEndo result "")
it "should reduce like iinputs" do it "should reduce like iinputs" do
forM_ (RTree.iinputs re) \(ii, e') -> do forM_ (RTree.iinputs re) \(ii, e') -> do
......
...@@ -14,7 +14,7 @@ import Data.Functor ...@@ -14,7 +14,7 @@ import Data.Functor
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
import Test.Hspec import Test.Hspec
import qualified Test.Hspec.Expectations.Pretty as Pretty import qualified Test.Hspec.Expectations.Pretty as Pretty
import Test.Hspec.GitGolden import Test.Hspec.Glitter
shouldBeString :: String -> String -> Pretty.Expectation shouldBeString :: String -> String -> Pretty.Expectation
shouldBeString = Pretty.shouldBe shouldBeString = Pretty.shouldBe
...@@ -81,7 +81,7 @@ rtreeSpec = describe "RTree" do ...@@ -81,7 +81,7 @@ rtreeSpec = describe "RTree" do
describe "drawRTree" do describe "drawRTree" do
it "should pretty print it's tree" do it "should pretty print it's tree" do
golden glitter
"test/expected/rlist-drawrtree" "test/expected/rlist-drawrtree"
(drawRTree (\() -> id) shows (rList [1, 2, 3 :: Int])) (drawRTree (\() -> id) shows (rList [1, 2, 3 :: Int]))
...@@ -108,7 +108,7 @@ examplesSpec = describe "example" do ...@@ -108,7 +108,7 @@ examplesSpec = describe "example" do
let re = runReaderT me Map.empty let re = runReaderT me Map.empty
it "should draw the same" do it "should draw the same" do
golden glitter
("test/expected/" <> str) ("test/expected/" <> str)
(drawRTree showString (prettyExprS 0) re) (drawRTree showString (prettyExprS 0) re)
......
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedRecordDot #-}
module Test.Hspec.GitGolden where
import System.Directory
import System.FilePath
import Data.Function
import qualified Data.Text.Lazy as Text
import qualified Data.Text.Lazy.Encoding as Text
import System.Process.Typed
import Test.Hspec.Core.Spec
data GitGolden = GitGolden
{ filename :: !FilePath
, content :: !String
}
instance Example (IO GitGolden) where
evaluateExample e p a c = do
e' <- e
evaluateExample e' p a c
instance Example GitGolden where
evaluateExample e _p _a _c = do
createDirectoryIfMissing True (takeDirectory e.filename)
writeFile e.filename e.content
ec <-
proc "git" ["ls-files", "--error-unmatch", e.filename]
& setStdout nullStream
& setStderr nullStream
& runProcess
case ec of
ExitFailure _ -> do
pure $
Result
""
( Failure
location
( Reason $
"file "
<> show e.filename
<> " not in index"
<> "\n"
<> e.content
)
)
ExitSuccess -> do
(_, diff) <- readProcessStdout (proc "git" ["diff", e.filename])
pure $ case (ec, Text.unpack (Text.decodeUtf8 diff)) of
(ExitSuccess, "") -> Result "" Success
(_, df) ->
Result
"failed"
( Failure
location
( Reason
(unlines . drop 3 . lines $ df)
)
)
golden :: FilePath -> String -> GitGolden
golden fp str = GitGolden{filename = fp, content = str}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment