[Git][ghc/ghc][master] Hadrian: add --test-root-dirs, to only run specific directories of tests
Marge Bot
gitlab at gitlab.haskell.org
Wed May 22 20:55:58 UTC 2019
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
2c15b85e by Alp Mestanogullari at 2019-05-22T20:52:22Z
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.
- - - - -
3 changed files:
- hadrian/doc/testsuite.md
- hadrian/src/CommandLine.hs
- hadrian/src/Settings/Builders/RunTest.hs
Changes:
=====================================
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
=====================================
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")
=====================================
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"
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/2c15b85eb2541a64df0cdf3705fb9aa068634004
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/2c15b85eb2541a64df0cdf3705fb9aa068634004
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190522/39aacc85/attachment-0001.html>
More information about the ghc-commits
mailing list