Factor out general functionality of path oracles to the library
[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 Settings
11 import Settings.Path
12 import Target
13 import Util
14
15 -- TODO: clean up after testing
16 testRules :: Rules ()
17 testRules = do
18 "validate" ~> do
19 need inplaceLibCopyTargets
20 needBuilder $ Ghc CompileHs Stage2
21 needBuilder $ GhcPkg Update Stage1
22 needBuilder Hpc
23 need ["inplace/bin/hp2ps", "inplace/bin/hsc2hs"]
24 -- TODO: Eliminate explicit filepaths in "need" (#376)
25 -- FIXME: needBuilder Hsc2Hs doesn't work
26 build $ target (vanillaContext Stage2 compiler) (Make "testsuite/tests") [] []
27
28 "test" ~> do
29 let yesNo x = show $ if x then "YES" else "NO"
30 pkgs <- stagePackages Stage1
31 tests <- filterM doesDirectoryExist $ concat
32 [ [ pkgPath pkg -/- "tests", pkgPath pkg -/- "tests-ghc" ]
33 | pkg <- pkgs, isLibrary pkg, pkg /= rts, pkg /= libffi ]
34 windows <- windowsHost
35 top <- topDirectory
36 compiler <- builderPath $ Ghc CompileHs Stage2
37 ghcPkg <- builderPath $ GhcPkg Update Stage1
38 haddock <- builderPath Haddock
39 threads <- shakeThreads <$> getShakeOptions
40 ghcWithNativeCodeGenInt <- fromEnum <$> ghcWithNativeCodeGen
41 ghcWithInterpreterInt <- fromEnum <$> ghcWithInterpreter
42 ghcUnregisterisedInt <- fromEnum <$> flag GhcUnregisterised
43 quietly . cmd "python2" $
44 [ "testsuite/driver/runtests.py" ]
45 ++ map ("--rootdir="++) tests ++
46 [ "-e", "windows=" ++ show windows
47 , "-e", "config.speed=2"
48 , "-e", "ghc_compiler_always_flags=" ++ show "-fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts"
49 , "-e", "ghc_with_native_codegen=" ++ show ghcWithNativeCodeGenInt
50 , "-e", "ghc_debugged=" ++ yesNo (ghcDebugged flavour)
51 , "-e", "ghc_with_vanilla=1" -- TODO: do we always build vanilla?
52 , "-e", "ghc_with_dynamic=0" -- TODO: support dynamic
53 , "-e", "ghc_with_profiling=0" -- TODO: support profiling
54 , "-e", "ghc_with_interpreter=" ++ show ghcWithInterpreterInt
55 , "-e", "ghc_unregisterised=" ++ show ghcUnregisterisedInt
56 , "-e", "ghc_with_threaded_rts=0" -- TODO: support threaded
57 , "-e", "ghc_with_dynamic_rts=0" -- TODO: support dynamic
58 , "-e", "ghc_dynamic_by_default=False" -- TODO: support dynamic
59 , "-e", "ghc_dynamic=0" -- TODO: support dynamic
60 , "-e", "ghc_with_llvm=0" -- TODO: support LLVM
61 , "-e", "in_tree_compiler=True" -- TODO: when is it equal to False?
62 , "-e", "clean_only=False" -- TODO: do we need to support True?
63 , "--configfile=testsuite/config/ghc"
64 , "--config", "compiler=" ++ show (top -/- compiler)
65 , "--config", "ghc_pkg=" ++ show (top -/- ghcPkg)
66 , "--config", "haddock=" ++ show (top -/- haddock)
67 , "--summary-file", "testsuite_summary.txt"
68 , "--threads=" ++ show threads
69 ]
70
71 -- , "--config", "hp2ps=" ++ quote ("hp2ps")
72 -- , "--config", "hpc=" ++ quote ("hpc")
73 -- , "--config", "gs=$(call quote_path,$(GS))"
74 -- , "--config", "timeout_prog=$(call quote_path,$(TIMEOUT_PROGRAM))"