From c8e901277844d93e0ce890e4863ef5837717e3a4 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 7 Apr 2018 15:13:58 -0700 Subject: [PATCH] Some minor fixups for compilation --- hnix.cabal | 3 ++- tests/NixLanguageTests.hs | 3 +-- tests/TestCommon.hs | 31 ++++++++++++++----------------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/hnix.cabal b/hnix.cabal index 747ad3e..ae24380 100644 --- a/hnix.cabal +++ b/hnix.cabal @@ -2,7 +2,7 @@ -- -- see: https://github.com/sol/hpack -- --- hash: 429fc2370bb078161c283b1238eb797ca1c03c46e4c1a2f68ac80937a901bb79 +-- hash: 2a22f1191905e2b66f2d356247a272e923144902c5ad6026fe72d137f8127a77 name: hnix version: 0.5.0 @@ -135,6 +135,7 @@ test-suite hnix-tests NixLanguageTests ParserTests PrettyTests + TestCommon Paths_hnix hs-source-dirs: tests diff --git a/tests/NixLanguageTests.hs b/tests/NixLanguageTests.hs index 95620d9..e0f17f3 100644 --- a/tests/NixLanguageTests.hs +++ b/tests/NixLanguageTests.hs @@ -23,7 +23,6 @@ import Nix.Utils import Nix.Stack import Nix.Value import Nix.XML -import System.Directory import System.Environment import System.FilePath import System.FilePath.Glob (compile, globDir1) @@ -128,7 +127,7 @@ assertEval files = catch go $ \case assertEvalFail :: FilePath -> Assertion assertEvalFail file = catch ?? (\(_ :: SomeException) -> return ()) $ do - evalResult <- printNix <$> nixEvalFile file + evalResult <- printNix <$> hnixEvalFile file evalResult `seq` assertFailure $ file ++ " should not evaluate.\nThe evaluation result was `" ++ evalResult ++ "`." diff --git a/tests/TestCommon.hs b/tests/TestCommon.hs index 73607c9..ccc178d 100644 --- a/tests/TestCommon.hs +++ b/tests/TestCommon.hs @@ -1,16 +1,16 @@ module TestCommon where -import Nix -import Nix.Monad -import Nix.Monad.Instance -import Nix.Parser -import Nix.Pretty -import System.Directory -import System.Environment -import System.IO -import System.Posix.Temp -import System.Process -import Test.Tasty.HUnit +import Nix +import Nix.Monad.Instance +import Nix.Parser +import Nix.Pretty +import Nix.Value +import System.Environment +import System.IO +import System.Posix.Files +import System.Posix.Temp +import System.Process +import Test.Tasty.HUnit hnixEvalFile :: FilePath -> IO (NValueNF (Lazy IO)) hnixEvalFile file = do @@ -23,8 +23,7 @@ hnixEvalFile file = do evalLoc (Just file) expression hnixEvalString :: String -> IO (NValueNF (Lazy IO)) -hnixEvalString expr = do - case parseNixString expr of +hnixEvalString expr = case parseNixString expr of Failure err -> error $ "Parsing failed for expressien `" ++ expr ++ "`.\n" ++ show err Success expression -> eval Nothing expression @@ -35,13 +34,11 @@ nixEvalString expr = do hPutStr h expr hClose h res <- nixEvalFile fp - removeFile fp + removeLink fp return res nixEvalFile :: FilePath -> IO String -nixEvalFile fp = do - readProcess "nix-instantiate" ["--eval", fp] "" - +nixEvalFile fp = readProcess "nix-instantiate" ["--eval", fp] "" assertEvalMatchesNix :: String -> Assertion assertEvalMatchesNix expr = do