From d5716ab8adcfac43f0c416f1f4643ca839762ddd Mon Sep 17 00:00:00 2001 From: Denis Shevchenko Date: Tue, 18 Jan 2022 18:34:12 +0400 Subject: [PATCH] tmp test macOS 4, one prop per group 3. --- .../test/Cardano/Tracer/Test/Logs/Tests.hs | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/cardano-tracer/test/Cardano/Tracer/Test/Logs/Tests.hs b/cardano-tracer/test/Cardano/Tracer/Test/Logs/Tests.hs index cf15fd78eda..8fcf8e5d345 100644 --- a/cardano-tracer/test/Cardano/Tracer/Test/Logs/Tests.hs +++ b/cardano-tracer/test/Cardano/Tracer/Test/Logs/Tests.hs @@ -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