From 66a8467a29a8850871606955211376178f691401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 24 Aug 2023 20:36:57 +0200 Subject: Accept test name selection after filepath on command line Changelog: Selection of test from test file path on command line using ':' charater --- src/Main.hs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Main.hs b/src/Main.hs index 7af4c72..4e6176f 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -19,6 +19,7 @@ import Output import Parser import Process import Run +import Test import Util import Version @@ -98,10 +99,21 @@ main = do fail $ optDefaultTool (optTest opts) <> " is not executable" files <- if not (null ofiles) - then return ofiles - else concat <$> mapM (flip globDir1 baseDir) (maybe [] configTests config) + then return $ flip map ofiles $ \ofile -> + case span (/= ':') ofile of + (path, ':':test) -> (path, Just $ T.pack test) + (path, _) -> (path, Nothing) + else map (, Nothing) . concat <$> mapM (flip globDir1 baseDir) (maybe [] configTests config) + when (null files) $ fail $ "No test files" out <- startOutput $ optVerbose opts - ok <- allM (runTest out $ optTest opts) . concat =<< mapM parseTestFile files + + tests <- forM files $ \(path, mbTestName) -> do + fileTests <- parseTestFile path + return $ case mbTestName of + Nothing -> fileTests + Just name -> filter ((==name) . testName) fileTests + + ok <- allM (runTest out $ optTest opts) $ concat tests when (not ok) exitFailure -- cgit v1.2.3