on master help sign in
selftest: Make ob run tests run in sequence to hopefully be less fickle
80c4e28Elliot Cameron
lib/selftest/src/Obelisk/SelfTest.hs+6−6
@@ -95,7 +95,6 @@ main = do
95 f obeliskImpl initCache
95 f obeliskImpl initCache
96
96
97 httpManager <- HTTP.newManager HTTP.defaultManagerSettings
97 httpManager <- HTTP.newManager HTTP.defaultManagerSettings
98− [p0, p1, p2, p3] <- liftIO $ getFreePorts 4
99
98
100 withObeliskImpl $ \obeliskImpl initCache ->
99 withObeliskImpl $ \obeliskImpl initCache ->
101 hspec $ parallel $ do
100 hspec $ parallel $ do
@@ -149,9 +148,9 @@ main = do
149
148
150 -- These tests fail with "Could not find module 'Obelisk.Generated.Static'"
149 -- These tests fail with "Could not find module 'Obelisk.Generated.Static'"
151 -- when not run by 'nix-build --attr selftest'
150 -- when not run by 'nix-build --attr selftest'
152− describe "ob run" $ parallel $ do
151+ describe "ob run" $ {- NOT parallel $ -} do
153− it "works in root directory" $ inTmpObInit $ \_ -> testObRunInDir p0 p1 Nothing httpManager
152+ it "works in root directory" $ inTmpObInit $ \_ -> testObRunInDir Nothing httpManager
154− it "works in sub directory" $ inTmpObInit $ \_ -> testObRunInDir p2 p3 (Just "frontend") httpManager
153+ it "works in sub directory" $ inTmpObInit $ \_ -> testObRunInDir (Just "frontend") httpManager
155
154
156 describe "obelisk project" $ parallel $ do
155 describe "obelisk project" $ parallel $ do
157 it "can build obelisk command" $ inTmpObInit $ \_ -> nixBuild ["-A", "command" , toTextIgnore obeliskImpl]
156 it "can build obelisk command" $ inTmpObInit $ \_ -> nixBuild ["-A", "command" , toTextIgnore obeliskImpl]
@@ -249,8 +248,9 @@ main = do
249
248
250
249
251-- | Run `ob run` in the given directory (maximum of one level deep)
250-- | Run `ob run` in the given directory (maximum of one level deep)
252−testObRunInDir :: Socket.PortNumber -> Socket.PortNumber -> Maybe FilePath -> HTTP.Manager -> Sh ()
251+testObRunInDir :: Maybe FilePath -> HTTP.Manager -> Sh ()
253−testObRunInDir p0 p1 mdir httpManager = handle_sh (\case ExitSuccess -> pure (); e -> throw e) $ do
252+testObRunInDir mdir httpManager = handle_sh (\case ExitSuccess -> pure (); e -> throw e) $ do
253+ [p0, p1] <- liftIO $ getFreePorts 2
254 let uri p = "http://localhost:" <> T.pack (show p) <> "/" -- trailing slash required for comparison
254 let uri p = "http://localhost:" <> T.pack (show p) <> "/" -- trailing slash required for comparison
255 writefile "config/common/route" $ uri p0
255 writefile "config/common/route" $ uri p0
256 maybe id chdir mdir $ runHandle "ob" ["run", "-v"] $ \stdout -> do
256 maybe id chdir mdir $ runHandle "ob" ["run", "-v"] $ \stdout -> do