Skip to content

Commit

Permalink
Remove false dependencies from clash-testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnbastiaan committed Jul 22, 2023
1 parent 465941c commit 98a8a87
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions tests/src/Test/Tasty/Clash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,20 @@ targetTempPath parent tool target =

stepName
:: String
-- ^ Tool name
-> String
-- ^ Step name
-> String
-- ^ Build target
-> String
stepName tool step target = tool <> " (" <> step <> " " <> target <> ")"
stepName step target = step <> " " <> target

-- | Simulation test for a specific build target
--
-- Simulation tests usually consist of two test trees: one for building designs
-- and one for running them. It depends on 'hdlLoad' and 'hdlSim' what will be
-- executed.
data TestTarget = TestTarget
{ buildTests :: [TestTree]
{ targetName :: String
, buildTests :: [TestTree]
, simTests :: [TestTree]
}

Expand Down Expand Up @@ -301,15 +300,15 @@ ghdlTests
-> [TestTarget]
ghdlTests opts@TestOptions{..} parentTmp =
flip map (getBuildTargets opts) (\t ->
TestTarget { buildTests = build t
TestTarget { targetName = "ghdl"
, buildTests = build t
, simTests = sim t
})
where
dir = targetTempPath parentTmp "ghdl"
toolName = stepName "ghdl"
importName = toolName "import"
makeName = toolName "make"
simName = toolName "sim"
importName = stepName "import"
makeName = stepName "make"
simName = stepName "sim"
build t =
[ singleTest (importName t) $ GhdlImportTest parentTmp (dir t)
, singleTest (makeName t) $ GhdlMakeTest (dir t) t
Expand All @@ -325,14 +324,14 @@ iverilogTests
-> [TestTarget]
iverilogTests opts@TestOptions{..} parentTmp =
flip map (getBuildTargets opts) (\t ->
TestTarget { buildTests = build t
TestTarget { targetName = "iverilog"
, buildTests = build t
, simTests = sim t
})
where
dir = targetTempPath parentTmp "iverilog"
toolName = stepName "iverilog"
makeName = toolName "make"
simName = toolName "sim"
makeName = stepName "make"
simName = stepName "sim"
build t =
[ singleTest (makeName t) $ IVerilogMakeTest parentTmp (dir t) t
]
Expand All @@ -348,15 +347,15 @@ modelsimTests
-> [TestTarget]
modelsimTests opts@TestOptions{..} parentTmp =
flip map (getBuildTargets opts) (\t ->
TestTarget { buildTests = build t
TestTarget { targetName = "modelsim"
, buildTests = build t
, simTests = sim t
})
where
dir = targetTempPath parentTmp "modelsim"
toolName = stepName "modelsim"
vlibName = toolName "vlib"
vlogName = toolName "vlog"
simName = toolName "sim"
vlibName = stepName "vlib"
vlogName = stepName "vlog"
simName = stepName "sim"
build t =
[ singleTest (vlibName t) $ ModelsimVlibTest parentTmp (dir t)
, singleTest (vlogName t) $ ModelsimVlogTest (dir t)
Expand All @@ -372,14 +371,14 @@ verilatorTests
-> [TestTarget]
verilatorTests opts@TestOptions{..} parentTmp =
flip map (getBuildTargets opts) (\t ->
TestTarget { buildTests = build t
TestTarget { targetName = "verilator"
, buildTests = build t
, simTests = sim t
})
where
dir = targetTempPath parentTmp "verilator"
toolName = stepName "verilator"
makeName = toolName "make"
simName = toolName "sim"
makeName = stepName "make"
simName = stepName "sim"
build t =
[ singleTest (makeName t) $ VerilatorMakeTest parentTmp (dir t) t
]
Expand All @@ -396,12 +395,13 @@ vivadoTests
-> [TestTarget]
vivadoTests opts parentTmp =
flip map (getBuildTargets opts) (\t ->
TestTarget { buildTests = []
TestTarget { targetName = "vivado"
, buildTests = []
, simTests = sim t
})
where
dir = targetTempPath parentTmp "vivado"
simName = stepName "vivado" "sim"
simName = stepName "sim"
sim t =
[ singleTest (simName t) $ VivadoTest parentTmp (dir t) (T.pack t)
]
Expand All @@ -427,9 +427,9 @@ runTest1
runTest1 modName opts@TestOptions{..} path target =
withResource mkTmpDir Directory.removeDirectoryRecursive $ \tmpDir ->
sequentialTestGroup (show target) AllSucceed
( clashTest tmpDir
: verifTests tmpDir
: hdlTests tmpDir )
[ clashTest tmpDir
, testGroup "tools" (verifTests tmpDir : hdlTests tmpDir)
]
where
mkTmpDir = flip createTempDirectory "clash-test" =<< getCanonicalTemporaryDirectory
sourceDir = List.foldl' (</>) sourceDirectory (reverse (tail path))
Expand All @@ -447,26 +447,27 @@ runTest1 modName opts@TestOptions{..} path target =

emptyGroup = testGroup "empty" []

buildAndSimTests :: Sim -> [TestTarget] -> TestTree
buildAndSimTests :: Sim -> [TestTarget] -> [TestTree]
buildAndSimTests sim tests
| isJust expectClashFail = testGroup "" []
| otherwise = sequentialTestGroup (show sim) AllSucceed $
flip concatMap tests $ \TestTarget{..} ->
(if sim `elem` hdlLoad then buildTests else []) <>
(if sim `elem` hdlSim then simTests else [])
| isJust expectClashFail = []
| otherwise =
flip map tests $ \TestTarget{..} ->
sequentialTestGroup targetName AllSucceed $
(if sim `elem` hdlLoad then buildTests else []) <>
(if sim `elem` hdlSim then simTests else [])

-- | The tests that are switched by `hdlLoad` and `hdlSim`
hdlTests tmpDir = case target of
VHDL ->
VHDL -> concat
[ buildAndSimTests GHDL (ghdlTests opts tmpDir)
, buildAndSimTests Vivado (vivadoTests opts tmpDir)
]
Verilog ->
Verilog -> concat
[ buildAndSimTests IVerilog (iverilogTests opts tmpDir)
, buildAndSimTests Verilator (verilatorTests opts tmpDir)
, buildAndSimTests Vivado (vivadoTests opts tmpDir)
]
SystemVerilog ->
SystemVerilog -> concat
[ -- TODO: ModelSim can do VHDL and Verilog too. Add that?
buildAndSimTests ModelSim (modelsimTests opts tmpDir)
, buildAndSimTests Verilator (verilatorTests opts tmpDir)
Expand Down

0 comments on commit 98a8a87

Please sign in to comment.