@@ -415,6 +415,33 @@ runSessionWithServerInTmpDir' ::
415
415
Session a -> IO a
416
416
runSessionWithServerInTmpDir' plugins conf sessConf caps tree act = runSessionWithServerInTmpDirCont False plugins conf sessConf caps tree (const act)
417
417
418
+ runWithLockInTempDir :: VirtualFileTree -> (FileSystem -> IO a ) -> IO a
419
+ runWithLockInTempDir tree act = withLock lockForTempDirs $ do
420
+ testRoot <- setupTestEnvironment
421
+ helperRecorder <- hlsHelperTestRecorder
422
+ -- Do not clean up the temporary directory if this variable is set to anything but '0'.
423
+ -- Aids debugging.
424
+ cleanupTempDir <- lookupEnv " HLS_TEST_HARNESS_NO_TESTDIR_CLEANUP"
425
+ let runTestInDir action = case cleanupTempDir of
426
+ Just val | val /= " 0" -> do
427
+ (tempDir, _) <- newTempDirWithin testRoot
428
+ a <- action tempDir
429
+ logWith helperRecorder Debug LogNoCleanup
430
+ pure a
431
+
432
+ _ -> do
433
+ (tempDir, cleanup) <- newTempDirWithin testRoot
434
+ a <- action tempDir `finally` cleanup
435
+ logWith helperRecorder Debug LogCleanup
436
+ pure a
437
+ runTestInDir $ \ tmpDir' -> do
438
+ -- we canonicalize the path, so that we do not need to do
439
+ -- cannibalization during the test when we compare two paths
440
+ tmpDir <- canonicalizePath tmpDir'
441
+ logWith helperRecorder Info $ LogTestDir tmpDir
442
+ fs <- FS. materialiseVFT tmpDir tree
443
+ act fs
444
+
418
445
-- | Host a server, and run a test session on it.
419
446
--
420
447
-- Creates a temporary directory, and materializes the VirtualFileTree
@@ -449,33 +476,8 @@ runSessionWithServerInTmpDirCont ::
449
476
ClientCapabilities ->
450
477
VirtualFileTree ->
451
478
(FileSystem -> Session a ) -> IO a
452
- runSessionWithServerInTmpDirCont disableKick plugins conf sessConf caps tree act = withLock lockForTempDirs $ do
453
- testRoot <- setupTestEnvironment
454
- helperRecorder <- hlsHelperTestRecorder
455
-
456
- -- Do not clean up the temporary directory if this variable is set to anything but '0'.
457
- -- Aids debugging.
458
- cleanupTempDir <- lookupEnv " HLS_TEST_HARNESS_NO_TESTDIR_CLEANUP"
459
- let runTestInDir action = case cleanupTempDir of
460
- Just val | val /= " 0" -> do
461
- (tempDir, _) <- newTempDirWithin testRoot
462
- a <- action tempDir
463
- logWith helperRecorder Debug LogNoCleanup
464
- pure a
465
-
466
- _ -> do
467
- (tempDir, cleanup) <- newTempDirWithin testRoot
468
- a <- action tempDir `finally` cleanup
469
- logWith helperRecorder Debug LogCleanup
470
- pure a
471
-
472
- runTestInDir $ \ tmpDir' -> do
473
- -- we canonicalize the path, so that we do not need to do
474
- -- cannibalization during the test when we compare two paths
475
- tmpDir <- canonicalizePath tmpDir'
476
- logWith helperRecorder Info $ LogTestDir tmpDir
477
- fs <- FS. materialiseVFT tmpDir tree
478
- runSessionWithServer' disableKick plugins conf sessConf caps tmpDir (act fs)
479
+ runSessionWithServerInTmpDirCont disableKick plugins conf sessConf caps tree act =
480
+ runWithLockInTempDir tree $ \ fs -> runSessionWithServer' disableKick plugins conf sessConf caps (fsRoot fs) (act fs)
479
481
480
482
runSessionWithServer :: Pretty b => Config -> PluginTestDescriptor b -> FilePath -> Session a -> IO a
481
483
runSessionWithServer config plugin fp act = do
0 commit comments