Skip to content

Commit

Permalink
Merge pull request #9228 from haskell/hkm/fix-num-jobs
Browse files Browse the repository at this point in the history
Fix use of NumJobs
  • Loading branch information
hamishmack authored Sep 5, 2023
2 parents 24a4603 + 22d7ee2 commit 19e1ee8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion Cabal-tests/tests/UnitTests/Distribution/Simple/Program/GHC.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
module UnitTests.Distribution.Simple.Program.GHC (tests) where

import qualified Data.Map as Map
import Data.Algorithm.Diff (PolyDiff (..), getDiff)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit

import Distribution.System (Platform(..), Arch(X86_64), OS(Linux))
import Distribution.Types.ParStrat
import Distribution.Simple.Flag
import Distribution.Simple.Compiler (Compiler(..), CompilerId(..), CompilerFlavor(..), AbiTag(NoAbiTag))
import Distribution.PackageDescription (emptyPackageDescription)
import Distribution.Simple.Program.GHC (normaliseGhcArgs)
import Distribution.Simple.Program.GHC (normaliseGhcArgs, renderGhcOptions, ghcOptNumJobs)
import Distribution.Version (mkVersion)

tests :: TestTree
Expand Down Expand Up @@ -38,6 +43,22 @@ tests = testGroup "Distribution.Simple.Program.GHC"

assertListEquals flags options_9_0_affects
]
, testGroup "renderGhcOptions"
[ testCase "options" $ do
let flags :: [String]
flags = renderGhcOptions
(Compiler
{ compilerId = CompilerId GHC (mkVersion [9,8,1])
, compilerAbiTag = NoAbiTag
, compilerCompat = []
, compilerLanguages = []
, compilerExtensions = []
, compilerProperties = Map.singleton "Support parallel --make" "YES"
})
(Platform X86_64 Linux)
(mempty { ghcOptNumJobs = Flag (NumJobs (Just 4)) })
assertListEquals flags ["-j4", "-clear-package-db"]
]
]

assertListEquals :: (Eq a, Show a) => [a] -> [a] -> Assertion
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Program/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ renderGhcOptions comp _platform@(Platform _arch os) opts
if jsemSupported comp
then ["-jsem " ++ name]
else []
Flag (NumJobs n) -> ["-j" ++ show n]
Flag (NumJobs n) -> ["-j" ++ maybe "" show n]
else []
, --------------------
-- Creating libraries
Expand Down

0 comments on commit 19e1ee8

Please sign in to comment.