Commit 2ac784ab authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

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.
parent 1f630025
...@@ -112,6 +112,9 @@ build test --only-perf ...@@ -112,6 +112,9 @@ build test --only-perf
build test --skip-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 ## Test speed
You can run the tests in `slow`, `normal` (default) or `fast` You can run the tests in `slow`, `normal` (default) or `fast`
......
...@@ -52,6 +52,7 @@ data TestArgs = TestArgs ...@@ -52,6 +52,7 @@ data TestArgs = TestArgs
, testConfigFile :: String , testConfigFile :: String
, testConfigs :: [String] , testConfigs :: [String]
, testJUnit :: Maybe FilePath , testJUnit :: Maybe FilePath
, testMetrics :: Maybe FilePath
, testOnly :: [String] , testOnly :: [String]
, testOnlyPerf :: Bool , testOnlyPerf :: Bool
, testSkipPerf :: Bool , testSkipPerf :: Bool
...@@ -71,6 +72,7 @@ defaultTestArgs = TestArgs ...@@ -71,6 +72,7 @@ defaultTestArgs = TestArgs
, testConfigFile = "testsuite/config/ghc" , testConfigFile = "testsuite/config/ghc"
, testConfigs = [] , testConfigs = []
, testJUnit = Nothing , testJUnit = Nothing
, testMetrics = Nothing
, testOnly = [] , testOnly = []
, testOnlyPerf = False , testOnlyPerf = False
, testSkipPerf = False , testSkipPerf = False
...@@ -143,6 +145,9 @@ readTestConfigFile filepath = ...@@ -143,6 +145,9 @@ readTestConfigFile filepath =
readTestJUnit :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) readTestJUnit :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestJUnit filepath = Right $ \flags -> flags { testArgs = (testArgs flags) { testJUnit = filepath } } 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 :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestOnly tests = Right $ \flags -> readTestOnly tests = Right $ \flags ->
flags { testArgs = (testArgs flags) { testOnly = tests'' flags } } flags { testArgs = (testArgs flags) { testOnly = tests'' flags } }
...@@ -240,6 +245,8 @@ optDescrs = ...@@ -240,6 +245,8 @@ optDescrs =
"Configurations to run test, in key=value format." "Configurations to run test, in key=value format."
, Option [] ["summary-junit"] (OptArg readTestJUnit "TEST_SUMMARY_JUNIT") , Option [] ["summary-junit"] (OptArg readTestJUnit "TEST_SUMMARY_JUNIT")
"Output testsuite summary in JUnit format." "Output testsuite summary in JUnit format."
, Option [] ["summary-metrics"] (OptArg readTestMetrics "METRICS_FILE")
"Output testsuite performance metrics summary."
, Option [] ["only"] (OptArg readTestOnly "TESTS") , Option [] ["only"] (OptArg readTestOnly "TESTS")
"Test cases to run." "Test cases to run."
, Option [] ["only-perf"] (NoArg readTestOnlyPerf) , Option [] ["only-perf"] (NoArg readTestOnlyPerf)
......
...@@ -169,6 +169,9 @@ getTestArgs = do ...@@ -169,6 +169,9 @@ getTestArgs = do
junitArg = case testJUnit args of junitArg = case testJUnit args of
Just filepath -> Just $ "--junit=" ++ filepath Just filepath -> Just $ "--junit=" ++ filepath
Nothing -> Nothing Nothing -> Nothing
metricsArg = case testMetricsFile args of
Just filepath -> Just $ "--metrics-file=" ++ filepath
Nothing -> Nothing
configArgs = concat [["-e", configArg] | configArg <- testConfigs args] configArgs = concat [["-e", configArg] | configArg <- testConfigs args]
verbosityArg = case testVerbosity args of verbosityArg = case testVerbosity args of
Nothing -> Just $ "--verbose=" ++ show (fromEnum globalVerbosity) Nothing -> Just $ "--verbose=" ++ show (fromEnum globalVerbosity)
...@@ -186,7 +189,7 @@ getTestArgs = do ...@@ -186,7 +189,7 @@ getTestArgs = do
pure $ configFileArg ++ testOnlyArg ++ speedArg pure $ configFileArg ++ testOnlyArg ++ speedArg
++ catMaybes [ onlyPerfArg, skipPerfArg, summaryArg ++ catMaybes [ onlyPerfArg, skipPerfArg, summaryArg
, junitArg, verbosityArg ] , junitArg, metricsArg, verbosityArg ]
++ configArgs ++ wayArgs ++ compilerArg ++ ghcPkgArg ++ configArgs ++ wayArgs ++ compilerArg ++ ghcPkgArg
++ haddockArg ++ hp2psArg ++ hpcArg ++ inTreeArg ++ haddockArg ++ hp2psArg ++ hpcArg ++ inTreeArg
......
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