Skip to content

Commit 4ba5f60

Browse files
committed
Refactor Test.Tasty.Clash
So it'll be easier to keep the temp directory
1 parent 0ffd62e commit 4ba5f60

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/src/Test/Tasty/Clash.hs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,20 +412,23 @@ sbyTests opts@TestOptions {..} parentTmp =
412412
singleTest t (SbyVerificationTest expectVerificationFail parentTmp (dir t) t)
413413
dir = targetTempPath parentTmp "symbiyosys"
414414

415+
rmTmpDir :: FilePath -> IO ()
416+
rmTmpDir = Directory.removeDirectoryRecursive
417+
415418
runTest1
416419
:: String
417420
-> TestOptions
418421
-> [TestName]
419422
-> HDL
420423
-> TestTree
421424
runTest1 modName opts@TestOptions{..} path target =
422-
withResource mkTmpDir Directory.removeDirectoryRecursive $ \tmpDir ->
425+
withResource mkTmpDir rmTmpDir $ \tmpDir ->
423426
sequentialTestGroup (show target) AllSucceed
424427
[ clashTest tmpDir
425428
, testGroup "tools" (verifTests tmpDir : hdlTests tmpDir)
426429
]
427430
where
428-
mkTmpDir = flip createTempDirectory "clash-test" =<< getCanonicalTemporaryDirectory
431+
mkTmpDir = flip createTempDirectory ("clash-test_" <> modName) =<< getCanonicalTemporaryDirectory
429432
sourceDir = List.foldl' (</>) sourceDirectory (reverse (drop 1 path))
430433

431434
clashTest tmpDir =
@@ -499,13 +502,13 @@ outputTest'
499502
-- one closest to the test.
500503
-> TestTree
501504
outputTest' modName target extraClashArgs extraGhcArgs path =
502-
withResource mkTmpDir Directory.removeDirectoryRecursive $ \tmpDir ->
505+
withResource mkTmpDir rmTmpDir $ \tmpDir ->
503506
sequentialTestGroup (show target) AllSucceed
504507
[ clashGenHdl tmpDir
505508
, clashBuild tmpDir
506509
]
507510
where
508-
mkTmpDir = flip createTempDirectory "clash-test" =<< getCanonicalTemporaryDirectory
511+
mkTmpDir = flip createTempDirectory ("clash-test_" <> modName) =<< getCanonicalTemporaryDirectory
509512
sourceDir = List.foldl' (</>) sourceDirectory (reverse (drop 1 path))
510513

511514
clashGenHdl workDir = singleTest "clash (gen)" (ClashGenTest {
@@ -556,12 +559,12 @@ clashLibTest'
556559
-- one closest to the test.
557560
-> TestTree
558561
clashLibTest' modName target extraGhcArgs path =
559-
withResource mkTmpDir Directory.removeDirectoryRecursive $ \tmpDir ->
562+
withResource mkTmpDir rmTmpDir $ \tmpDir ->
560563
sequentialTestGroup (show target) AllSucceed
561564
[ clashBuild tmpDir
562565
]
563566
where
564-
mkTmpDir = flip createTempDirectory "clash-test" =<< getCanonicalTemporaryDirectory
567+
mkTmpDir = flip createTempDirectory ("clash-test_" <> modName) =<< getCanonicalTemporaryDirectory
565568
sourceDir = List.foldl' (</>) sourceDirectory (reverse (drop 1 path))
566569

567570
clashBuild workDir = singleTest "clash (exec)" (ClashBinaryTest {

0 commit comments

Comments
 (0)