Commit 831e1ce0 authored by Chitrak Raj Gupta's avatar Chitrak Raj Gupta Committed by Andrey Mokhov

Add config file and test speed options to testsuite (#624)

* Added option to specify config file

* Added speed setting for validation

* Revision
parent 19068287
...@@ -45,31 +45,33 @@ defaultCommandLineArgs = CommandLineArgs ...@@ -45,31 +45,33 @@ defaultCommandLineArgs = CommandLineArgs
-- | These arguments are used by the `test` target. -- | These arguments are used by the `test` target.
data TestArgs = TestArgs data TestArgs = TestArgs
{ testCompiler :: String { testCompiler :: String
, testConfigs :: [String] , testConfigFile :: String
, testJUnit :: Maybe FilePath , testConfigs :: [String]
, testOnly :: Maybe String , testJUnit :: Maybe FilePath
, testOnlyPerf :: Bool , testOnly :: Maybe String
, testSkipPerf :: Bool , testOnlyPerf :: Bool
, testSpeed :: TestSpeed , testSkipPerf :: Bool
, testSummary :: Maybe FilePath , testSpeed :: TestSpeed
, testVerbosity:: Maybe String , testSummary :: Maybe FilePath
, testWays :: [String] } , testVerbosity :: Maybe String
, testWays :: [String] }
deriving (Eq, Show) deriving (Eq, Show)
-- | Default value for `TestArgs`. -- | Default value for `TestArgs`.
defaultTestArgs :: TestArgs defaultTestArgs :: TestArgs
defaultTestArgs = TestArgs defaultTestArgs = TestArgs
{ testCompiler = "stage2" { testCompiler = "stage2"
, testConfigs = [] , testConfigFile = "testsuite/config/ghc"
, testJUnit = Nothing , testConfigs = []
, testOnly = Nothing , testJUnit = Nothing
, testOnlyPerf = False , testOnly = Nothing
, testSkipPerf = False , testOnlyPerf = False
, testSpeed = Average , testSkipPerf = False
, testSummary = Nothing , testSpeed = Fast
, testVerbosity= Nothing , testSummary = Nothing
, testWays = [] } , testVerbosity = Nothing
, testWays = [] }
readConfigure :: Either String (CommandLineArgs -> CommandLineArgs) readConfigure :: Either String (CommandLineArgs -> CommandLineArgs)
readConfigure = Right $ \flags -> flags { configure = True } readConfigure = Right $ \flags -> flags { configure = True }
...@@ -136,6 +138,12 @@ readTestConfig config = ...@@ -136,6 +138,12 @@ readTestConfig config =
let configs = conf : testConfigs (testArgs flags) let configs = conf : testConfigs (testArgs flags)
in flags { testArgs = (testArgs flags) { testConfigs = configs } } in flags { testArgs = (testArgs flags) { testConfigs = configs } }
readTestConfigFile :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestConfigFile filepath =
maybe (Left "Cannot parse test-speed") (Right . set) filepath
where
set filepath flags = flags { testArgs = (testArgs flags) { testConfigFile = 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 } }
...@@ -197,6 +205,8 @@ optDescrs = ...@@ -197,6 +205,8 @@ optDescrs =
"Generate split objects (requires a full clean rebuild)." "Generate split objects (requires a full clean rebuild)."
, Option [] ["test-compiler"] (OptArg readTestCompiler "TEST_COMPILER") , Option [] ["test-compiler"] (OptArg readTestCompiler "TEST_COMPILER")
"Use given compiler [Default=stage2]." "Use given compiler [Default=stage2]."
, Option [] ["test-config-file"] (OptArg readTestConfigFile "CONFIG_FILE")
"congiguration file for testsuite. Default=testsuite/config/ghc"
, Option [] ["config"] (OptArg readTestConfig "EXTRA_TEST_CONFIG") , Option [] ["config"] (OptArg readTestConfig "EXTRA_TEST_CONFIG")
"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")
......
...@@ -4,6 +4,7 @@ import GHC ...@@ -4,6 +4,7 @@ import GHC
import Oracles.Setting import Oracles.Setting
import Rules.Gmp import Rules.Gmp
import Settings.Builders.Common import Settings.Builders.Common
import CommandLine
makeBuilderArgs :: Args makeBuilderArgs :: Args
makeBuilderArgs = do makeBuilderArgs = do
...@@ -23,7 +24,8 @@ validateBuilderArgs = builder (Make "testsuite/tests") ? do ...@@ -23,7 +24,8 @@ validateBuilderArgs = builder (Make "testsuite/tests") ? do
compiler <- expr $ fullpath ghc compiler <- expr $ fullpath ghc
checkPpr <- expr $ fullpath checkPpr checkPpr <- expr $ fullpath checkPpr
checkApiAnnotations <- expr $ fullpath checkApiAnnotations checkApiAnnotations <- expr $ fullpath checkApiAnnotations
return [ "fast" args <- expr $ userSetting defaultTestArgs
return [ setTestSpeed $ testSpeed args
, "THREADS=" ++ show threads , "THREADS=" ++ show threads
, "TEST_HC=" ++ (top -/- compiler) , "TEST_HC=" ++ (top -/- compiler)
, "CHECK_PPR=" ++ (top -/- checkPpr) , "CHECK_PPR=" ++ (top -/- checkPpr)
...@@ -33,3 +35,8 @@ validateBuilderArgs = builder (Make "testsuite/tests") ? do ...@@ -33,3 +35,8 @@ validateBuilderArgs = builder (Make "testsuite/tests") ? do
fullpath :: Package -> Action FilePath fullpath :: Package -> Action FilePath
fullpath pkg = programPath =<< programContext Stage1 pkg fullpath pkg = programPath =<< programContext Stage1 pkg
-- | Support for speed of validation
setTestSpeed :: TestSpeed -> String
setTestSpeed Fast = "fasttest"
setTestSpeed Average = "test"
setTestSpeed Slow = "slowtest"
...@@ -80,7 +80,6 @@ runTestBuilderArgs = builder RunTest ? do ...@@ -80,7 +80,6 @@ runTestBuilderArgs = builder RunTest ? do
, arg "-e", arg $ "config.arch=" ++ show arch , arg "-e", arg $ "config.arch=" ++ show arch
, arg "-e", arg $ "config.platform=" ++ show platform , arg "-e", arg $ "config.platform=" ++ show platform
, arg "--config-file=testsuite/config/ghc"
, arg "--config", arg $ "gs=gs" -- Use the default value as in test.mk , arg "--config", arg $ "gs=gs" -- Use the default value as in test.mk
, arg "--config", arg $ "timeout_prog=" ++ show (top -/- timeoutProg) , arg "--config", arg $ "timeout_prog=" ++ show (top -/- timeoutProg)
, arg $ "--threads=" ++ show threads , arg $ "--threads=" ++ show threads
...@@ -94,7 +93,8 @@ getTestArgs = do ...@@ -94,7 +93,8 @@ getTestArgs = do
bindir <- expr $ setBinaryDirectory (testCompiler args) bindir <- expr $ setBinaryDirectory (testCompiler args)
compiler <- expr $ setCompiler (testCompiler args) compiler <- expr $ setCompiler (testCompiler args)
globalVerbosity <- shakeVerbosity <$> expr getShakeOptions globalVerbosity <- shakeVerbosity <$> expr getShakeOptions
let testOnlyArg = case testOnly args of let configFileArg= ["--config-file=" ++ (testConfigFile args)]
testOnlyArg = case testOnly args of
Just cases -> map ("--only=" ++) (words cases) Just cases -> map ("--only=" ++) (words cases)
Nothing -> [] Nothing -> []
onlyPerfArg = if testOnlyPerf args onlyPerfArg = if testOnlyPerf args
...@@ -120,7 +120,7 @@ getTestArgs = do ...@@ -120,7 +120,7 @@ getTestArgs = do
haddockArg = ["--config", "haddock=" ++ show (bindir -/- "haddock")] haddockArg = ["--config", "haddock=" ++ show (bindir -/- "haddock")]
hp2psArg = ["--config", "hp2ps=" ++ show (bindir -/- "hp2ps")] hp2psArg = ["--config", "hp2ps=" ++ show (bindir -/- "hp2ps")]
hpcArg = ["--config", "hpc=" ++ show (bindir -/- "hpc")] hpcArg = ["--config", "hpc=" ++ show (bindir -/- "hpc")]
pure $ testOnlyArg ++ speedArg pure $ configFileArg ++ testOnlyArg ++ speedArg
++ catMaybes [ onlyPerfArg, skipPerfArg, summaryArg ++ catMaybes [ onlyPerfArg, skipPerfArg, summaryArg
, junitArg, verbosityArg ] , junitArg, verbosityArg ]
++ configArgs ++ wayArgs ++ compilerArg ++ ghcPkgArg ++ configArgs ++ wayArgs ++ compilerArg ++ ghcPkgArg
......
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