@@ -4,6 +4,7 @@
44{-# LANGUAGE PatternGuards #-}
55{-# LANGUAGE ScopedTypeVariables #-}
66{-# LANGUAGE ViewPatterns #-}
7+{-# LANGUAGE TemplateHaskell #-}
78module Obelisk.SelfTest where
89
910import Control.Exception (bracket, throw)
@@ -21,11 +22,12 @@ import qualified Data.Text.IO as T
2122import qualified Network.HTTP.Client as HTTP
2223import qualified Network.HTTP.Types as HTTP
2324import qualified Network.Socket as Socket
24−import Shelly
25+import Shelly hiding (cp)
2526import System.Directory (withCurrentDirectory, getDirectoryContents)
2627import System.Environment
2728import System.Exit (ExitCode (..))
2829import System.FilePath (replaceBaseName, takeBaseName)
30+import System.Which (staticWhich)
2931import qualified System.Info
3032import System.IO (Handle, hClose)
3133import System.IO.Temp
@@ -44,6 +46,9 @@ data ObRunState
4446 | ObRunState_BackendStarted
4547 deriving (Eq, Show)
4648
49+cp :: FilePath
50+cp = $(staticWhich "cp")
51+
4752doubleQuotes :: (IsString a, Semigroup a) => a -> a
4853doubleQuotes s = "\"" <> s <> "\""
4954
@@ -69,6 +74,7 @@ tshow = T.pack . show
6974shellyOb :: MonadIO m => (Sh a -> Sh a) -> Sh a -> m a
7075shellyOb f obTest = shelly $ f obTest
7176
77+
7278main :: IO ()
7379main = do
7480 -- Note: you can pass hspec arguments as well, eg: `-m <pattern>`
@@ -83,7 +89,7 @@ main = do
8389 withSystemTempDirectory "obelisk-impl-copy" $ \(fromString -> obeliskImpl) -> do
8490 void . shellyOb verbosity $ chdir obeliskImpl $ do
8591 user <- T.strip <$> run "whoami" []
86− run_ "cp" ["-rT", toTextIgnore obeliskImplRaw, toTextIgnore obeliskImpl]
92+ run_ cp ["-rT", toTextIgnore obeliskImplRaw, toTextIgnore obeliskImpl]
8793 run_ "chown" ["-R", user, toTextIgnore obeliskImpl]
8894 run_ "chmod" ["-R", "g-rw,o-rw", toTextIgnore obeliskImpl]
8995 f obeliskImpl
@@ -112,7 +118,7 @@ main = do
112118 withTmp f = shelly_ . withSystemTempDirectory "test λ" $ f . fromString
113119
114120 inTmpObInit f = inTmp $ \dir -> do
115− run_ "cp" ["-rT", fromString initCache, toTextIgnore dir]
121+ run_ cp ["-rT", fromString initCache, toTextIgnore dir]
116122 f dir
117123
118124 -- To be used in tests that change the obelisk impl directory