Skip to content

Commit 53fd56a

Browse files
committed
cabal: Add test for new empty library support
1 parent ad4a1db commit 53fd56a

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
load("@rules_haskell//haskell:cabal.bzl",
3+
"haskell_cabal_args",
4+
"haskell_cabal_library",
5+
)
6+
load(
7+
"@rules_haskell//haskell:defs.bzl",
8+
"haskell_test",
9+
"haskell_toolchain_library",
10+
)
11+
12+
haskell_toolchain_library(name = "base")
13+
14+
haskell_cabal_library(
15+
name = "first-lib",
16+
package_name = "lib",
17+
srcs = [
18+
"Lib.hs",
19+
"lib.cabal",
20+
],
21+
cabalopts = [
22+
"--ghc-option=-DONE=1",
23+
"--haddock-option=--optghc=-DONE=1",
24+
],
25+
tags = [
26+
# Windows builds are not sandboxed, so both cabal files are visible to
27+
# the build action and it fails with:
28+
#
29+
# Setup.hs: Multiple cabal files found.
30+
# Please use only one of: .\second-lib.cabal, .\lib.cabal
31+
"dont_test_on_windows",
32+
],
33+
version = "0.1.0.0",
34+
)
35+
36+
haskell_cabal_args(
37+
name = "second-lib-cabal-args",
38+
is_empty = True,
39+
)
40+
41+
haskell_cabal_library(
42+
name = "second-lib",
43+
srcs = [
44+
"second-lib.cabal",
45+
],
46+
deps = [
47+
":base",
48+
":first-lib",
49+
],
50+
cabal_args = "second-lib-cabal-args",
51+
tags = [
52+
# Windows builds are not sandboxed, so both cabal files are visible to
53+
# the build action and it fails with:
54+
#
55+
# Setup.hs: Multiple cabal files found.
56+
# Please use only one of: .\second-lib.cabal, .\lib.cabal
57+
"dont_test_on_windows",
58+
],
59+
version = "0.1.0.0",
60+
)
61+
62+
haskell_test(
63+
name = "haskell_cabal_empty_library",
64+
srcs = ["Main.hs"],
65+
tags = [
66+
"dont_test_on_windows",
67+
],
68+
deps = [
69+
":base",
70+
":second-lib",
71+
],
72+
)
73+
74+
filegroup(
75+
name = "all_files",
76+
testonly = True,
77+
srcs = glob(["**"]),
78+
visibility = ["//visibility:public"],
79+
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Lib where
2+
3+
x :: Int
4+
x = 2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Main where
2+
3+
import Lib
4+
5+
main = print Lib.x
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cabal-version: >=1.10
2+
name: lib
3+
version: 0.1.0.0
4+
build-type: Simple
5+
6+
library
7+
build-depends: base
8+
default-language: Haskell2010
9+
exposed-modules: Lib
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cabal-version: >=1.10
2+
name: second-lib
3+
version: 0.1.0.0
4+
build-type: Simple
5+
6+
library
7+
build-depends: base, lib
8+
default-language: Haskell2010
9+
reexported-modules: Lib

0 commit comments

Comments
 (0)