packages feed

streamly-0.9.0: 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
    default-language: Haskell2010

    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-extensions:
        BangPatterns
        CApiFFI
        CPP
        ConstraintKinds
        DeriveDataTypeable
        DeriveGeneric
        DeriveTraversable
        ExistentialQuantification
        FlexibleContexts
        FlexibleInstances
        GeneralizedNewtypeDeriving
        InstanceSigs
        KindSignatures
        LambdaCase
        MagicHash
        MultiParamTypeClasses
        PatternSynonyms
        RankNTypes
        RecordWildCards
        ScopedTypeVariables
        TupleSections
        TypeFamilies
        ViewPatterns

        -- MonoLocalBinds, enabled by TypeFamilies, causes performance
        -- regressions. Disable it. This must come after TypeFamilies,
        -- otherwise TypeFamilies will enable it again.
        NoMonoLocalBinds

        -- UndecidableInstances -- Does not show any perf impact
        -- UnboxedTuples        -- interferes with (#.)

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.18
      , containers        >= 0.5   && < 0.7
      , exceptions        >= 0.8   && < 0.11
      , ghc
      , hspec             >= 2.0   && < 2.10
      , mtl               >= 2.2   && < 2.3
      , random            >= 1.0.0 && < 1.3
      , transformers      >= 0.4   && < 0.7
      , QuickCheck        >= 2.13  && < 2.15
      , directory         >= 1.2.2 && < 1.4
      , filepath          >= 1.4.1 && < 1.5
      , temporary         >= 1.3   && < 1.4
      , network           >= 3.1   && < 3.2

  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
    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 -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
               -fno-ignore-asserts
  if flag(fusion-plugin) && !impl(ghcjs) && !impl(ghc < 8.6)
    ghc-options: -fplugin Fusion.Plugin

-------------------------------------------------------------------------------
-- Test suites in sorted order
-------------------------------------------------------------------------------

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.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
  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.Mut
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Array/Mut.hs
  ghc-options: -main-is Streamly.Test.Data.Array.Mut.main

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

test-suite Data.Unbox
  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.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.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

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

test-suite Data.Parser.ParserD
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Data/Parser/ParserD.hs
  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.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 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)
    buildable: False
  if 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 !os(linux)
    buildable: False
  if 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)
    buildable: False
  if 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 Network.Inet.TCP
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Network/Inet/TCP.hs
  if flag(use-streamly-core)
    buildable: False
  -- XXX on Windows these test cases are hanging for ever
  -- need to be investigated.
  -- https://github.com/composewell/streamly/issues/2315
  if os(windows)
    buildable: False

test-suite Network.Socket
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Network/Socket.hs
  if flag(use-streamly-core)
    buildable: False
  -- XXX on Windows these test cases are hanging for ever
  -- need to be investigated.
  -- https://github.com/composewell/streamly/issues/2315
  if os(windows)
    buildable: False

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 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 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

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 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 Serialize.Serializable
  import: test-options
  type: exitcode-stdio-1.0
  main-is: Streamly/Test/Serialize/Serializable.hs

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