packages feed

streamly-0.11.1: test/streamly-tests.cabal

cabal-version:      2.2
name:               streamly-tests
version:            0.0.0
synopsis:           Tests for streamly
description: See streamly-benchmarks for the reason why we use a separate
 package for tests.

flag fusion-plugin
  description: Use fusion plugin for benchmarks and executables
  manual: True
  default: False

flag limit-build-mem
  description: Limits memory when building the executables
  manual: True
  default: False

flag use-large-mem
  description: Include tests that require large amount of memory
  manual: True
  default: False

flag include-flaky-tests
  description: Include tests that are unpredictable
  manual: True
  default: False

flag dev
  description: Development build
  manual: True
  default: False

flag has-llvm
  description: Use llvm backend for better performance
  manual: True
  default: False

flag opt
  description: off=-O0 (faster builds), on=-O2
  manual: True
  default: True

flag use-streamly-core
  description: Test only core package
  manual: True
  default: False

-------------------------------------------------------------------------------
-- Common stanzas
-------------------------------------------------------------------------------

common compile-options
    if os(darwin)
      cpp-options:    -DCABAL_OS_DARWIN

    if os(linux)
      cpp-options:    -DCABAL_OS_LINUX

    if os(windows)
      cpp-options:    -DCABAL_OS_WINDOWS

    if flag(dev)
      cpp-options:    -DDEVBUILD

    ghc-options:      -Wall
                      -Wcompat
                      -Wunrecognised-warning-flags
                      -Widentities
                      -Wincomplete-record-updates
                      -Wincomplete-uni-patterns
                      -Wredundant-constraints
                      -Wnoncanonical-monad-instances
                      -Wmissing-export-lists
                      -Rghc-timing

    if flag(has-llvm)
      ghc-options: -fllvm

    if flag(dev)
      ghc-options:    -Wmissed-specialisations
                      -Wall-missed-specialisations

    if flag(limit-build-mem)
      ghc-options: +RTS -M512M -RTS

    if flag(use-large-mem)
      cpp-options: -DUSE_LARGE_MEMORY

    if flag(include-flaky-tests)
      cpp-options: -DINCLUDE_FLAKY_TESTS

common default-extensions
    default-language: Haskell2010

    -- GHC2024 may include more extensions than we are actually using, see the
    -- full list below. We enable this to ensure that we are able to compile
    -- with this i.e. there is no interference by other extensions.
    if impl(ghc >= 9.10)
      default-language: GHC2024

    if impl(ghc >= 9.2) && impl(ghc < 9.10)
      default-language: GHC2021

    if impl(ghc >= 8.10)
      default-extensions: StandaloneKindSignatures

    -- In GHC 2024
    default-extensions:
        BangPatterns
        ConstraintKinds
        DeriveDataTypeable
        DeriveGeneric
        DeriveTraversable
        ExistentialQuantification
        FlexibleContexts
        FlexibleInstances
        GeneralizedNewtypeDeriving
        InstanceSigs
        KindSignatures
        LambdaCase
        MultiParamTypeClasses
        RankNTypes
        ScopedTypeVariables
        TupleSections

        -- Not in GHC2024
        CPP
        MagicHash
        PatternSynonyms
        RecordWildCards
        NoMonoLocalBinds

common threading-options
  ghc-options:  -threaded
                -with-rtsopts=-N

common optimization-options
  if flag(opt) || flag(fusion-plugin)
    ghc-options: -O2
                 -fdicts-strict
                 -fmax-worker-args=16
                 -fspec-constr-recursive=16
                 -- This must come after -O2
                 -fno-ignore-asserts
    if flag(fusion-plugin) && !impl(ghcjs) && !impl(ghc < 8.6)
      ghc-options: -fplugin Fusion.Plugin
  else
    ghc-options: -O0

common test-dependencies
  build-depends:
        streamly-core
      , base              >= 4.9   && < 4.23
      , containers        >= 0.5   && < 0.9
      , exceptions        >= 0.8   && < 0.11
      , ghc
      , hspec             >= 2.0   && < 2.12
      , mtl               >= 2.2   && < 2.4
      , random            >= 1.0.0 && < 1.4
      , transformers      >= 0.4   && < 0.7
      , QuickCheck        >= 2.13  && < 2.19
      , directory         >= 1.2.2 && < 1.5
      , filepath          >= 1.4.1 && < 1.6
      , temporary         >= 1.3   && < 1.4
      , network           >= 3.1   && < 3.3
      , scientific        >= 0.0   && < 0.4
      , template-haskell  >= 2.12  && < 2.25

  if !flag(use-streamly-core)
    build-depends: streamly

  if flag(fusion-plugin) && !impl(ghcjs) && !impl(ghc < 8.6)
     build-depends:
         fusion-plugin     >= 0.2   && < 0.3

-------------------------------------------------------------------------------
-- Library
-------------------------------------------------------------------------------

common lib-options
  import: compile-options
        , optimization-options
        , default-extensions
        , test-dependencies

library
    import: lib-options, test-dependencies
    hs-source-dirs: lib
    exposed-modules:
        Streamly.Test.Common
        Streamly.Test.Parser.Common
    if !flag(use-streamly-core)
      exposed-modules: Streamly.Test.Prelude.Common
    if flag(limit-build-mem)
      ghc-options: +RTS -M1500M -RTS

-------------------------------------------------------------------------------
-- Test suite options
-------------------------------------------------------------------------------

common test-options
  import: lib-options
        , threading-options
  ghc-options:
    -rtsopts
    -with-rtsopts "-t"
    -fno-ignore-asserts
  include-dirs: .
  build-depends: streamly-tests

common always-optimized
  import: compile-options
        , threading-options
        , default-extensions
        , test-dependencies
  ghc-options: -O2
               -fdicts-strict
               -fmax-worker-args=16
               -fspec-constr-recursive=16
               -rtsopts
               -with-rtsopts "-t"
               -fno-ignore-asserts
  if flag(fusion-plugin) && !impl(ghcjs) && !impl(ghc < 8.6)
    ghc-options: -fplugin Fusion.Plugin

-------------------------------------------------------------------------------
-- Test suites in alphabetical order
-------------------------------------------------------------------------------

test-suite Data.Array
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Array.hs
  ghc-options: -main-is Streamly.Test.Data.Array.main

test-suite Data.Array.Generic
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Array/Generic.hs
  ghc-options: -main-is Streamly.Test.Data.Array.Generic.main
  if flag(use-streamly-core)
    buildable: False

test-suite Data.Array.Stream
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Array/Stream.hs
  if flag(use-streamly-core)
    buildable: False

test-suite Data.Binary
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Serialize/Serializable.hs

test-suite Data.Fold
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Fold.hs

test-suite Data.Fold.Window
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Fold/Window.hs
  ghc-options: -main-is Streamly.Test.Data.Fold.Window.main

-- The Streamly.Data.List needs to be fixed to enable this
-- test-suite Data.List
--   import: test-options
--   type: exitcode-stdio-1.0
--   main-is: Streamly/Test/Data/List.hs
--   cpp-options:  -DUSE_STREAMLY_LIST
--   if !flag(dev)
--     buildable: False

test-suite Data.List.Base
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/List.hs

test-suite Data.MutArray
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/MutArray.hs
  ghc-options: -main-is Streamly.Test.Data.MutArray.main

test-suite Data.Parser
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Parser.hs
  hs-source-dirs: .
  other-modules: Streamly.Test.Data.Parser.Common
  if flag(limit-build-mem)
    ghc-options: +RTS -M2000M -RTS

test-suite Data.ParserK
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/ParserK.hs
  if flag(limit-build-mem)
    ghc-options: +RTS -M1500M -RTS

test-suite Data.RingArray
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/RingArray.hs
  ghc-options: -main-is Streamly.Test.Data.RingArray.main

test-suite Data.Scanl.Concurrent
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Scanl/Concurrent.hs
  ghc-options: -main-is Streamly.Test.Data.Scanl.Concurrent.main
  if flag(use-streamly-core)
    buildable: False

-- XXX Rename to MutByteArray
test-suite Data.Serialize
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Serialize.hs
  other-modules:
      Streamly.Test.Data.Serialize.TH
      Streamly.Test.Data.Serialize.CompatV0
      Streamly.Test.Data.Serialize.CompatV1
  ghc-options: -main-is Streamly.Test.Data.Serialize.main
  if flag(limit-build-mem)
    ghc-options: +RTS -M1500M -RTS

test-suite Data.Serialize.Derive.TH
  import: test-options
  type: exitcode-stdio-1.0
  cpp-options: -DUSE_SERIALIZE
  main-is: Streamly/Test/Data/Unbox.hs
  ghc-options: -main-is Streamly.Test.Data.Unbox.main

test-suite Data.Serialize.ENABLE_constructorTagAsString
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Serialize.hs
  other-modules:
      Streamly.Test.Data.Serialize.TH
      Streamly.Test.Data.Serialize.CompatV0
      Streamly.Test.Data.Serialize.CompatV1
  cpp-options: -DENABLE_constructorTagAsString
  ghc-options: -main-is Streamly.Test.Data.Serialize.main
  if flag(limit-build-mem)
    ghc-options: +RTS -M1500M -RTS

test-suite Data.SmallArray
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/SmallArray.hs
  ghc-options: -main-is Streamly.Test.Data.SmallArray.main
  if !flag(dev) || flag(use-streamly-core)
    buildable: False

test-suite Data.Stream
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Stream.hs
  ghc-options: -main-is Streamly.Test.Data.Stream.main
  if flag(limit-build-mem)
    ghc-options: +RTS -M1500M -RTS

test-suite Data.Stream.Concurrent
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Stream/Concurrent.hs
  ghc-options: -main-is Streamly.Test.Data.Stream.Concurrent.main
  if flag(use-streamly-core)
    buildable: False

test-suite Data.Stream.Exception
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Stream/Exception.hs
  ghc-options: -main-is Streamly.Test.Data.Stream.Exception.main

test-suite Data.Stream.Time
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Stream/Time.hs
  ghc-options: -main-is Streamly.Test.Data.Stream.Time.main
  if flag(use-streamly-core)
    buildable: False

test-suite Data.Stream.Rate
  import:always-optimized
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Stream/Rate.hs
  ghc-options: -main-is Streamly.Test.Data.Stream.Rate.main
  if flag(dev)
    buildable: True
  else
    buildable: False
  if flag(use-streamly-core)
    buildable: False

-- XXX Rename to MutByteArray.Unbox
test-suite Data.Unbox.Derive.Generic
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Unbox.hs
  ghc-options: -main-is Streamly.Test.Data.Unbox.main

test-suite Data.Unbox.Derive.TH
  import: test-options
  type: exitcode-stdio-1.0
  cpp-options: -DUSE_TH
  main-is: Streamly/Test/Data/Unbox.hs
  ghc-options: -main-is Streamly.Test.Data.Unbox.main

test-suite Data.Unbox.TH
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Unbox/TH.hs
  ghc-options: -main-is Streamly.Test.Data.Unbox.TH.main

test-suite Data.Unfold
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Unfold.hs

test-suite FileSystem.Event
  import: test-options
  type: exitcode-stdio-1.0
  ghc-options: -main-is Streamly.Test.FileSystem.Event
  main-is: Streamly/Test/FileSystem/Event.hs
  other-modules: Streamly.Test.FileSystem.Event.Common
  if !((os(linux) && impl(ghc >= 9.4)) || os(darwin) || os(windows)) || flag(use-streamly-core)
    buildable: False

test-suite FileSystem.Event.Darwin
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/FileSystem/Event/Darwin.hs
  other-modules: Streamly.Test.FileSystem.Event.Common
  cpp-options: -DFILESYSTEM_EVENT_DARWIN
  ghc-options: -main-is Streamly.Test.FileSystem.Event.Darwin
  if !os(darwin) || flag(use-streamly-core)
    buildable: False

test-suite FileSystem.Event.Linux
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/FileSystem/Event/Linux.hs
  other-modules: Streamly.Test.FileSystem.Event.Common
  cpp-options: -DFILESYSTEM_EVENT_LINUX
  ghc-options: -main-is Streamly.Test.FileSystem.Event.Linux
  if impl(ghc < 9.4) || !os(linux) || flag(use-streamly-core)
    buildable: False

test-suite FileSystem.Event.Windows
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/FileSystem/Event/Windows.hs
  other-modules: Streamly.Test.FileSystem.Event.Common
  cpp-options: -DFILESYSTEM_EVENT_WINDOWS
  ghc-options: -main-is Streamly.Test.FileSystem.Event.Windows
  if !os(windows) || flag(use-streamly-core)
    buildable: False

test-suite FileSystem.Handle
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/FileSystem/Handle.hs
  ghc-options: -main-is Streamly.Test.FileSystem.Handle.main
  if flag(use-streamly-core)
    buildable: False

test-suite FileSystem.DirIO
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/FileSystem/DirIO.hs
  if flag(use-streamly-core)
    buildable: False
  build-depends:
      bench-test-lib
  -- Fix this test-suite for Windows
  if os(windows)
    buildable: False

test-suite Network.Inet.TCP
  import: lib-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Network/Inet/TCP.hs
  ghc-options: -rtsopts -fno-ignore-asserts
  include-dirs: .
  build-depends: streamly-tests
  -- Cannot killThread in listen/accept on Windows threaded runtime
  if !os(windows)
    ghc-options: -threaded -with-rtsopts=-N
  if flag(use-streamly-core)
    buildable: False

test-suite Network.Socket
  import: lib-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Network/Socket.hs
  ghc-options: -rtsopts -fno-ignore-asserts
  include-dirs: .
  build-depends: streamly-tests
  -- Cannot killThread in listen/accept on Windows threaded runtime
  if !os(windows)
    ghc-options: -threaded -with-rtsopts=-N
  if flag(use-streamly-core)
    buildable: False

test-suite Unicode.Char
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Unicode/Char.hs
  ghc-options: -main-is Streamly.Test.Unicode.Char.main
  if flag(use-streamly-core) || !flag(dev)
    buildable: False

test-suite Unicode.Parser
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Unicode/Parser.hs
  ghc-options: -main-is Streamly.Test.Unicode.Parser.main
  if flag(use-streamly-core)
    buildable: False

test-suite Unicode.Stream
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Unicode/Stream.hs
  ghc-options: -main-is Streamly.Test.Unicode.Stream.main
  if flag(use-streamly-core)
    buildable: False

test-suite version-bounds
  import: test-options
  type: exitcode-stdio-1.0
  main-is: version-bounds.hs

-------------------------------------------------------------------------------
-- Deprecated
-------------------------------------------------------------------------------

test-suite Prelude
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude.hs
  ghc-options: -main-is Streamly.Test.Prelude.main
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.Ahead
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/Ahead.hs
  ghc-options: -main-is Streamly.Test.Prelude.Ahead.main
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.Async
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/Async.hs
  ghc-options: -main-is Streamly.Test.Prelude.Async.main
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.Concurrent
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/Concurrent.hs
  ghc-options: -main-is Streamly.Test.Prelude.Concurrent.main
  if flag(limit-build-mem)
    ghc-options: +RTS -M2000M -RTS
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.Fold
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/Fold.hs
  ghc-options: -main-is Streamly.Test.Prelude.Fold.main
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.Parallel
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/Parallel.hs
  ghc-options: -main-is Streamly.Test.Prelude.Parallel.main
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.Rate
  import:always-optimized
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/Rate.hs
  ghc-options: -main-is Streamly.Test.Prelude.Rate.main
  if flag(dev)
    buildable: True
  else
    buildable: False
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.Serial
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/Serial.hs
  ghc-options: -main-is Streamly.Test.Prelude.Serial.main
  if flag(limit-build-mem)
    ghc-options: +RTS -M1500M -RTS
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.Top
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/Top.hs
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.WAsync
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/WAsync.hs
  ghc-options: -main-is Streamly.Test.Prelude.WAsync.main
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.WSerial
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/WSerial.hs
  ghc-options: -main-is Streamly.Test.Prelude.WSerial.main
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.ZipAsync
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/ZipAsync.hs
  ghc-options: -main-is Streamly.Test.Prelude.ZipAsync.main
  if flag(limit-build-mem)
    ghc-options: +RTS -M750M -RTS
  if flag(use-streamly-core)
    buildable: False

test-suite Prelude.ZipSerial
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Prelude/ZipSerial.hs
  ghc-options: -main-is Streamly.Test.Prelude.ZipSerial.main
  if flag(use-streamly-core)
    buildable: False