Skip to content

Commit fa78d47

Browse files
committed
Run cabal-add tests in temporary directories
1 parent e781ccd commit fa78d47

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

plugins/hls-cabal-plugin/test/Utils.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import qualified Ide.Plugin.Cabal
1414
import Ide.Plugin.Cabal.Completion.Types
1515
import System.FilePath
1616
import Test.Hls
17-
import Test.Hls.FileSystem (VirtualFileTree)
17+
import qualified Test.Hls.FileSystem as FS
1818

1919

2020
cabalPlugin :: PluginTestDescriptor Ide.Plugin.Cabal.Log
@@ -52,22 +52,22 @@ runCabalTestCaseSession :: TestName -> FilePath -> Session () -> TestTree
5252
runCabalTestCaseSession title subdir = testCase title . runCabalSession subdir
5353

5454
runHaskellTestCaseSession :: TestName -> FilePath -> Session () -> TestTree
55-
runHaskellTestCaseSession title subdir = testCase title . runHaskellAndCabalSession subdir
55+
runHaskellTestCaseSession title subdir = testCase title . runHaskellAndCabalSession (FS.mkVirtualFileTree testDataDir [FS.copyDir subdir])
5656

5757
runCabalSession :: FilePath -> Session a -> IO a
5858
runCabalSession subdir =
59-
failIfSessionTimeout . runSessionWithServer def cabalPlugin (testDataDir </> subdir)
59+
failIfSessionTimeout . runSessionWithServerInTmpDir def cabalPlugin (FS.mkVirtualFileTree testDataDir [FS.copyDir subdir])
6060

61-
runCabalTestCaseSessionVft :: TestName -> VirtualFileTree -> Session () -> TestTree
61+
runCabalTestCaseSessionVft :: TestName -> FS.VirtualFileTree -> Session () -> TestTree
6262
runCabalTestCaseSessionVft title vft = testCase title . runCabalSessionVft vft
6363

64-
runCabalSessionVft :: VirtualFileTree -> Session a -> IO a
64+
runCabalSessionVft :: FS.VirtualFileTree -> Session a -> IO a
6565
runCabalSessionVft vft =
6666
failIfSessionTimeout . runSessionWithServerInTmpDir def cabalPlugin vft
6767

68-
runHaskellAndCabalSession :: FilePath -> Session a -> IO a
69-
runHaskellAndCabalSession subdir =
70-
failIfSessionTimeout . runSessionWithServer def (cabalPlugin <> cabalHaskellPlugin) (testDataDir </> subdir)
68+
runHaskellAndCabalSession :: FS.VirtualFileTree -> Session a -> IO a
69+
runHaskellAndCabalSession vft =
70+
failIfSessionTimeout . runSessionWithServerInTmpDir def (cabalPlugin <> cabalHaskellPlugin) vft
7171

7272
runCabalGoldenSession :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
7373
runCabalGoldenSession title subdir fp act = goldenWithCabalDoc def cabalPlugin title testDataDir (subdir </> fp) "golden" "cabal" act

0 commit comments

Comments
 (0)