From 2b4a9c3d7353d4e12112dcc0ae028bf3719f88e8 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Mon, 13 Jul 2026 11:05:59 +0000 Subject: [PATCH] tests: create separate tmp folders for test clients (#7244) --- tests/ChatClient.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/ChatClient.hs b/tests/ChatClient.hs index c803570d99..c194b0c961 100644 --- a/tests/ChatClient.hs +++ b/tests/ChatClient.hs @@ -66,6 +66,7 @@ import Simplex.Messaging.Transport.Server (ServerCredentials (..), mkTransportSe import Simplex.Messaging.Version import Simplex.Messaging.Version.Internal import System.Directory (createDirectoryIfMissing, removeDirectoryRecursive) +import System.FilePath (()) import qualified System.Terminal as C import System.Terminal.Internal (VirtualTerminal (..), VirtualTerminalSettings (..), withVirtualTerminal) import System.Timeout (timeout) @@ -79,7 +80,6 @@ import Data.ByteArray (ScrubbedBytes) import qualified Data.Map.Strict as M import Simplex.Messaging.Agent.Client (agentClientStore) import Simplex.Messaging.Agent.Store.Common (withConnection) -import System.FilePath (()) #endif #if defined(dbPostgres) @@ -283,13 +283,13 @@ createTestChat ps cfg opts@ChatOpts {coreOptions = coreOptions@CoreChatOpts {cha insertUser agentStore ts <- getCurrentTime Right user <- withTransaction chatStore $ \db' -> runExceptT $ createUserRecordAt db' (AgentUserId 1) chatRelay clientService profile True ts - startTestChat_ ps db cfg opts user + startTestChat_ ps db cfg opts dbPrefix user startTestChat :: TestParams -> ChatConfig -> ChatOpts -> String -> IO TestCC startTestChat ps cfg opts@ChatOpts {coreOptions} dbPrefix = do Right db@ChatDatabase {chatStore} <- createDatabase ps coreOptions dbPrefix Just user <- find activeUser <$> withTransaction chatStore getUsers - startTestChat_ ps db cfg opts user + startTestChat_ ps db cfg opts dbPrefix user createDatabase :: TestParams -> CoreChatOpts -> String -> IO (Either MigrationError ChatDatabase) #if defined(dbPostgres) @@ -306,12 +306,12 @@ insertUser :: DBStore -> IO () insertUser st = withTransaction st (`DB.execute_` "INSERT INTO users (user_id) VALUES (1)") #endif -startTestChat_ :: TestParams -> ChatDatabase -> ChatConfig -> ChatOpts -> User -> IO TestCC -startTestChat_ TestParams {printOutput} db cfg opts@ChatOpts {coreOptions = CoreChatOpts {maintenance}} user = do +startTestChat_ :: TestParams -> ChatDatabase -> ChatConfig -> ChatOpts -> String -> User -> IO TestCC +startTestChat_ TestParams {tmpPath, printOutput} db cfg opts@ChatOpts {coreOptions = CoreChatOpts {maintenance}} dbPrefix user = do t <- withVirtualTerminal termSettings pure ct <- newChatTerminal t opts Right cc <- newChatController db (Just user) cfg opts False - void $ execChatCommand' (SetTempFolder "tests/tmp/tmp") 0 `runReaderT` cc + void $ execChatCommand' (SetTempFolder (tmpPath dbPrefix)) 0 `runReaderT` cc chatAsync <- async $ runSimplexChat cfg opts user cc $ \_u cc' -> runChatTerminal ct cc' opts unless maintenance $ atomically $ readTVar (agentAsync cc) >>= \a -> when (isNothing a) retry termQ <- newTQueueIO