Skip to content

Commit 6cc9c63

Browse files
authored
Merge pull request #11457 from cabalism/test/autogen-modules-main-is
Add tests for autogen-modules as main-is
2 parents 0e7d82b + 11686ad commit 6cc9c63

File tree

21 files changed

+193
-0
lines changed

21 files changed

+193
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LICENSE
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cabal-version: 3.12
2+
name: MainIsBench
3+
version: 0.1
4+
license: BSD-3-Clause
5+
license-file: LICENSE
6+
author: Federico Mastellone
7+
maintainer: Federico Mastellone
8+
synopsis: MainIsBench
9+
category: PackageTests
10+
build-type: Simple
11+
12+
description:
13+
Check if Cabal accepts an autogen-module in a benchmark as the main-is field.
14+
15+
Benchmark Bench
16+
default-language: Haskell2010
17+
main-is: MyDummy.hs
18+
type: exitcode-stdio-1.0
19+
build-depends: base == 4.*
20+
other-modules:
21+
MyDummy
22+
autogen-modules:
23+
MyDummy
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# cabal build
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- MainIsBench-0.1 (bench:Bench) (first run)
6+
Configuring benchmark 'Bench' for MainIsBench-0.1...
7+
Preprocessing benchmark 'Bench' for MainIsBench-0.1...
8+
Building benchmark 'Bench' for MainIsBench-0.1...
9+
Error: [Cabal-2115]
10+
MyDummy.hs doesn't exist
11+
Error: [Cabal-7125]
12+
Failed to build MainIsBench-0.1-inplace-Bench.
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+
main = cabalTest $ do
4+
build <- fails $ cabal' "build" ["--enable-benchmarks"]
5+
assertOutputContains "MyDummy.hs doesn't exist" build
6+
return ()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Setup configure
2+
Configuring MainIsBench-0.1...
3+
# Setup sdist
4+
Building source dist for MainIsBench-0.1...
5+
Error: [Cabal-2115]
6+
MyDummy.hs doesn't exist
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Setup configure
2+
Configuring MainIsBench-0.1...
3+
# Setup sdist
4+
Building source dist for MainIsBench-0.1...
5+
Error: [Cabal-2115]
6+
MyDummy.hs doesn't exist
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Test that setup shows all the 'autogen-modules' warnings.
4+
main = setupAndCabalTest $ do
5+
6+
configureResult <- setup' "configure" []
7+
assertOutputDoesNotContain "MyDummy.hs doesn't exist" configureResult
8+
sdistResult <- fails $ setup' "sdist" []
9+
assertOutputContains "MyDummy.hs doesn't exist" sdistResult
10+
11+
return ()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LICENSE
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
cabal-version: 3.12
2+
name: MainIsExe
3+
version: 0.1
4+
license: BSD-3-Clause
5+
license-file: LICENSE
6+
author: Federico Mastellone
7+
maintainer: Federico Mastellone
8+
synopsis: AutogenModules
9+
category: PackageTests
10+
build-type: Simple
11+
12+
description:
13+
Check if Cabal accepts an autogen-module in an executable as the main-is field.
14+
15+
Executable Exe
16+
default-language: Haskell2010
17+
main-is: MyDummy.hs
18+
build-depends: base == 4.*
19+
other-modules:
20+
MyDummy
21+
autogen-modules:
22+
MyDummy
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# cabal build
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- MainIsExe-0.1 (exe:Exe) (first run)
6+
Configuring executable 'Exe' for MainIsExe-0.1...
7+
Preprocessing executable 'Exe' for MainIsExe-0.1...
8+
Error: [Cabal-7554]
9+
can't find source for MyDummy in ., cabal.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/MainIsExe-0.1/x/Exe/build/Exe/autogen, cabal.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/MainIsExe-0.1/x/Exe/build/global-autogen
10+
Error: [Cabal-7125]
11+
Failed to build MainIsExe-0.1-inplace-Exe.

0 commit comments

Comments
 (0)