$OpenBSD$

SPDX-License-Identifier: AGPL-3.0-only

Skip server-backed integration tests that require simplexmq server modules.
The port builds simplexmq with +client_library to avoid the server dependency
set, so keep only tests that compile against the client library. v7 restructured
the test entry point to use tmpTestBracket; remove all withSmpServer-reliant
blocks and the ChatClient dependency.

Index: tests/Test.hs
--- tests/Test.hs.orig
+++ tests/Test.hs
@@ -3,13 +3,14 @@
 {-# LANGUAGE NamedFieldPuns #-}
 {-# LANGUAGE TupleSections #-}
 
-import Bots.BroadcastTests
-import Bots.DirectoryTests
-import ChatClient
-import ChatTests
-import ChatTests.DBUtils
-import ChatTests.Names (chatNamesTests)
-import ChatTests.Utils (xdescribe'')
+-- import Bots.BroadcastTests
+-- import Bots.DirectoryTests
+-- import ChatClient
+-- import ChatTests
+-- import ChatTests.DBUtils
+-- import ChatTests.Names (chatNamesTests)
+-- import ChatTests.Utils (xdescribe'')
+import Control.Exception (bracket_)
 import Control.Logger.Simple
 import Data.Time.Clock.System
 import BadgeTests
@@ -20,21 +20,21 @@
 import ProtocolTests
 import OperatorTests
 import RandomServers
-import RemoteTests
+-- import RemoteTests
+import System.Directory (createDirectoryIfMissing, removeDirectoryRecursive)
 import Test.Hspec hiding (it)
 import UnliftIO.Temporary (withTempDirectory)
 import ValidNames
 import ViewTests
 #if defined(dbPostgres)
-import Control.Exception (bracket_)
 import PostgresSchemaDump
 import Simplex.Chat.Store.Postgres.Migrations (migrations)
 import Simplex.Messaging.Agent.Store.Postgres.Util (createDBAndUserIfNotExists, dropDatabaseAndUser)
-import System.Directory (createDirectoryIfMissing, removePathForcibly)
+import System.Directory (removePathForcibly)
 #else
 import APIDocs
-import qualified Simplex.Messaging.TMap as TM
-import MobileTests
+-- import qualified Simplex.Messaging.TMap as TM
+-- import MobileTests
 import SchemaDump
 import WebRTCTests
 #endif
@@ -42,14 +42,10 @@
 main :: IO ()
 main = do
   setLogLevel LogError
-#if !defined(dbPostgres)
-  chatQueryStats <- TM.emptyIO
-  agentQueryStats <- TM.emptyIO
-#endif
   withGlobalLogging logCfg . hspec
     $ do
 #if defined(dbPostgres)
-      createdDropDb . around_ (bracket_ (createDirectoryIfMissing False "tests/tmp") (removePathForcibly "tests/tmp")) $
+      createdDropDb . around_ (bracket_ (createDirectoryIfMissing False "tests/tmp") (removeDirectoryRecursive "tests/tmp")) $
         describe "Postgres schema dump" $
           postgresSchemaDumpTest
             migrations
@@ -72,42 +72,32 @@
       describe "Message batching" batchingTests
       describe "Operators" operatorTests
       describe "Random servers" randomServersTests
-#if !defined(dbPostgres)
-      around (tmpTestBracket chatQueryStats agentQueryStats) $ describe "names tests" chatNamesTests
-      around (tmpTestBracket chatQueryStats agentQueryStats) $ xdescribe'' "SimpleX Directory names" directoryNameTests
-#endif
-#if defined(dbPostgres)
-      createdDropDb . around testBracket
-#else
-      around (testBracket chatQueryStats agentQueryStats)
-#endif
-        $ do
-#if !defined(dbPostgres)
-          describe "Mobile API Tests" mobileTests
-#endif
-          describe "SimpleX chat client" chatTests
-          xdescribe'' "SimpleX Broadcast bot" broadcastBotTests
-          xdescribe'' "SimpleX Directory service bot" directoryServiceTests
-          describe "Remote session" remoteTests
-#if !defined(dbPostgres)
-          xdescribe'' "Save query plans" saveQueryPlans
-#endif
+      -- The OpenBSD port builds simplexmq with +client_library, so the
+      -- SMP/XFTP server-backed integration tests cannot compile here.
+      -- Disabled groups:
+      --   names tests
+      --   Directory names
+      --   Mobile API Tests
+      --   SimpleX chat client
+      --   SimpleX Broadcast bot
+      --   SimpleX Directory service bot
+      --   Remote session
+      --   Save query plans
   where
 #if defined(dbPostgres)
     createdDropDb =
       before_ (dropDatabaseAndUser testDBConnectInfo >> createDBAndUserIfNotExists testDBConnectInfo)
         . after_ (dropDatabaseAndUser testDBConnectInfo)
-    testBracket test = withSmpServer $ tmpBracket $ \tmpPath -> test TestParams {tmpPath, printOutput = False}
-#else
-    testBracket chatQueryStats agentQueryStats test =
-      withSmpServer $ tmpBracket $ \tmpPath -> test TestParams {tmpPath, chatQueryStats, agentQueryStats, printOutput = False}
-    tmpTestBracket chatQueryStats agentQueryStats test =
-      tmpBracket $ \tmpPath -> test TestParams {tmpPath, chatQueryStats, agentQueryStats, printOutput = False}
 #endif
     tmpBracket test = do
       t <- getSystemTime
       let ts = show (systemSeconds t) <> show (systemNanoseconds t)
       withTmpFiles $ withTempDirectory "tests/tmp" ts test
+    withTmpFiles :: IO a -> IO a
+    withTmpFiles =
+      bracket_
+        (createDirectoryIfMissing False "tests/tmp")
+        (removeDirectoryRecursive "tests/tmp")
 
 logCfg :: LogConfig
 logCfg = LogConfig {lc_file = Nothing, lc_stderr = True}

