summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorAlp Mestanogullari <alpmestan@gmail.com>2019-05-14 18:16:52 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-05-22 16:52:22 -0400
commit2c15b85eb2541a64df0cdf3705fb9aa068634004 (patch)
treeb3d784084788fc29cc09f4115c9048bc00f44640 /hadrian
parentecc9366a0e0db107c286935130837b2222e2dd82 (diff)
downloadhaskell-2c15b85eb2541a64df0cdf3705fb9aa068634004.tar.gz
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.
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/doc/testsuite.md31
-rw-r--r--hadrian/src/CommandLine.hs14
-rw-r--r--hadrian/src/Settings/Builders/RunTest.hs8
3 files changed, 49 insertions, 4 deletions
diff --git a/hadrian/doc/testsuite.md b/hadrian/doc/testsuite.md
index f1164ff39e..a905e8b3bb 100644
--- a/hadrian/doc/testsuite.md
+++ b/hadrian/doc/testsuite.md
@@ -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
diff --git a/hadrian/src/CommandLine.hs b/hadrian/src/CommandLine.hs
index 37d6607a24..41b2f8d0b9 100644
--- a/hadrian/src/CommandLine.hs
+++ b/hadrian/src/CommandLine.hs
@@ -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")
diff --git a/hadrian/src/Settings/Builders/RunTest.hs b/hadrian/src/Settings/Builders/RunTest.hs
index 21796478a7..6cc11f8aef 100644
--- a/hadrian/src/Settings/Builders/RunTest.hs
+++ b/hadrian/src/Settings/Builders/RunTest.hs
@@ -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"