Skip to content

Commit 8a5ab57

Browse files
committed
Add a number of tests
* 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
1 parent 399e90f commit 8a5ab57

File tree

29 files changed

+239
-0
lines changed

29 files changed

+239
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cabal check
2+
No errors or warnings could be found in the package.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Do not output warning when an -O2 is behind a cabal flag.
4+
main = cabalTest $ cabal "check" []
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cabal-version: 2.2
2+
name: pkg
3+
version: 0
4+
category: example
5+
maintainer: [email protected]
6+
synopsis: synopsys
7+
description: description
8+
license: GPL-3.0-or-later
9+
10+
flag force-O2
11+
default: False
12+
manual: True
13+
14+
library
15+
exposed-modules: Foo
16+
default-language: Haskell2010
17+
if flag(force-O2)
18+
ghc-options: -O2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# cabal check
2+
Warning: These warnings may cause trouble when distributing the package:
3+
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.
4+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Output warning when an -O2 inside a cabal flag, but the flag is not
4+
-- marked as `manual: True`.
5+
main = cabalTest $ cabal "check" []
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cabal-version: 2.2
2+
name: pkg
3+
version: 0
4+
category: example
5+
maintainer: [email protected]
6+
synopsis: synopsys
7+
description: description
8+
license: GPL-3.0-or-later
9+
10+
flag force-O2
11+
default: False
12+
13+
library
14+
exposed-modules: Foo
15+
default-language: Haskell2010
16+
if flag(force-O2)
17+
ghc-options: -O2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# cabal check
2+
Warning: These warnings may cause trouble when distributing the package:
3+
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.
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Output warning when an -O2 outside a cabal flag, along with one inside.
4+
main = cabalTest $ cabal "check" []
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cabal-version: 2.2
2+
name: pkg
3+
version: 0
4+
category: example
5+
maintainer: [email protected]
6+
synopsis: synopsys
7+
description: description
8+
license: GPL-3.0-or-later
9+
10+
flag force-O2
11+
default: False
12+
manual: True
13+
14+
library
15+
exposed-modules: Foo
16+
default-language: Haskell2010
17+
ghc-options: -O2
18+
if flag(force-O2)
19+
ghc-options: -O2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cabal check
2+
No errors or warnings could be found in the package.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Absolute paths can be used in `extra-lib-dirs`.
4+
main = cabalTest $
5+
cabal "check" []
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cabal-version: 3.0
2+
name: pkg
3+
synopsis: synopsis
4+
description: description
5+
version: 0
6+
category: example
7+
maintainer: [email protected]
8+
license: GPL-3.0-or-later
9+
10+
library
11+
exposed-modules: Module
12+
default-language: Haskell2010
13+
extra-lib-dirs: /home/

cabal-testsuite/PackageTests/Check/NonConfCheck/DevOnlyFlags/ElseCheck/LICENSE

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# cabal check
2+
Warning: The following errors will cause portability problems on other
3+
environments:
4+
Warning: 'ghc-options: -j[N]' can make sense for specific user's setup, but it
5+
is not appropriate for a distributed package. Alternatively, if you want to
6+
use this, make it conditional based on a Cabal configuration flag (with
7+
'manual: True' and 'default: False') and enable that flag during development.
8+
Warning: Hackage would reject this package.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
-- `check` should not be confused by an user flag.
4+
main = cabalTest $
5+
fails $ cabal "check" []
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: pkg
2+
version: 0.0.0.1
3+
synopsis: The Servant
4+
description: Various capabilities
5+
category: prelude
6+
maintainer: [email protected]
7+
license: MIT
8+
license-file: LICENSE
9+
build-type: Simple
10+
cabal-version: >= 1.10
11+
12+
flag production
13+
description: Disables failing.
14+
manual: True
15+
default: False
16+
17+
library
18+
exposed-modules:
19+
RFC.Servant.API
20+
ghc-options: -j
21+
if flag(production)
22+
ghc-options: -feager-blackholing
23+
else
24+
cpp-options: -DDEVELOPMENT
25+
default-language: Haskell2010
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cabal check
2+
No errors or warnings could be found in the package.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Do not complain if WError is under a user, off-by-default flag.
4+
main = cabalTest $
5+
cabal "check" []
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cabal-version: 3.0
2+
name: pkg
3+
synopsis: synopsis
4+
description: description
5+
version: 0
6+
category: example
7+
maintainer: [email protected]
8+
license: GPL-3.0-or-later
9+
10+
flag dev
11+
description: Turn on development settings.
12+
manual: True
13+
default: False
14+
15+
library
16+
exposed-modules: Foo
17+
default-language: Haskell2010
18+
if flag(dev)
19+
ghc-options: -Werror
20+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# cabal check
2+
Warning: These warnings may cause trouble when distributing the package:
3+
Warning: These packages miss upper bounds:
4+
- base
5+
Please add them, using `cabal gen-bounds` for suggestions. For more
6+
information see: https://pvp.haskell.org/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Unbounded (top) base with internal dependency: warn but do not error.
4+
main = cabalTest $
5+
cabal "check" []
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cabal-version: 3.0
2+
name: pkg
3+
synopsis: synopsis
4+
description: description
5+
version: 0
6+
category: example
7+
maintainer: [email protected]
8+
license: GPL-3.0-or-later
9+
10+
library
11+
exposed-modules: Foo
12+
default-language: Haskell2010
13+
build-depends: base <= 3.10
14+
15+
executable test-exe
16+
main-is: Main.hs
17+
default-language: Haskell2010
18+
build-depends: base, pkg
19+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cabal check
2+
No errors or warnings could be found in the package.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Straddle deps declarations (build-depends: base > 5, base < 6)
4+
-- should not error.
5+
main = cabalTest $
6+
cabal "check" []
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cabal-version: 3.0
2+
name: pkg
3+
synopsis: synopsis
4+
description: description
5+
version: 0
6+
category: example
7+
maintainer: [email protected]
8+
license: GPL-3.0-or-later
9+
10+
library
11+
exposed-modules: Foo
12+
default-language: Haskell2010
13+
build-depends: base > 2,
14+
base <= 3.10
15+

cabal-testsuite/PackageTests/Check/PackageFiles/DirExistAbs/LICENSE

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cabal check
2+
No errors or warnings could be found in the package.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Do not warn on non-existant directory if it is absolute.
4+
main = cabalTest $
5+
cabal "check" []
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Name: pkg
2+
Version: 0.1.0.0
3+
Synopsis: Low
4+
description: lallalala
5+
License: LGPL-3
6+
License-File: LICENSE
7+
Maintainer: [email protected]
8+
Bug-Reports: https://github.com/MaxOw/awesomium-raw/issues
9+
Category: Graphics, Web
10+
Build-Type: Simple
11+
Cabal-Version: >=1.8
12+
13+
Library
14+
Exposed-Modules: Graphics.UI.Awesomium.Raw
15+
Build-Depends: base >= 3 && < 5
16+
Extra-Lib-Dirs: /usr/lib/awesomium-1.6.5
17+

0 commit comments

Comments
 (0)