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