24ee9c962ed9754b869bab73003204aed7855b2a
[hadrian.git] / src / Settings / Builders / RunTest.hs
1 module Settings.Builders.RunTest (runTestBuilderArgs) where
2
3 import CommandLine (TestArgs(..), defaultTestArgs)
4 import Flavour
5 import GHC.Packages
6 import Hadrian.Builder (getBuilderPath)
7 import Hadrian.Utilities
8 import Rules.Test
9 import Settings.Builders.Common
10
11 -- Arguments to send to the runtest.py script.
12 runTestBuilderArgs :: Args
13 runTestBuilderArgs = builder RunTest ? do
14 pkgs <- expr $ stagePackages Stage1
15 libTests <- expr $ filterM doesDirectoryExist $ concat
16 [ [ pkgPath pkg -/- "tests", pkgPath pkg -/- "tests-ghc" ]
17 | pkg <- pkgs, isLibrary pkg, pkg /= rts, pkg /= libffi ]
18
19 debugged <- ghcDebugged <$> expr flavour
20
21 withNativeCodeGen <- expr ghcWithNativeCodeGen
22 withInterpreter <- expr ghcWithInterpreter
23 unregisterised <- expr $ flag GhcUnregisterised
24 withSMP <- expr ghcWithSMP
25
26 windows <- expr windowsHost
27 darwin <- expr osxHost
28
29 threads <- shakeThreads <$> expr getShakeOptions
30 verbose <- shakeVerbosity <$> expr getShakeOptions
31
32 top <- expr topDirectory
33 compiler <- getBuilderPath $ Ghc CompileHs Stage2
34 ghcPkg <- getBuilderPath $ GhcPkg Update Stage1
35 haddock <- getBuilderPath $ Haddock BuildPackage
36 hp2ps <- getBuilderPath $ Hp2Ps
37 hpc <- getBuilderPath $ Hpc
38
39 ghcFlags <- expr runTestGhcFlags
40 timeoutProg <- expr buildRoot <&> (-/- timeoutProgPath)
41
42 mconcat [ arg $ "testsuite/driver/runtests.py"
43 , arg $ "--rootdir=" ++ ("testsuite" -/- "tests")
44 , pure ["--rootdir=" ++ test | test <- libTests]
45 , arg "-e", arg $ "windows=" ++ show windows
46 , arg "-e", arg $ "darwin=" ++ show darwin
47 , arg "-e", arg $ "config.speed=2" -- Use default value in GHC's test.mk
48 , arg "-e", arg $ "config.local=True"
49 , arg "-e", arg $ "config.cleanup=False" -- Don't clean up.
50 , arg "-e", arg $ "config.compiler_debugged=" ++ quote (yesNo debugged)
51 , arg "-e", arg $ "ghc_debugged=" ++ quote (yesNo debugged)
52 , arg "-e", arg $ "ghc_with_native_codegen=" ++ zeroOne withNativeCodeGen
53
54 , arg "-e", arg $ "config.have_interp=" ++ show withInterpreter
55 , arg "-e", arg $ "config.unregisterised=" ++ show unregisterised
56
57 , arg "-e", arg $ "ghc_compiler_always_flags=" ++ quote ghcFlags
58 , arg "-e", arg $ "ghc_with_vanilla=1" -- TODO: do we always build vanilla?
59 , arg "-e", arg $ "ghc_with_dynamic=0" -- TODO: support dynamic
60 , arg "-e", arg $ "ghc_with_profiling=0" -- TODO: support profiling
61
62 , arg "-e", arg $ "config.have_vanilla=1" -- TODO: support other build context
63 , arg "-e", arg $ "config.have_dynamic=0" -- TODO: support dynamic
64 , arg "-e", arg $ "config.have_profiling=0" -- TODO: support profiling
65 , arg "-e", arg $ "ghc_with_smp=" ++ zeroOne withSMP
66 , arg "-e", arg $ "ghc_with_llvm=0" -- TODO: support LLVM
67
68 , arg "-e", arg $ "ghc_with_threaded_rts=0" -- TODO: support threaded
69 , arg "-e", arg $ "ghc_with_dynamic_rts=0" -- TODO: support dynamic
70 , arg "-e", arg $ "config.ghc_dynamic_by_default=False" -- TODO: support dynamic
71 , arg "-e", arg $ "config.ghc_dynamic=False" -- TODO: support dynamic
72
73 , arg "-e", arg $ "config.in_tree_compiler=True" -- Use default value, see https://github.com/ghc/ghc/blob/master/testsuite/mk/boilerplate.mk
74
75 , arg "--config-file=testsuite/config/ghc"
76 , arg "--config", arg $ "compiler=" ++ show (top -/- compiler)
77 , arg "--config", arg $ "ghc_pkg=" ++ show (top -/- ghcPkg)
78 , arg "--config", arg $ "haddock=" ++ show (top -/- haddock)
79 , arg "--config", arg $ "hp2ps=" ++ show (top -/- hp2ps)
80 , arg "--config", arg $ "hpc=" ++ show (top -/- hpc)
81 , arg "--config", arg $ "gs=gs" -- Use the default value as in test.mk
82 , arg "--config", arg $ "timeout_prog=" ++ show (top -/- timeoutProg)
83 , arg $ "--threads=" ++ show threads
84 , arg $ "--verbose=" ++ show (fromEnum verbose)
85 , getTestArgs -- User-provided arguments from command line.
86 ]
87
88 -- | Prepare the command-line arguments to run GHC's test script.
89 getTestArgs :: Args
90 getTestArgs = do
91 args <- expr $ userSetting defaultTestArgs
92 let testOnlyArg = case testOnly args of
93 Just cases -> map ("--only=" ++) (words cases)
94 Nothing -> []
95 skipPerfArg = if testSkipPerf args
96 then Just "--skip-perf-tests"
97 else Nothing
98 summaryArg = case testSummary args of
99 Just filepath -> Just $ "--summary-file" ++ quote filepath
100 Nothing -> Just $ "--summary-file=testsuite_summary.txt"
101 junitArg = case testJUnit args of
102 Just filepath -> Just $ "--junit " ++ quote filepath
103 Nothing -> Nothing
104 configArgs = map ("-e " ++) (testConfigs args)
105
106 pure $ testOnlyArg ++ catMaybes [skipPerfArg, summaryArg, junitArg] ++ configArgs