1 module UnitTests
.Distribution
.Simple
.Program
.GHC
(tests
) where
3 import qualified Data
.Map
as Map
4 import Data
.Algorithm
.Diff
(PolyDiff
(..), getDiff
)
5 import Test
.Tasty
(TestTree
, testGroup
)
6 import Test
.Tasty
.HUnit
8 import Distribution
.System
(Platform
(..), Arch
(X86_64
), OS
(Linux
))
9 import Distribution
.Types
.ParStrat
10 import Distribution
.Simple
.Flag
11 import Distribution
.Simple
.Compiler
(Compiler
(..), CompilerId
(..), CompilerFlavor
(..), AbiTag
(NoAbiTag
))
12 import Distribution
.PackageDescription
(emptyPackageDescription
)
13 import Distribution
.Simple
.Program
.GHC
(normaliseGhcArgs
, renderGhcOptions
, ghcOptNumJobs
)
14 import Distribution
.Version
(mkVersion
)
17 tests
= testGroup
"Distribution.Simple.Program.GHC"
18 [ testGroup
"normaliseGhcArgs"
19 [ testCase
"options added in GHC-8.8" $ do
21 flags
= normaliseGhcArgs
22 (Just
$ mkVersion
[8,8,1])
23 emptyPackageDescription
26 assertListEquals flags options_8_8_affects
28 , testCase
"options added in GHC-8.10" $ do
30 flags
= normaliseGhcArgs
31 (Just
$ mkVersion
[8,10,1])
32 emptyPackageDescription
35 assertListEquals flags options_8_10_affects
37 , testCase
"options added in GHC-9.0" $ do
39 flags
= normaliseGhcArgs
40 (Just
$ mkVersion
[9,0,1])
41 emptyPackageDescription
44 assertListEquals flags options_9_0_affects
46 , testGroup
"renderGhcOptions"
47 [ testCase
"options" $ do
49 flags
= renderGhcOptions
51 { compilerId
= CompilerId GHC
(mkVersion
[9,8,1])
52 , compilerAbiTag
= NoAbiTag
54 , compilerLanguages
= []
55 , compilerExtensions
= []
56 , compilerProperties
= Map
.singleton
"Support parallel --make" "YES"
58 (Platform X86_64 Linux
)
59 (mempty
{ ghcOptNumJobs
= Flag
(NumJobs
(Just
4)) })
60 assertListEquals flags
["-j4", "-clear-package-db"]
64 assertListEquals
:: (Eq a
, Show a
) => [a
] -> [a
] -> Assertion
65 assertListEquals xs ys
66 | xs
== ys
= return ()
67 |
otherwise = assertFailure
$ unlines $
68 "Lists are not equal" :
70 First x
-> "- " ++ show x
71 Second y
-> "+ " ++ show y
72 Both x _
-> " " ++ show x
76 -------------------------------------------------------------------------------
78 -------------------------------------------------------------------------------
80 -- | Options added in GHC-8.8, to generate:
83 -- ghc-8.6.5 --show-options | sort > 8.6.5.txt
84 -- ghc-8.8.1 --show-options | sort > 8.8.1.txt
85 -- diff -u 8.6.5 8.8.1
88 -- - remove -W(no-)error=, -W(no-)warn flags.
89 -- - split into all and flags which may affect artifacts
90 options_8_8_all
:: [String]
92 [ "-ddump-cfg-weights"
93 , "-dno-suppress-stg-exts"
94 , "-dsuppress-stg-exts"
95 , "-Wmissed-extra-shared-lib"
96 , "-Wmissing-deriving-strategies"
97 , "-Wmissing-space-after-bang"
98 , "-Wno-missed-extra-shared-lib"
99 , "-Wno-missing-deriving-strategies"
100 , "-Wno-missing-space-after-bang"
101 , "-fno-show-docs-of-hole-fits"
102 , "-fshow-docs-of-hole-fits"
103 ] ++ options_8_8_affects
105 options_8_8_affects
:: [String]
106 options_8_8_affects
=
107 [ "-fblock-layout-cfg"
108 , "-fblock-layout-weightless"
109 , "-fblock-layout-weights"
112 , "-fno-block-layout-cfg"
113 , "-fno-block-layout-weightless"
115 , "-fno-safe-haskell"
116 , "-fno-stg-lift-lams"
117 , "-fno-stg-lift-lams-known"
118 , "-fno-validate-ide-info"
119 , "-fno-write-ide-info"
121 , "-fstg-lift-lams-known"
122 , "-fstg-lift-lams-non-rec-args"
123 , "-fstg-lift-lams-non-rec-args-any"
124 , "-fstg-lift-lams-rec-args"
125 , "-fstg-lift-lams-rec-args-any"
126 , "-fvalidate-ide-info"
131 , "-keep-hscpp-files"
134 -------------------------------------------------------------------------------
136 -------------------------------------------------------------------------------
138 options_8_10_all
:: [String]
140 [ "-ddump-cmm-verbose-by-proc"
142 , "-ddump-stg-unarised"
143 , "-Wderiving-defaults"
144 , "-Winferred-safe-imports"
145 , "-Wmissing-safe-haskell-mode"
146 , "-Wno-deriving-defaults"
147 , "-Wno-inferred-safe-imports"
148 , "-Wno-missing-safe-haskell-mode"
149 , "-Wno-prepositive-qualified-module"
150 , "-Wno-redundant-record-wildcards"
151 , "-Wno-unused-packages"
152 , "-Wno-unused-record-wildcards"
153 , "-Wprepositive-qualified-module"
154 , "-Wredundant-record-wildcards"
155 , "-Wunused-packages"
156 , "-Wunused-record-wildcards"
157 , "-fdefer-diagnostics"
159 , "-fprint-axiom-incomps"
160 , "-fno-defer-diagnostics"
162 , "-fno-print-axiom-incomps"
163 ] ++ options_8_10_affects
165 options_8_10_affects
:: [String]
166 options_8_10_affects
=
167 [ "-dno-typeable-binds"
168 , "-fbinary-blob-threshold"
169 , "-fmax-pmcheck-models"
170 , "-fplugin-trustworthy"
171 , "-include-cpp-deps"
175 -------------------------------------------------------------------------------
177 -------------------------------------------------------------------------------
179 options_9_0_all
:: [String]
183 , "-ddump-cpr-signatures"
185 -- NOTE: we filter out -dlinear-core-lint
186 -- we filter, -dcore-lint, -dstg-lint etc.
187 , "-dlinear-core-lint"
188 ] ++ options_9_0_affects
190 options_9_0_affects
:: [String]
191 options_9_0_affects
=
192 [ "-fcmm-static-pred"