
-- Trying a completely separate .cabal for testing.

Name:                test-atomic-primops
Version:             0.6.0.5
Build-type:          Simple
Cabal-version:       >=1.8

-- This is generally controled by the continuous integration script at a more granular level:
Flag opt
    Description: Enable GHC optimization.
    Default: False

Flag threaded
    Description: Enable GHC threaded RTS.
    Default: True

-- The MAIN test suite:
Test-Suite test-atomic-primops
    type:       exitcode-stdio-1.0
    main-is:    Test.hs
    ghc-options: -rtsopts -main-is Test.main -Wall

    if flag(opt)
       ghc-options: -O2 -funbox-strict-fields
    if flag(threaded)
       ghc-options: -threaded 
       ghc-options: -rtsopts -with-rtsopts=-N4

    -- Set it to always run with some parallelism.
    build-depends: base, ghc-prim, primitive, containers, random, atomic-primops >= 0.6.0.5,
                   -- For Testing:
                   time, HUnit, test-framework, test-framework-hunit
    -- Optional: Debugging generated code:
    --    ghc-options: -keep-tmp-files -dsuppress-module-prefixes -ddump-to-file -ddump-core-stats -ddump-simpl-stats -dcore-lint -dcmm-lint
    --    ghc-options: -ddump-ds -ddump-simpl -ddump-stg -ddump-asm -ddump-bcos -ddump-cmm -ddump-opt-cmm -ddump-inlinings

-- Cabal can get confused if there is no executable or library... so here's a dummy executable.
-- Also it provides a good test of compile/link issues, apart from everything else.
Executable hello-world-atomic-primops
  main-is: hello.hs
  build-depends: base >= 4.5, atomic-primops

-- This is separated out, because a bug in GHC 7.6 make this fail on Linux.
Test-suite template-haskell-atomic-primops
  type:       exitcode-stdio-1.0
  main-is: ghci-test.hs
  if impl(ghc >= 7.8) {
    Buildable: True
    build-depends: base >= 4.5, atomic-primops >= 0.6.0.5, template-haskell,
                   -- For Testing:
                   test-framework, test-framework-hunit
  } else {
    Buildable: False
  }

-- A very simple test of one primop included in GHC 7.8:
Test-suite raw_CAS
  type:    exitcode-stdio-1.0
  build-depends: base, ghc-prim, atomic-primops >= 0.6.0.5
-- ghc-prim, primitive, containers, random, atomic-primops >= 0.5.0.2,
  main-is: Raw781_test.hs
  if impl(ghc < 7.7) {
    Buildable: False  
  }


Test-suite Issue28
  type:    exitcode-stdio-1.0
  build-depends: base, ghc-prim, atomic-primops >= 0.6.0.5
  main-is: Issue28.hs
  ghc-options: -main-is Issue28.main
  -- if impl(ghc < 7.7) {
  --   Buildable: False  
  -- }

Benchmark atomic-primops-MicroBench
  type:    exitcode-stdio-1.0
  build-depends: base, ghc-prim, primitive, containers, random,
                 atomic-primops >= 0.6.0.5, 
                 deepseq >= 1.3, 
                 time, HUnit, test-framework, test-framework-hunit
  build-depends: criterion >= 1.0
  main-is: MicroBench.hs
