@@ -23,7 +23,7 @@ import qualified Network.HTTP.Client as HTTP
2323import qualified Network.HTTP.Types as HTTP
2424import qualified Network.Socket as Socket
2525import Shelly hiding (cp)
26−import System.Directory (withCurrentDirectory, getDirectoryContents)
26+import System.Directory (getCurrentDirectory, withCurrentDirectory, getDirectoryContents)
2727import System.Environment
2828import System.Exit (ExitCode (..))
2929import System.FilePath (replaceBaseName, takeBaseName)
@@ -93,17 +93,23 @@ main = do
9393 putStrLn "Tests may take longer to run if there are unbuilt derivations: use -v for verbose output"
9494 let verbosity = bool silently verbosely isVerbose
9595 nixBuild args = run "nix-build" ("--no-out-link" : args)
96− obeliskImplRaw <- fromString <$> getEnv "OBELISK_IMPL"
96+ obeliskImplDirtyReadOnly <- fromString <$> getCurrentDirectory
9797 let runOb_ = augmentWithVerbosity run_ ob isVerbose
9898 let runOb = augmentWithVerbosity run ob isVerbose
9999 let testObRunInDir' = augmentWithVerbosity testObRunInDir ob isVerbose ["run"]
100100 let testThunkPack' = augmentWithVerbosity testThunkPack ob isVerbose []
101101 let
102− withObeliskImpl f =
102+ withObeliskImplClean f =
103+ withSystemTempDirectory "obelisk-impl-clean" $ \(fromString -> obeliskImpl) -> do
104+ void . shellyOb verbosity $ chdir obeliskImpl $ do
105+ run_ "git" ["clone", "file://" <> toTextIgnore obeliskImplDirtyReadOnly, toTextIgnore obeliskImpl]
106+ f obeliskImpl
107+
108+ withObeliskImplDirty f =
103109 withSystemTempDirectory "obelisk-impl-copy" $ \(fromString -> obeliskImpl) -> do
104110 void . shellyOb verbosity $ chdir obeliskImpl $ do
105111 user <- T.strip <$> run "whoami" []
106− run_ cp ["-rT", toTextIgnore obeliskImplRaw, toTextIgnore obeliskImpl]
112+ run_ cp ["-rT", "--no-preserve=mode", toTextIgnore obeliskImplDirtyReadOnly, toTextIgnore obeliskImpl]
107113 run_ "chown" ["-R", user, toTextIgnore obeliskImpl]
108114 run_ "chmod" ["-R", "g-rw,o-rw", toTextIgnore obeliskImpl]
109115 f obeliskImpl
@@ -117,12 +123,12 @@ main = do
117123
118124 f initCache
119125
120− withObeliskImplAndInitCache f =
121− withObeliskImpl $ \impl -> withInitCache (f impl) impl
126+ withObeliskImplDirtyAndInitCache f =
127+ withObeliskImplDirty $ \impl -> withInitCache (f impl) impl
122128
123129 httpManager <- HTTP.newManager HTTP.defaultManagerSettings
124130
125− withObeliskImplAndInitCache $ \obeliskImpl initCache ->
131+ withObeliskImplDirtyAndInitCache $ \obeliskImplDirty initCache ->
126132 hspec $ parallel $ do
127133 let shelly_ = void . shellyOb verbosity
128134
@@ -142,9 +148,9 @@ main = do
142148
143149 -- To be used in tests that change the obelisk impl directory
144150 inTmpObInitWithImplCopy f = inTmpObInit $ \dir ->
145− withObeliskImpl $ \(fromString -> implCopy) -> do
151+ withObeliskImplClean $ \(fromString -> implClean) -> do
146152 run_ "rm" [thunk]
147− run_ "ln" ["-s", implCopy, thunk]
153+ run_ "ln" ["-s", implClean, thunk]
148154 f dir
149155
150156 assertRevEQ a b = liftIO . assertEqual "" "" =<< diff a b
@@ -167,7 +173,7 @@ main = do
167173 describe "ob init" $ parallel $ do
168174 it "works with default impl" $ inTmp $ \_ -> runOb ["init"]
169175 it "works with master branch impl" $ inTmp $ \_ -> runOb ["init", "--branch", "master"]
170− it "works with symlink" $ inTmp $ \_ -> runOb ["init", "--symlink", toTextIgnore obeliskImpl]
176+ it "works with symlink" $ inTmp $ \_ -> runOb ["init", "--symlink", toTextIgnore obeliskImplDirty]
171177 it "doesn't silently overwrite existing files" $ withSystemTempDirectory "ob-init λ" $ \dir -> do
172178 let p force = (System.Process.proc ob $ "--no-handoff" : "-v" : "init" : ["--force"|force]) { cwd = Just dir }
173179 (ExitSuccess, _, _) <- readCreateProcessWithExitCode (p False) ""
@@ -194,10 +200,10 @@ main = do
194200 testObRunInDir' Nothing httpManager
195201
196202 describe "obelisk project" $ parallel $ do
197− it "can build obelisk command" $ inTmpObInit $ \_ -> nixBuild ["-A", "command" , toTextIgnore obeliskImpl]
198− it "can build obelisk skeleton" $ inTmpObInit $ \_ -> nixBuild ["-A", "skeleton", toTextIgnore obeliskImpl]
199− it "can build obelisk shell" $ inTmpObInit $ \_ -> nixBuild ["-A", "shell", toTextIgnore obeliskImpl]
200− it "can build everything" $ inTmpObInit $ \_ -> nixBuild [toTextIgnore obeliskImpl]
203+ it "can build obelisk command" $ inTmpObInit $ \_ -> nixBuild ["-A", "command" , toTextIgnore obeliskImplDirty]
204+ it "can build obelisk skeleton" $ inTmpObInit $ \_ -> nixBuild ["-A", "skeleton", toTextIgnore obeliskImplDirty]
205+ it "can build obelisk shell" $ inTmpObInit $ \_ -> nixBuild ["-A", "shell", toTextIgnore obeliskImplDirty]
206+ it "can build everything" $ inTmpObInit $ \_ -> nixBuild [toTextIgnore obeliskImplDirty]
201207
202208 describe "blank initialized project" $ parallel $ do
203209
@@ -271,7 +277,7 @@ main = do
271277
272278 testThunkPack' $ fromText repo
273279
274− it "aborts thunk pack when there are uncommitted files" $ inTmpObInit $ \dir -> do
280+ it "aborts thunk pack when there are uncommitted files" $ inTmpObInitWithImplCopy $ \dir -> do
275281 testThunkPack' (dir </> thunk)
276282
277283 describe "ob thunk update --branch" $ parallel $ do
@@ -313,9 +319,9 @@ testThunkPack executable args path' = withTempFile (T.unpack $ toTextIgnore path
313319 let pack' = readProcessWithExitCode executable (T.unpack <$> ["thunk", "pack", toTextIgnore path'] ++ args) ""
314320 ensureThunkPackFails q = liftIO $ pack' >>= \case
315321 (code, out, err)
316− | code == ExitSuccess -> fail "ob thunk pack succeeded when it should have failed"
322+ | code == ExitSuccess -> fail $ "ob thunk pack succeeded when it should have failed with error '" <> show q <> "'"
317323 | q `T.isInfixOf` T.pack (out <> err) -> pure ()
318− | otherwise -> fail $ "ob thunk pack failed for an unexpected reason: " <> show out <> "\nstderr: " <> err
324+ | otherwise -> fail $ "ob thunk pack failed for an unexpected reason, expecting '" <> show q <> "', received: " <> show out <> "\nstderr: " <> err
319325 git = chdir path' . run "git"
320326 -- Untracked files
321327 ensureThunkPackFails "Untracked files"