Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for --omit-tests and --omit-benchmarks #593

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cabal2nix/src/Cabal2nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ import Text.PrettyPrint.HughesPJClass ( Doc, Pretty(..), text, vcat, hcat, semi,

{-# ANN module ("HLint: ignore Use Just" :: String) #-}

data IncludeTests = IncludeTests | OmitTests
deriving (Eq, Show)

data IncludeBenchmarks = IncludeBenchmarks | OmitBenchmarks
deriving (Eq, Show)

data Options = Options
{ optSha256 :: Maybe String
, optMaintainer :: [String]
Expand All @@ -67,6 +73,8 @@ data Options = Options
, optNixpkgsIdentifier :: NixpkgsResolver
, optUrl :: String
, optFetchSubmodules :: FetchSubmodules
, optOmitTests :: IncludeTests
, optOmitBenchmarks :: IncludeBenchmarks
}

options :: Parser Options
Expand Down Expand Up @@ -125,6 +133,10 @@ options = do
<- strArgument (metavar "URI")
optFetchSubmodules
<- flag FetchSubmodules DontFetchSubmodules (long "dont-fetch-submodules" <> help "do not fetch git submodules from git sources")
optOmitTests
<- flag IncludeTests OmitTests (long "omit-tests" <> help "do not include test suites in the expression")
optOmitBenchmarks
<- flag IncludeBenchmarks OmitBenchmarks (long "omit-benchmarks" <> help "do not include benchmarks in the expression")
pure Options{..}

-- | A parser for the date. Hackage updates happen maybe once or twice a month.
Expand Down Expand Up @@ -230,6 +242,12 @@ processPackage Options{..} pkg = do
& doCheck &&~ optDoCheck
& doBenchmark ||~ optDoBenchmark
& extraFunctionArgs %~ Set.union (Set.fromList ("inherit lib":map (fromString . ("inherit " ++)) optExtraArgs))
& testDepends %~ (\x -> case optOmitTests of
IncludeTests -> x
OmitTests -> mempty)
& benchmarkDepends %~ (\x -> case optOmitBenchmarks of
IncludeBenchmarks -> x
OmitBenchmarks -> mempty)

shell :: Doc
shell = vcat
Expand Down