summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-01-18 12:14:03 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-09 02:53:05 -0500
commit2ac784ab381aae936ee3be7c8685e0203ee4dbf6 (patch)
treed8cb9280f1c30b6376a7e01a58d1f4b314bf9474
parent1f630025d457807c4a9da513e4a0823e4643b2a6 (diff)
downloadhaskell-2ac784ab381aae936ee3be7c8685e0203ee4dbf6.tar.gz
hadrian: Add --test-metrics argument
Allowing the test metric output to be captured to a file, a la the METRIC_FILE environment variable of the make build system.
-rw-r--r--hadrian/doc/testsuite.md3
-rw-r--r--hadrian/src/CommandLine.hs7
-rw-r--r--hadrian/src/Settings/Builders/RunTest.hs5
3 files changed, 14 insertions, 1 deletions
diff --git a/hadrian/doc/testsuite.md b/hadrian/doc/testsuite.md
index a905e8b3bb..12ad4cb87c 100644
--- a/hadrian/doc/testsuite.md
+++ b/hadrian/doc/testsuite.md
@@ -112,6 +112,9 @@ build test --only-perf
build test --skip-perf
```
+The testsuite driver will produce a summary of the observed performance metrics
+if `hadrian` is passed the `--summary-metrics=<file>` flag.
+
## Test speed
You can run the tests in `slow`, `normal` (default) or `fast`
diff --git a/hadrian/src/CommandLine.hs b/hadrian/src/CommandLine.hs
index dcb42b8a32..afb791eb2a 100644
--- a/hadrian/src/CommandLine.hs
+++ b/hadrian/src/CommandLine.hs
@@ -52,6 +52,7 @@ data TestArgs = TestArgs
, testConfigFile :: String
, testConfigs :: [String]
, testJUnit :: Maybe FilePath
+ , testMetrics :: Maybe FilePath
, testOnly :: [String]
, testOnlyPerf :: Bool
, testSkipPerf :: Bool
@@ -71,6 +72,7 @@ defaultTestArgs = TestArgs
, testConfigFile = "testsuite/config/ghc"
, testConfigs = []
, testJUnit = Nothing
+ , testMetrics = Nothing
, testOnly = []
, testOnlyPerf = False
, testSkipPerf = False
@@ -143,6 +145,9 @@ readTestConfigFile filepath =
readTestJUnit :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestJUnit filepath = Right $ \flags -> flags { testArgs = (testArgs flags) { testJUnit = filepath } }
+readTestMetrics :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
+readTestMetrics filepath = Right $ \flags -> flags { testArgs = (testArgs flags) { testMetrics = filepath } }
+
readTestOnly :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestOnly tests = Right $ \flags ->
flags { testArgs = (testArgs flags) { testOnly = tests'' flags } }
@@ -240,6 +245,8 @@ optDescrs =
"Configurations to run test, in key=value format."
, Option [] ["summary-junit"] (OptArg readTestJUnit "TEST_SUMMARY_JUNIT")
"Output testsuite summary in JUnit format."
+ , Option [] ["summary-metrics"] (OptArg readTestMetrics "METRICS_FILE")
+ "Output testsuite performance metrics summary."
, Option [] ["only"] (OptArg readTestOnly "TESTS")
"Test cases to run."
, Option [] ["only-perf"] (NoArg readTestOnlyPerf)
diff --git a/hadrian/src/Settings/Builders/RunTest.hs b/hadrian/src/Settings/Builders/RunTest.hs
index d3ce1c6fb8..c1febb92ac 100644
--- a/hadrian/src/Settings/Builders/RunTest.hs
+++ b/hadrian/src/Settings/Builders/RunTest.hs
@@ -169,6 +169,9 @@ getTestArgs = do
junitArg = case testJUnit args of
Just filepath -> Just $ "--junit=" ++ filepath
Nothing -> Nothing
+ metricsArg = case testMetricsFile args of
+ Just filepath -> Just $ "--metrics-file=" ++ filepath
+ Nothing -> Nothing
configArgs = concat [["-e", configArg] | configArg <- testConfigs args]
verbosityArg = case testVerbosity args of
Nothing -> Just $ "--verbose=" ++ show (fromEnum globalVerbosity)
@@ -186,7 +189,7 @@ getTestArgs = do
pure $ configFileArg ++ testOnlyArg ++ speedArg
++ catMaybes [ onlyPerfArg, skipPerfArg, summaryArg
- , junitArg, verbosityArg ]
+ , junitArg, metricsArg, verbosityArg ]
++ configArgs ++ wayArgs ++ compilerArg ++ ghcPkgArg
++ haddockArg ++ hp2psArg ++ hpcArg ++ inTreeArg