@@ -90,15 +90,19 @@ main = do
9090 let verbosity = bool silently verbosely isVerbose
9191 obeliskImpl <- fromString <$> getEnv "OBELISK_IMPL"
9292 httpManager <- HTTP.newManager HTTP.defaultManagerSettings
93− withSystemTempDirectory "blank-project" $ \blankProject ->
94− hspec $ do
93+ withSystemTempDirectory "initCache" $ \initCache -> do
94+ -- Setup the ob init cache
95+ void . shellyOb verbosity $ chdir (fromString initCache) $ do
96+ run_ "ob" ["init", "--symlink", obeliskImpl]
97+ run_ "git" ["init"]
98+ hspec $ parallel $ do
9599 let shelly_ = void . shellyOb verbosity
96100
97− inProj :: Sh a -> IO ()
98− inProj = shelly_ . chdir (fromString blankProject)
99−
100101 inTmp :: (Shelly.FilePath -> Sh a) -> IO ()
101− inTmp f = shelly_ . withSystemTempDirectory "ob-init" $ (chdir <*> f) . fromString
102+ inTmp f = shelly_ . withSystemTempDirectory "test" $ (chdir <*> f) . fromString
103+
104+ obInitFromCache dir = run_ "cp" ["-a", fromString $ initCache <> "/.", toTextIgnore dir]
105+ inTmpObInit f = inTmp $ \dir -> obInitFromCache dir *> f
102106
103107 assertRevEQ a b = liftIO . assertEqual "" "" =<< diff a b
104108 assertRevNE a b = liftIO . assertBool "" . (/= "") =<< diff a b
@@ -117,7 +121,7 @@ main = do
117121
118122 diff a b = run "git" ["diff", a, b]
119123
120− describe "ob init" $ do
124+ describe "ob init" $ parallel $ do
121125 it "works with default impl" $ inTmp $ \_ -> run "ob" ["init"]
122126 it "works with master branch impl" $ inTmp $ \_ -> run "ob" ["init", "--branch", "master"]
123127 it "works with symlink" $ inTmp $ \_ -> run "ob" ["init", "--symlink", obeliskImpl]
@@ -136,12 +140,12 @@ main = do
136140 run_ "ob" ["init"]
137141 liftIO $ withCurrentDirectory (T.unpack $ toTextIgnore tmp) $ getConfigRoute `shouldNotReturn` Nothing
138142
139− describe "ob run" $ do
140− it "works in root directory" $ inTmp $ \_ -> do
141− run_ "ob" ["init"]
143+ -- These tests fail with "Could not find module 'Obelisk.Generated.Static'"
144+ -- when not run by 'nix-build --attr selftest'
145+ describe "ob run" $ parallel $ do
146+ it "works in root directory" $ inTmpObInit $ do
142147 testObRunInDir Nothing httpManager
143− it "works in sub directory" $ inTmp $ \_ -> do
144− run_ "ob" ["init"]
148+ it "works in sub directory" $ inTmpObInit $ do
145149 testObRunInDir (Just "frontend") httpManager
146150
147151 describe "obelisk project" $ parallel $ do
@@ -151,37 +155,33 @@ main = do
151155 -- See https://github.com/obsidiansystems/obelisk/issues/101
152156 -- it "can build everything" $ shelly_ $ run "nix-build" [obeliskImpl]
153157
154− describe "blank initialized project" $ do
155− it "can be created" $ inProj $ do
156− run_ "ob" ["init"]
157− run_ "git" ["init"]
158− commitAll
158+ describe "blank initialized project" $ parallel $ do
159159
160− it "can build ghc.backend" $ inProj $ do
160+ it "can build ghc.backend" $ inTmpObInit $ do
161161 run "nix-build" ["--no-out-link", "-A", "ghc.backend"]
162− it "can build ghcjs.frontend" $ inProj $ do
162+ it "can build ghcjs.frontend" $ inTmpObInit $ do
163163 run "nix-build" ["--no-out-link", "-A", "ghcjs.frontend"]
164164
165165 if os == "darwin"
166− then it "can build ios" $ inProj $ run "nix-build" ["--no-out-link", "-A", "ios.frontend" ]
167− else it "can build android" $ inProj $ run "nix-build" ["--no-out-link", "-A", "android.frontend"]
166+ then it "can build ios" $ inTmpObInit $ run "nix-build" ["--no-out-link", "-A", "ios.frontend" ]
167+ else it "can build android" $ inTmpObInit $ run "nix-build" ["--no-out-link", "-A", "android.frontend"]
168168
169169 forM_ ["ghc", "ghcjs"] $ \compiler -> do
170170 let
171171 shell = "shells." <> compiler
172172 inShell cmd' = run "nix-shell" ["-A", fromString shell, "--run", cmd']
173− it ("can enter " <> shell) $ inProj $ inShell "exit"
174− it ("can build in " <> shell) $ inProj $ inShell $ "cabal new-build --" <> fromString compiler <> " all"
173+ it ("can enter " <> shell) $ inTmpObInit $ inShell "exit"
174+ it ("can build in " <> shell) $ inTmpObInit $ inShell $ "cabal new-build --" <> fromString compiler <> " all"
175175
176− it "can build reflex project" $ inProj $ do
176+ it "can build reflex project" $ inTmpObInit $ do
177177 run "nix-build" []
178178
179− it "has idempotent thunk update" $ inProj $ do
179+ it "has idempotent thunk update" $ inTmpObInit $ do
180180 u <- update
181181 uu <- update
182182 assertRevEQ u uu
183183
184− describe "ob thunk pack/unpack" $ do
184+ describe "ob thunk pack/unpack" $ parallel $ do
185185 it "has thunk pack and unpack inverses" $ inTmp $ \_ -> do
186186 _ <- run "ob" ["init"]
187187 _ <- run "git" ["init"]