Merge pull request #275 from michalt/compilermode/1
[hadrian.git] / src / Rules / Test.hs
1 module Rules.Test (testRules) where
2
3 import Base
4 import Builder
5 import Expression
6 import Flavour
7 import GHC
8 import Oracles.Config.Flag
9 import Oracles.Config.Setting
10 import Oracles.WindowsPath
11 import Rules.Actions
12 import Settings
13 import Target
14
15 -- TODO: clean up after testing
16 testRules :: Rules ()
17 testRules = do
18 "validate" ~> do
19 needBuilder $ Ghc CompileHs Stage2
20 needBuilder $ GhcPkg Stage1
21 needBuilder Hpc
22 build $ Target (vanillaContext Stage2 compiler) (Make "testsuite/tests") [] []
23
24 "test" ~> do
25 let yesNo x = show $ if x then "YES" else "NO"
26 pkgs <- interpretInContext (stageContext Stage1) getPackages
27 tests <- filterM doesDirectoryExist $ concat
28 [ [ pkgPath pkg -/- "tests", pkgPath pkg -/- "tests-ghc" ]
29 | pkg <- pkgs, isLibrary pkg, pkg /= rts, pkg /= libffi ]
30 windows <- windowsHost
31 top <- topDirectory
32 compiler <- builderPath $ Ghc CompileHs Stage2
33 ghcPkg <- builderPath $ GhcPkg Stage1
34 haddock <- builderPath Haddock
35 threads <- shakeThreads <$> getShakeOptions
36 ghcWithNativeCodeGenInt <- fromEnum <$> ghcWithNativeCodeGen
37 ghcWithInterpreterInt <- fromEnum <$> ghcWithInterpreter
38 ghcUnregisterisedInt <- fromEnum <$> flag GhcUnregisterised
39 quietly . cmd "python2" $
40 [ "testsuite/driver/runtests.py" ]
41 ++ map ("--rootdir="++) tests ++
42 [ "-e", "windows=" ++ show windows
43 , "-e", "config.speed=2"
44 , "-e", "ghc_compiler_always_flags=" ++ show "-fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts"
45 , "-e", "ghc_with_native_codegen=" ++ show ghcWithNativeCodeGenInt
46 , "-e", "ghc_debugged=" ++ yesNo (ghcDebugged flavour)
47 , "-e", "ghc_with_vanilla=1" -- TODO: do we always build vanilla?
48 , "-e", "ghc_with_dynamic=0" -- TODO: support dynamic
49 , "-e", "ghc_with_profiling=0" -- TODO: support profiling
50 , "-e", "ghc_with_interpreter=" ++ show ghcWithInterpreterInt
51 , "-e", "ghc_unregisterised=" ++ show ghcUnregisterisedInt
52 , "-e", "ghc_with_threaded_rts=0" -- TODO: support threaded
53 , "-e", "ghc_with_dynamic_rts=0" -- TODO: support dynamic
54 , "-e", "ghc_dynamic_by_default=False" -- TODO: support dynamic
55 , "-e", "ghc_dynamic=0" -- TODO: support dynamic
56 , "-e", "ghc_with_llvm=0" -- TODO: support LLVM
57 , "-e", "in_tree_compiler=True" -- TODO: when is it equal to False?
58 , "-e", "clean_only=False" -- TODO: do we need to support True?
59 , "--configfile=testsuite/config/ghc"
60 , "--config", "compiler=" ++ show (top -/- compiler)
61 , "--config", "ghc_pkg=" ++ show (top -/- ghcPkg)
62 , "--config", "haddock=" ++ show (top -/- haddock)
63 , "--summary-file", "testsuite_summary.txt"
64 , "--threads=" ++ show threads
65 ]
66
67 -- , "--config", "hp2ps=" ++ quote ("hp2ps")
68 -- , "--config", "hpc=" ++ quote ("hpc")
69 -- , "--config", "gs=$(call quote_path,$(GS))"
70 -- , "--config", "timeout_prog=$(call quote_path,$(TIMEOUT_PROGRAM))"