Skip to content

Commit 8ad1337

Browse files
committed
Final fix
CI fails to create the log file without this change
1 parent 7d2962f commit 8ad1337

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

cardano-testnet/src/Testnet/Runtime.hs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
{-# LANGUAGE FlexibleInstances #-}
66
{-# LANGUAGE GADTs #-}
77
{-# LANGUAGE LambdaCase #-}
8-
{-# LANGUAGE NumericUnderscores #-}
98
{-# LANGUAGE OverloadedStrings #-}
109
{-# LANGUAGE ScopedTypeVariables #-}
1110

@@ -44,7 +43,7 @@ import GHC.Stack
4443
import qualified GHC.Stack as GHC
4544
import Network.Socket (HostAddress, PortNumber)
4645
import Prettyprinter (unAnnotate)
47-
import RIO (runRIO, threadDelay)
46+
import RIO (runRIO)
4847
import qualified System.Directory as IO
4948
import System.FilePath
5049
import qualified System.IO as IO
@@ -253,16 +252,7 @@ startNode tp node ipv4 port _testnetMagic nodeCmd = GHC.withFrozenCallStack $ do
253252
createDirectoryIfMissingNew :: HasCallStack => FilePath -> IO FilePath
254253
createDirectoryIfMissingNew directory = GHC.withFrozenCallStack $ do
255254
IO.createDirectoryIfMissing True directory
256-
exists <- IO.doesDirectoryExist directory
257-
if exists
258-
then pure directory
259-
else do
260-
threadDelay 5_000_000
261-
IO.createDirectoryIfMissing True directory
262-
exists' <- IO.doesDirectoryExist directory
263-
if exists'
264-
then pure directory
265-
else throwString $ "Failed to create directory: " <> directory
255+
pure directory
266256

267257

268258
createSubdirectoryIfMissingNew :: ()
@@ -343,8 +333,15 @@ startLedgerNewEpochStateLogging testnetRuntime tmpWorkspace = withFrozenCallStac
343333
-- | Handle all sync exceptions and log them into the log file. We don't want to fail the test just
344334
-- because logging has failed.
345335
handleException = handle $ \(e :: SomeException) -> do
346-
liftIOAnnotated $ appendFile outputFp $ "Ledger new epoch logging failed - caught exception:\n"
347-
<> displayException e <> "\n"
336+
exists <- liftIO $ IO.doesFileExist outputFp
337+
if exists
338+
then liftIO $ appendFile outputFp $ "Ledger new epoch logging failed - caught exception:\n"
339+
<> displayException e <> "\n"
340+
else
341+
liftIO $ writeFile outputFp $ unlines
342+
["Ledger new epoch logging failed - caught exception:"
343+
, displayException e
344+
]
348345
pure ConditionMet
349346

350347
calculateEpochStateDiff

0 commit comments

Comments
 (0)