diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2023-08-24 20:36:57 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2023-08-24 20:54:22 +0200 |
commit | 66a8467a29a8850871606955211376178f691401 (patch) | |
tree | 1803317ae8c12917bcd89645cd24f7ad9fe62f13 | |
parent | 92c763ad490accaec833ccf7a4775a5a3d4d078a (diff) |
Accept test name selection after filepath on command line
Changelog: Selection of test from test file path on command line using ':' charater
-rw-r--r-- | src/Main.hs | 18 |
1 files changed, 15 insertions, 3 deletions
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 |