From cc26e52cb0baeae120372e694f9fde1f1027cc32 Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Mon, 9 Sep 2024 15:50:48 -0400 Subject: [PATCH] what the hell --- flake.lock | 12 ++++++------ .../src/Templatespiler/ToLang/Target.hs | 2 +- templatespiler-converter/test/Main.hs | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index 35e6004..63cbd33 100644 --- a/flake.lock +++ b/flake.lock @@ -74,11 +74,11 @@ }, "haskell-flake": { "locked": { - "lastModified": 1725314890, - "narHash": "sha256-jjVrhLOlPjQiZ/8pe+g6Xc5sa563WXnNZDwGXVl4PXQ=", + "lastModified": 1725811060, + "narHash": "sha256-lmPoWYNT8kI8LSTa0Z3id38SoR05+05IEZ3fxeIwOzE=", "owner": "srid", "repo": "haskell-flake", - "rev": "ed94388c2e622f28cb45108a4e73c9d2b2a796da", + "rev": "9b490fe01ec8f6858f43d3cc81bfbbd0000eb29e", "type": "github" }, "original": { @@ -89,11 +89,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1725534445, - "narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=", + "lastModified": 1725816686, + "narHash": "sha256-0Kq2MkQ/sQX1rhWJ/ySBBQlBJBUK8mPMDcuDhhdBkSU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9bb1e7571aadf31ddb4af77fc64b2d59580f9a39", + "rev": "add0443ee587a0c44f22793b8c8649a0dbc3bb00", "type": "github" }, "original": { diff --git a/templatespiler-converter/src/Templatespiler/ToLang/Target.hs b/templatespiler-converter/src/Templatespiler/ToLang/Target.hs index 5fd2faf..32c6cc1 100644 --- a/templatespiler-converter/src/Templatespiler/ToLang/Target.hs +++ b/templatespiler-converter/src/Templatespiler/ToLang/Target.hs @@ -1,7 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} -{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FunctionalDependencies #-} +{-# LANGUAGE TypeFamilies #-} module Templatespiler.ToLang.Target where diff --git a/templatespiler-converter/test/Main.hs b/templatespiler-converter/test/Main.hs index 5077e6e..a2a69e2 100644 --- a/templatespiler-converter/test/Main.hs +++ b/templatespiler-converter/test/Main.hs @@ -1,9 +1,11 @@ +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE PackageImports #-} module Main where import Control.Monad.Morph (hoist) import Control.Monad.Trans.Resource +import Data.List (intersperse) import Data.Text.IO qualified as Text import Hedgehog (Property, evalEither, evalMaybe, forAll, property) import Hedgehog.Internal.Property (failWith) @@ -22,9 +24,12 @@ import Test.Syd import Test.Syd.Hedgehog () import Text.Trifecta import "temporary-resourcet" System.IO.Temp qualified as TempResourceT +import System.Environment (getEnv) main :: IO () -main = sydTest spec +main = do + getEnv "PATH" >>= putStrLn + sydTest spec spec :: Spec spec = describe "Integration Test" $ do @@ -62,7 +67,7 @@ withCompiled lang code = do compiledFile <- case lang of Python -> pure sourceFp C -> do - liftIO $ callProcess "cc" [sourceFp, "-o", fp "a.out"] + liftIO $ callProcess "gcc" [sourceFp, "-o", fp "a.out"] pure $ fp <> "/a.out" let (cmdToRun, argsToRun) = case lang of @@ -73,12 +78,7 @@ withCompiled lang code = do runProcessWithStdin :: Text -> [Text] -> [Text] -> IO () runProcessWithStdin processName args input = do - let inputText = unlines input - (Just hin, Just hout, _, _) <- createProcess (proc "sh" (["-c", toString processName] ++ map toString args)) {std_in = CreatePipe, std_out = CreatePipe} - Text.hPutStrLn hin inputText - hFlush hin - -- assert that the process exits successfully with no output - output <- Text.hGetContents hout + output <- readProcess (toString processName) (toString <$> args) (toString $ unlines input) output `shouldBe` "" parseTemplate :: Text -> Either Text BindingList