Skip to content

Commit

Permalink
Add a number of tests
Browse files Browse the repository at this point in the history
* Add test for haskell#7423

i.e. Do not warn on -O2 if under off-by-default package configuration
flag conditional.

* Add a regression for:

    * Add another -WErrr test
        This is to make sure we do *not* report it if it is under
        a user, off-by-default flag.
    * Add test for non manual user flags.
    * Add “absolute path in extra-lib-dirs” test
    * Add if/else test
    * Add “dircheck on abspath” check
    * Add Package version internal test
    * Add PackageVersionsStraddle test
  • Loading branch information
ffaf1 committed Oct 24, 2023
1 parent c2bce0f commit b37734b
Show file tree
Hide file tree
Showing 29 changed files with 239 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal check
No errors or warnings could be found in the package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Test.Cabal.Prelude

-- Do not output warning when an -O2 is behind a cabal flag.
main = cabalTest $ cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cabal-version: 2.2
name: pkg
version: 0
category: example
maintainer: none@example.com
synopsis: synopsys
description: description
license: GPL-3.0-or-later

flag force-O2
default: False
manual: True

library
exposed-modules: Foo
default-language: Haskell2010
if flag(force-O2)
ghc-options: -O2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# cabal check
Warning: These warnings may cause trouble when distributing the package:
Warning: 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit and not just imposing longer compile times on your users.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude

-- Output warning when an -O2 inside a cabal flag, but the flag is not
-- marked as `manual: True`.
main = cabalTest $ cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cabal-version: 2.2
name: pkg
version: 0
category: example
maintainer: none@example.com
synopsis: synopsys
description: description
license: GPL-3.0-or-later

flag force-O2
default: False

library
exposed-modules: Foo
default-language: Haskell2010
if flag(force-O2)
ghc-options: -O2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# cabal check
Warning: These warnings may cause trouble when distributing the package:
Warning: 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit and not just imposing longer compile times on your users.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Test.Cabal.Prelude

-- Output warning when an -O2 outside a cabal flag, along with one inside.
main = cabalTest $ cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cabal-version: 2.2
name: pkg
version: 0
category: example
maintainer: none@example.com
synopsis: synopsys
description: description
license: GPL-3.0-or-later

flag force-O2
default: False
manual: True

library
exposed-modules: Foo
default-language: Haskell2010
ghc-options: -O2
if flag(force-O2)
ghc-options: -O2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal check
No errors or warnings could be found in the package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude

-- Absolute paths can be used in `extra-lib-dirs`.
main = cabalTest $
cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cabal-version: 3.0
name: pkg
synopsis: synopsis
description: description
version: 0
category: example
maintainer: none@example.com
license: GPL-3.0-or-later

library
exposed-modules: Module
default-language: Haskell2010
extra-lib-dirs: /home/
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# cabal check
Warning: The following errors will cause portability problems on other
environments:
Warning: 'ghc-options: -j[N]' can make sense for specific user's setup, but it
is not appropriate for a distributed package. Alternatively, if you want to
use this, make it conditional based on a Cabal configuration flag (with
'manual: True' and 'default: False') and enable that flag during development.
Warning: Hackage would reject this package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude

-- `check` should not be confused by an user flag.
main = cabalTest $
fails $ cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: pkg
version: 0.0.0.1
synopsis: The Servant
description: Various capabilities
category: prelude
maintainer: smokejumperit+rfc@gmail.com
license: MIT
license-file: LICENSE
build-type: Simple
cabal-version: >= 1.10

flag production
description: Disables failing.
manual: True
default: False

library
exposed-modules:
RFC.Servant.API
ghc-options: -j
if flag(production)
ghc-options: -feager-blackholing
else
cpp-options: -DDEVELOPMENT
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal check
No errors or warnings could be found in the package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude

-- Do not complain if WError is under a user, off-by-default flag.
main = cabalTest $
cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cabal-version: 3.0
name: pkg
synopsis: synopsis
description: description
version: 0
category: example
maintainer: none@example.com
license: GPL-3.0-or-later

flag dev
description: Turn on development settings.
manual: True
default: False

library
exposed-modules: Foo
default-language: Haskell2010
if flag(dev)
ghc-options: -Werror

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# cabal check
Warning: These warnings may cause trouble when distributing the package:
Warning: These packages miss upper bounds:
- base
Please add them, using `cabal gen-bounds` for suggestions. For more
information see: https://pvp.haskell.org/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude

-- Unbounded (top) base with internal dependency: warn but do not error.
main = cabalTest $
cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cabal-version: 3.0
name: pkg
synopsis: synopsis
description: description
version: 0
category: example
maintainer: none@example.com
license: GPL-3.0-or-later

library
exposed-modules: Foo
default-language: Haskell2010
build-depends: base <= 3.10

executable test-exe
main-is: Main.hs
default-language: Haskell2010
build-depends: base, pkg

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal check
No errors or warnings could be found in the package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

-- Straddle deps declarations (build-depends: base > 5, base < 6)
-- should not error.
main = cabalTest $
cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cabal-version: 3.0
name: pkg
synopsis: synopsis
description: description
version: 0
category: example
maintainer: none@example.com
license: GPL-3.0-or-later

library
exposed-modules: Foo
default-language: Haskell2010
build-depends: base > 2,
base <= 3.10

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal check
No errors or warnings could be found in the package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude

-- Do not warn on non-existant directory if it is absolute.
main = cabalTest $
cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Name: pkg
Version: 0.1.0.0
Synopsis: Low
description: lallalala
License: LGPL-3
License-File: LICENSE
Maintainer: Maksymilian.Owsianny+AwesomiumRaw@gmail.com
Bug-Reports: https://github.com/MaxOw/awesomium-raw/issues
Category: Graphics, Web
Build-Type: Simple
Cabal-Version: >=1.8

Library
Exposed-Modules: Graphics.UI.Awesomium.Raw
Build-Depends: base >= 3 && < 5
Extra-Lib-Dirs: /usr/lib/awesomium-1.6.5

0 comments on commit b37734b

Please sign in to comment.