@@ -25,6 +25,7 @@ import Shelly
2525import System.Directory (withCurrentDirectory, getDirectoryContents)
2626import System.Environment
2727import System.Exit (ExitCode (..))
28+import System.FilePath (replaceBaseName, takeBaseName)
2829import qualified System.Info
2930import System.IO (Handle, hClose)
3031import System.IO.Temp
@@ -151,6 +152,9 @@ main = do
151152 describe "ob run" $ {- NOT parallel $ -} do
152153 it "works in root directory" $ inTmpObInit $ \_ -> testObRunInDir Nothing httpManager
153154 it "works in sub directory" $ inTmpObInit $ \_ -> testObRunInDir (Just "frontend") httpManager
155+ it "works with differently named cabal files" $ inTmpObInit $ \_ -> do
156+ changeCabalPackageName "backend/backend.cabal" "new-backend"
157+ testObRunInDir Nothing httpManager
154158
155159 describe "obelisk project" $ parallel $ do
156160 it "can build obelisk command" $ inTmpObInit $ \_ -> nixBuild ["-A", "command" , toTextIgnore obeliskImpl]
@@ -330,6 +334,14 @@ obRunCheck httpManager _stdout frontendUri = do
330334 req frontendUri >>= \r -> when (HTTP.responseStatus r /= HTTP.ok200) $ errorExit $
331335 "Request to frontend server failed: " <> T.pack (show r)
332336
337+-- | Rename a cabal file and do a really dumb, brittle search/replace in its content to update the name.
338+changeCabalPackageName :: FilePath -> Text -> Sh ()
339+changeCabalPackageName cabalFile newName = do
340+ contents <- readfile cabalFile
341+ writefile (replaceBaseName cabalFile (T.unpack newName)) $
342+ T.replace (" " <> T.pack (takeBaseName cabalFile)) (" " <> newName) contents -- WARNING: Super brittle
343+ rm cabalFile
344+
333345getFreePorts :: Int -> IO [Socket.PortNumber]
334346getFreePorts 0 = pure []
335347getFreePorts n = Socket.withSocketsDo $ do