-
Notifications
You must be signed in to change notification settings - Fork 37
Added support for testsuite #602
Changes from 11 commits
39e3cc2
0d6050b
fffd876
a6b5e05
cf67794
b98524f
d06ef68
5961be4
29a6a0d
d886a74
cf9a443
71d87c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
module CommandLine ( | ||
optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, cmdIntegerSimple, | ||
cmdProgressColour, cmdProgressInfo, cmdConfigure, cmdSplitObjects, | ||
cmdInstallDestDir, lookupBuildRoot, TestArgs(..), defaultTestArgs | ||
cmdInstallDestDir, lookupBuildRoot, TestArgs(..), TestSpeed(..), | ||
defaultTestArgs | ||
) where | ||
|
||
import Data.Either | ||
|
@@ -12,6 +13,8 @@ import Hadrian.Utilities hiding (buildRoot) | |
import System.Console.GetOpt | ||
import System.Environment | ||
|
||
data TestSpeed = Slow | Average | Fast deriving (Show, Eq) | ||
|
||
-- | All arguments that can be passed to Hadrian via the command line. | ||
data CommandLineArgs = CommandLineArgs | ||
{ configure :: Bool | ||
|
@@ -42,21 +45,29 @@ defaultCommandLineArgs = CommandLineArgs | |
|
||
-- | These arguments are used by the `test` target. | ||
data TestArgs = TestArgs | ||
{ testOnly :: Maybe String | ||
{ testConfigs :: [String] | ||
, testJUnit :: Maybe FilePath | ||
, testOnly :: Maybe String | ||
, testOnlyPerf :: Bool | ||
, testSkipPerf :: Bool | ||
, testSpeed :: TestSpeed | ||
, testSummary :: Maybe FilePath | ||
, testJUnit :: Maybe FilePath | ||
, testConfigs :: [String] } | ||
, testVerbosity:: Maybe String | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shake already provides a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The verbose option of Shake is boolean, whereas test suite supports 5 levels of verbosity. This is why I chose to pass a separate verbose argument. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that it may be convenient to control these two verbosity settings separately: you might want verbose testing, but not Shake diagnostic info. And vice versa. So, let's keep this flag. |
||
, testWays :: [String] } | ||
deriving (Eq, Show) | ||
|
||
-- | Default value for `TestArgs`. | ||
defaultTestArgs :: TestArgs | ||
defaultTestArgs = TestArgs | ||
{ testOnly = Nothing | ||
{ testConfigs = [] | ||
, testJUnit = Nothing | ||
, testOnly = Nothing | ||
, testOnlyPerf = False | ||
, testSkipPerf = False | ||
, testSpeed = Average | ||
, testSummary = Nothing | ||
, testJUnit = Nothing | ||
, testConfigs = [] } | ||
, testVerbosity= Nothing | ||
, testWays = [] } | ||
|
||
readConfigure :: Either String (CommandLineArgs -> CommandLineArgs) | ||
readConfigure = Right $ \flags -> flags { configure = True } | ||
|
@@ -110,26 +121,52 @@ readProgressInfo ms = | |
readSplitObjects :: Either String (CommandLineArgs -> CommandLineArgs) | ||
readSplitObjects = Right $ \flags -> flags { splitObjects = True } | ||
|
||
readTestConfig :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestConfig config = | ||
case config of | ||
Nothing -> Right id | ||
Just conf -> Right $ \flags -> | ||
let configs = conf : testConfigs (testArgs flags) | ||
in flags { testArgs = (testArgs flags) { testConfigs = configs } } | ||
|
||
readTestJUnit :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestJUnit filepath = Right $ \flags -> flags { testArgs = (testArgs flags) { testJUnit = filepath } } | ||
|
||
readTestOnly :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestOnly tests = Right $ \flags -> flags { testArgs = (testArgs flags) { testOnly = tests } } | ||
|
||
readTestOnlyPerf :: Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestOnlyPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testOnlyPerf = True } } | ||
|
||
readTestSkipPerf :: Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestSkipPerf = Right $ \flags -> flags { testArgs = (testArgs flags) { testSkipPerf = True } } | ||
|
||
readTestSpeed :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestSpeed ms = | ||
maybe (Left "Cannot parse test-speed") (Right . set) (go =<< lower <$> ms) | ||
where | ||
go :: String -> Maybe TestSpeed | ||
go "fast" = Just Fast | ||
go "slow" = Just Slow | ||
go "average" = Just Average | ||
go _ = Nothing | ||
set :: TestSpeed -> CommandLineArgs -> CommandLineArgs | ||
set flag flags = flags { testArgs = (testArgs flags) {testSpeed = flag} } | ||
|
||
readTestSummary :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestSummary filepath = Right $ \flags -> flags { testArgs = (testArgs flags) { testJUnit = filepath } } | ||
|
||
readTestJUnit :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestJUnit filepath = Right $ \flags -> flags { testArgs = (testArgs flags) { testJUnit = filepath } } | ||
|
||
readTestConfig :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestConfig config = | ||
case config of | ||
Nothing -> Right id | ||
Just conf -> Right $ \flags -> | ||
let configs = conf : testConfigs (testArgs flags) | ||
in flags { testArgs = (testArgs flags) { testConfigs = configs } } | ||
|
||
readTestVerbose :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestVerbose verbose = Right $ \flags -> flags { testArgs = (testArgs flags) { testVerbosity = verbose } } | ||
|
||
readTestWay :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs) | ||
readTestWay ways = | ||
case ways of | ||
Nothing -> Right id | ||
Just way -> Right $ \flags -> | ||
let newWays = way : testWays (testArgs flags) | ||
in flags { testArgs = (testArgs flags) {testWays = newWays} } | ||
-- | Standard 'OptDescr' descriptions of Hadrian's command line arguments. | ||
optDescrs :: [OptDescr (Either String (CommandLineArgs -> CommandLineArgs))] | ||
optDescrs = | ||
|
@@ -151,17 +188,25 @@ optDescrs = | |
"Progress info style (None, Brief, Normal or Unicorn)." | ||
, Option [] ["split-objects"] (NoArg readSplitObjects) | ||
"Generate split objects (requires a full clean rebuild)." | ||
, Option [] ["config"] (OptArg readTestConfig "EXTRA_TEST_CONFIG") | ||
"Configurations to run test, in key=value format." | ||
, Option [] ["summary-junit"] (OptArg readTestJUnit "TEST_SUMMARY_JUNIT") | ||
"Output testsuite summary in JUnit format." | ||
, Option [] ["only"] (OptArg readTestOnly "TESTS") | ||
"Test cases to run." | ||
, Option [] ["only-perf"] (NoArg readTestOnlyPerf) | ||
"Only run performance tests." | ||
, Option [] ["skip-perf"] (NoArg readTestSkipPerf) | ||
"Skip performance tests." | ||
, Option [] ["test-speed"] (OptArg readTestSpeed "SPEED") | ||
"fast, slow or normal. Normal by default" | ||
, Option [] ["summary"] (OptArg readTestSummary "TEST_SUMMARY") | ||
"Where to output the test summary file." | ||
, Option [] ["summary-junit"] (OptArg readTestJUnit "TEST_SUMMARY_JUNIT") | ||
"Output testsuite summary in JUnit format." | ||
, Option [] ["config"] (OptArg readTestConfig "EXTRA_TEST_CONFIG") | ||
"Configurations to run test, in key=value format." ] | ||
|
||
, Option [] ["test-verbose"] (OptArg readTestVerbose "TEST_VERBOSE") | ||
"A verbosity value between 0 and 5. 0 is silent, 4 and higher activates extra output." | ||
, Option [] ["test-way"] (OptArg readTestWay "TEST_WAY") | ||
"only run these ways" ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to document all these flags. You don't need to do this right in this PR, but at least please create an issue so that we don't forget about this. |
||
-- | A type-indexed map containing Hadrian command line arguments to be passed | ||
-- to Shake via 'shakeExtra'. | ||
cmdLineArgsMap :: IO (Map.HashMap TypeRep Dynamic) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ module Hadrian.Utilities ( | |
(<&>), (%%>), cmdLineLengthLimit, | ||
|
||
-- * Useful re-exports | ||
Dynamic, fromDynamic, toDyn, TypeRep, typeOf | ||
Dynamic, fromDynamic, toDyn, TypeRep, typeOf, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop the comma |
||
) where | ||
|
||
import Control.Monad.Extra | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import Expression | |
import GHC | ||
import Oracles.Flag | ||
import Oracles.Setting | ||
import Settings | ||
import Target | ||
import Utilities | ||
|
||
|
@@ -63,13 +64,23 @@ testRules = do | |
-- Execute the test target. | ||
buildWithCmdOptions env $ target (vanillaContext Stage2 compiler) RunTest [] [] | ||
|
||
-- | Build extra programs required by testsuite | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code below suggests that there are not only testsuite programs, but also testsuite libraries. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chitrak7 So, do you really need to handle libraries here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to handle rts library. I just cannot yet figure out how. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need to handle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't understand why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some files are missing in rts library causing multiple failures. At the moment, I cannot figure out which files are missing. Or they may be missing includes. I have to look into this matter further. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand how The comment for this function says "Build extra programs required by testsuite", but the implementation can also build libraries. This is an inconsistency that should be fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay! I think I should create an issue regarding this and temporarily install required programs only. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved |
||
needTestsuiteBuilders :: Action () | ||
needTestsuiteBuilders = do | ||
targets <- mapM (needfile Stage1) =<< testsuitePackages | ||
need targets | ||
where | ||
needfile :: Stage -> Package -> Action FilePath | ||
needfile stage pkg = programPath =<< programContext stage pkg | ||
|
||
|
||
needTestBuilders :: Action () | ||
needTestBuilders = do | ||
needBuilder $ Ghc CompileHs Stage2 | ||
needBuilder $ GhcPkg Update Stage1 | ||
needBuilder Hp2Ps | ||
needBuilder Hpc | ||
needBuilder (Hsc2Hs Stage1) | ||
needTestsuiteBuilders | ||
|
||
-- | Extra flags to send to the Haskell compiler to run tests. | ||
runTestGhcFlags :: Action String | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
module Settings.Builders.Make (makeBuilderArgs) where | ||
module Settings.Builders.Make (makeBuilderArgs, validateBuilderArgs) where | ||
|
||
import GHC | ||
import Oracles.Setting | ||
import Rules.Gmp | ||
import Rules.Libffi | ||
import Settings.Builders.Common | ||
|
@@ -13,5 +15,22 @@ makeBuilderArgs = do | |
mconcat | ||
[ builder (Make gmpPath ) ? pure ["MAKEFLAGS=-j" ++ t] | ||
, builder (Make libffiPath ) ? pure ["MAKEFLAGS=-j" ++ t, "install"] | ||
, builder (Make "testsuite/tests") ? pure ["THREADS=" ++ t, "fast"] | ||
] | ||
|
||
validateBuilderArgs :: Args | ||
validateBuilderArgs = builder (Make "testsuite/tests") ? do | ||
threads <- shakeThreads <$> expr getShakeOptions | ||
top <- expr topDirectory | ||
compiler <- expr $ fullpath ghc | ||
checkPpr <- expr $ fullpath checkPpr | ||
checkApiAnnotations <- expr $ fullpath checkApiAnnotations | ||
return [ "fast" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this is the default validate argument. Speed can be specified by running ./build.sh test and not validate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worst case, we can later arrange to support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. I can do that right now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I guess we can leave this for later. |
||
, "THREADS=" ++ show threads | ||
, "TEST_HC=" ++ (top -/- compiler) | ||
, "CHECK_PPR=" ++ (top -/- checkPpr) | ||
, "CHECK_API_ANNOTATIONS=" ++ (top -/- checkApiAnnotations) | ||
] | ||
where | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, a type signature might help. |
||
fullpath :: Package -> Action FilePath | ||
fullpath pkg = programPath =<< programContext Stage1 pkg | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hadrian (or Shake) already has
-jN
option, which is enough to control the speed of running testsuite. We don't need thetestThreads
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sighingnow Indeed! Well spotted.