From f93e2335aea6f20af143347defd07a214206c11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Mon, 12 May 2025 20:29:49 +0200 Subject: Select tests from project configuration by name Changelog: Select tests from project configuration using only test name on command line without script path. --- README.md | 18 +++++++++++++++--- src/Main.hs | 35 +++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 511501b..15fb488 100644 --- a/README.md +++ b/README.md @@ -56,14 +56,26 @@ cmake --build build erebos-tester --verbose ``` -To run tests from a given test file, pass it as command-line argument: +To run all tests from project configuration (see below), run the tester without any argument: ``` -erebos-tester path/to/script.test +erebos-tester +``` + +To run only some named tests, list the names on command line: +``` +erebos-tester FirstTest SecondTest +``` + +To run tests from a given test file, pass it as command-line argument (the path +must contain a slash, so use e.g. `./script.et` for script in the current +directory): +``` +erebos-tester path/to/script.et ``` To select single test from a file, use `:` separator: ``` -erebos-tester path/to/script.test:TestName +erebos-tester path/to/script.et:TestName ``` Configuration diff --git a/src/Main.hs b/src/Main.hs index abc96ac..48f95df 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -123,15 +123,21 @@ main = do } args <- getArgs - (opts, ofiles) <- case getOpt Permute (options ++ hiddenOptions) args of + (opts, oselection) <- case getOpt Permute (options ++ hiddenOptions) args of (o, files, []) -> return (foldl (flip id) initOpts o, files) (_, _, errs) -> do hPutStrLn stderr $ concat errs <> "Try `erebos-tester --help' for more information." exitFailure + let ( ofiles, otests ) + | any (any isPathSeparator) oselection = ( oselection, [] ) + | otherwise = ( [], map T.pack oselection ) + when (optShowHelp opts) $ do let header = unlines - [ "Usage: erebos-tester [