Skip to content

Commit

Permalink
tmp test macOS 4, one prop per group 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Shevchenko committed Jan 18, 2022
1 parent ce7efa1 commit d5716ab
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions cardano-tracer/test/Cardano/Tracer/Test/Logs/Tests.hs
Expand Up @@ -51,40 +51,36 @@ propLogs format rootDir localSock = do

doesDirectoryExist rootDir >>= \case
True -> do
traceIO "Logs, 1__"
traceIO $ "Logs, 1__, rootDir" <> rootDir
-- ... and contains one node's subdir...
listDirectory rootDir >>= \case
[] -> false "root dir is empty"
(subDir:_) -> do
traceIO "Logs, 2__"
withCurrentDirectory rootDir $ do
traceIO $ "Logs, 3__. rootDir " <> rootDir
-- ... with *.log-files inside...
listDirectory subDir >>= \case
[] -> false "subdir is empty"
logsAndSymLink -> do
traceIO $ "Logs, 3__. subDir " <> subDir
withCurrentDirectory subDir $ do
traceIO $ "Logs, 4__"
case filter (isItLog format) logsAndSymLink of
[] -> do
traceIO $ "Logs, 5__, logsAndSymLink " <> show logsAndSymLink
false "subdir doesn't contain expected logs"
logsWeNeed ->
if length logsWeNeed > 1
then
-- ... and one symlink...
filterM (isItSymLink format) logsAndSymLink >>= \case
[] -> false "subdir doesn't contain a symlink"
[symLink] -> do
-- ... to the latest *.log-file.
maybeLatestLog <- getSymbolicLinkTarget symLink
-- The logs' names contain timestamps, so the
-- latest log is the maximum one.
let latestLog = maximum logsWeNeed
return $ latestLog === takeFileName maybeLatestLog
_ -> false "there is more than one symlink"
else false "there is still 1 single log, no rotation"
-- ... with *.log-files inside...
let pathToSubDir = rootDir </> subDir
traceIO $ "Logs, 3__. pathToSubDir " <> pathToSubDir
listDirectory pathToSubDir >>= \case
[] -> false "subdir is empty"
logsAndSymLink ->
case filter (isItLog format) logsAndSymLink of
[] -> do
traceIO $ "Logs, 5__, logsAndSymLink " <> show logsAndSymLink
false "subdir doesn't contain expected logs"
logsWeNeed ->
if length logsWeNeed > 1
then
-- ... and one symlink...
filterM (isItSymLink format) logsAndSymLink >>= \case
[] -> false "subdir doesn't contain a symlink"
[symLink] -> do
-- ... to the latest *.log-file.
maybeLatestLog <- getSymbolicLinkTarget symLink
-- The logs' names contain timestamps, so the
-- latest log is the maximum one.
let latestLog = maximum logsWeNeed
return $ latestLog === takeFileName maybeLatestLog
_ -> false "there is more than one symlink"
else false "there is still 1 single log, no rotation"
False -> false "root dir doesn't exist"
where
config root p = TracerConfig
Expand Down

0 comments on commit d5716ab

Please sign in to comment.