Commit 2c15b85e authored by Alp Mestanogullari's avatar Alp Mestanogullari Committed by Marge Bot

Hadrian: add --test-root-dirs, to only run specific directories of tests

We can specify several of those, by using the flag multiple times or
just once but combining the directories with ':'.

Along the way, this patch also fixes the testsuite-related --only flag,
so that we can use it many times instead of being force to specify a
space-separated list of test in a single --only flag.
parent ecc9366a
Pipeline #5948 failed with stages
in 497 minutes and 2 seconds
......@@ -19,6 +19,8 @@ needed by the tests.
## Running only a subset of the testsuite
### Specific tests
You can use the `TEST` environment variable, like with the
Make build system, or the `--only=...` command line argument.
This is best illustrated with examples:
......@@ -40,6 +42,35 @@ TEST="test1 test2" build test
TEST="test1 test2" build test --only="test3 test4"
```
### Whole directories of tests
You can also ask Hadrian to run all the tests that live under one or
more directories, under which the testsuite driver will be looking for
`.T` files (usually called `all.T`), where our tests are declared.
By default, the `test` rule tries to run all the tests available (the ones
under `testsuite/tests/` as well as all the tests of the boot libraries
or programs (`base`, `haddock`, etc).
To restrict the testsuite driver to only run a specific directory of tests,
e.g `testsuite/tests/th`, you can simply do:
``` sh
$ build -j test --test-root-dirs=testsuite/tests/th
```
If you want to run several directories of tests, you can either
use several `--test-root-dirs` arguments or just one but separating
the various directories with `:`:
``` sh
# first approach
build -j test --test-root-dirs=testsuite/tests/th --test-root-dirs=testsuite/tests/gadt
# second approach
build -j test --test-root-dirs=testsuite/tests/th:testsuite/tests/gadt
```
## Accepting new output
You can use the `-a` or `--test-accept` flag to "accept" the new
......
......@@ -53,6 +53,7 @@ data TestArgs = TestArgs
, testOnly :: [String]
, testOnlyPerf :: Bool
, testSkipPerf :: Bool
, testRootDirs :: [FilePath]
, testSpeed :: TestSpeed
, testSummary :: Maybe FilePath
, testVerbosity :: Maybe String
......@@ -71,6 +72,7 @@ defaultTestArgs = TestArgs
, testOnly = []
, testOnlyPerf = False
, testSkipPerf = False
, testRootDirs = []
, testSpeed = TestNormal
, testSummary = Nothing
, testVerbosity = Nothing
......@@ -153,9 +155,10 @@ readTestJUnit filepath = Right $ \flags -> flags { testArgs = (testArgs flags) {
readTestOnly :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestOnly tests = Right $ \flags ->
flags { testArgs = (testArgs flags) { testOnly = tests' } }
flags { testArgs = (testArgs flags) { testOnly = tests'' flags } }
where tests' = maybe [] words tests
tests'' flags = testOnly (testArgs flags) ++ tests'
readTestOnlyPerf :: Either String (CommandLineArgs -> CommandLineArgs)
readTestOnlyPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testOnlyPerf = True } }
......@@ -163,6 +166,13 @@ readTestOnlyPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testO
readTestSkipPerf :: Either String (CommandLineArgs -> CommandLineArgs)
readTestSkipPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testSkipPerf = True } }
readTestRootDirs :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestRootDirs rootdirs = Right $ \flags ->
flags { testArgs = (testArgs flags) { testRootDirs = rootdirs'' flags } }
where rootdirs' = maybe [] (splitOn ":") rootdirs
rootdirs'' flags = testRootDirs (testArgs flags) ++ rootdirs'
readTestSpeed :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestSpeed ms =
maybe (Left "Cannot parse test-speed") (Right . set) (go =<< lower <$> ms)
......@@ -243,6 +253,8 @@ optDescrs =
"Only run performance tests."
, Option [] ["skip-perf"] (NoArg readTestSkipPerf)
"Skip performance tests."
, Option [] ["test-root-dirs"] (OptArg readTestRootDirs "DIR1:[DIR2:...:DIRn]")
"Test root directories to look at (all by default)."
, Option [] ["test-speed"] (OptArg readTestSpeed "SPEED")
"fast, slow or normal. Normal by default"
, Option [] ["summary"] (OptArg readTestSummary "TEST_SUMMARY")
......
......@@ -86,7 +86,10 @@ runTestBuilderArgs = builder RunTest ? do
top <- expr $ topDirectory
ghcFlags <- expr runTestGhcFlags
timeoutProg <- expr buildRoot <&> (-/- timeoutPath)
cmdrootdirs <- expr (testRootDirs <$> userSetting defaultTestArgs)
let defaultRootdirs = ("testsuite" -/- "tests") : libTests
rootdirs | null cmdrootdirs = defaultRootdirs
| otherwise = cmdrootdirs
-- See #16087
let ghcBuiltByLlvm = False -- TODO: Implement this check
......@@ -94,8 +97,7 @@ runTestBuilderArgs = builder RunTest ? do
-- TODO: set CABAL_MINIMAL_BUILD/CABAL_PLUGIN_BUILD
mconcat [ arg $ "testsuite/driver/runtests.py"
, arg $ "--rootdir=" ++ ("testsuite" -/- "tests")
, pure ["--rootdir=" ++ test | test <- libTests]
, pure [ "--rootdir=" ++ testdir | testdir <- rootdirs ]
, arg "-e", arg $ "windows=" ++ show windows
, arg "-e", arg $ "darwin=" ++ show darwin
, arg "-e", arg $ "config.local=False"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment