diff --git a/tests/src/Test/Tasty/Clash.hs b/tests/src/Test/Tasty/Clash.hs index a6779c08cd..58bc40988f 100644 --- a/tests/src/Test/Tasty/Clash.hs +++ b/tests/src/Test/Tasty/Clash.hs @@ -180,13 +180,11 @@ 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 -- @@ -194,7 +192,8 @@ stepName tool step target = tool <> " (" <> step <> " " <> target <> ")" -- 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] } @@ -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 @@ -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 ] @@ -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) @@ -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 ] @@ -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) ] @@ -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)) @@ -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)