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

Moved glitter test to other repository

parent d0ff68c4
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,44 @@
"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": {
"flake": false,
"locked": {
......@@ -49,6 +87,21 @@
"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": {
"locked": {
"lastModified": 1707939175,
......@@ -65,12 +118,29 @@
"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": {
"inputs": {
"flake-utils": "flake-utils",
"hspec-glitter": "hspec-glitter",
"language-c": "language-c",
"nix-filter": "nix-filter",
"nixpkgs": "nixpkgs"
"nix-filter": "nix-filter_2",
"nixpkgs": "nixpkgs_2"
}
},
"systems": {
......@@ -87,6 +157,21 @@
"repo": "default",
"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",
......
......@@ -7,6 +7,7 @@
url = github:kalhauge/language-c;
flake = false;
};
hspec-glitter.url = "/Users/chrg/Develop/repos/hspec-glitter";
};
outputs = {
self,
......@@ -27,11 +28,6 @@
(p.callCabal2nixWithOptions "language-c" inputs.language-c "" {}) {
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-c";
......@@ -47,7 +43,7 @@
hpkgs =
(import nixpkgs {
inherit system;
overlays = [overlays];
overlays = [inputs.hspec-glitter.overlays.default overlays];
})
.haskellPackages;
in rec {
......
......@@ -30,8 +30,5 @@ tests:
- hspec-discover
- hspec-expectations-pretty-diff
- hspec-hedgehog
- hspec-core
- typed-process
- directory
- filepath
- hspec-glitter
- bytestring
......@@ -38,7 +38,6 @@ test-suite rtree-test
Control.Monad.RTreeSpec
Data.Expr
Spec
Test.Hspec.GitGolden
Paths_rtree
hs-source-dirs:
test/src
......@@ -47,19 +46,16 @@ test-suite rtree-test
base >=4.9 && <5
, bytestring
, containers
, directory
, filepath
, hedgehog
, hspec
, hspec-core
, hspec-discover
, hspec-expectations-pretty-diff
, hspec-glitter
, hspec-hedgehog
, indexed-traversable
, mtl
, rtree
, text
, transformers
, typed-process
, vector
default-language: Haskell2010
......@@ -12,7 +12,7 @@ import Data.List.NonEmpty (nonEmpty)
import qualified Data.List.NonEmpty as NE
import qualified Data.Map.Strict as Map
import Test.Hspec
import Test.Hspec.GitGolden
import Test.Hspec.Glitter
spec :: Spec
spec = describe "examples" do
......@@ -45,12 +45,12 @@ spec = describe "examples" do
it "should find an opr" do
(mex, result) <- runWriterT (IRTree.reduce (debugPredicate showString (prettyExprS 0) predicate) me)
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
(mex, result) <- runWriterT (IRTree.reduceExp (debugPredicate showString (prettyExprS 0) predicate) me)
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
forM_ (RTree.iinputs re) \(ii, e') -> do
......
......@@ -14,7 +14,7 @@ import Data.Functor
import qualified Data.Map.Strict as Map
import Test.Hspec
import qualified Test.Hspec.Expectations.Pretty as Pretty
import Test.Hspec.GitGolden
import Test.Hspec.Glitter
shouldBeString :: String -> String -> Pretty.Expectation
shouldBeString = Pretty.shouldBe
......@@ -81,7 +81,7 @@ rtreeSpec = describe "RTree" do
describe "drawRTree" do
it "should pretty print it's tree" do
golden
glitter
"test/expected/rlist-drawrtree"
(drawRTree (\() -> id) shows (rList [1, 2, 3 :: Int]))
......@@ -108,7 +108,7 @@ examplesSpec = describe "example" do
let re = runReaderT me Map.empty
it "should draw the same" do
golden
glitter
("test/expected/" <> str)
(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.
Finish editing this message first!
Please register or to comment