Skip to content

Commit 6ce4db8

Browse files
committed
Re-design test-cases for show-build-info
1 parent e902b78 commit 6ce4db8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+730
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cabal-version: 2.4
2+
name: A
3+
version: 0.1.0.0
4+
license: BSD-3-Clause
5+
6+
library
7+
exposed-modules: A
8+
build-depends: base >=4
9+
hs-source-dirs: src
10+
default-language: Haskell2010
11+
12+
executable A
13+
main-is: Main.hs
14+
build-depends: base >=4
15+
hs-source-dirs: src
16+
default-language: Haskell2010
17+
18+
test-suite A-tests
19+
type: exitcode-stdio-1.0
20+
main-is: Test.hs
21+
build-depends: base >=4, A
22+
hs-source-dirs: src
23+
default-language: Haskell2010
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cabal-version: 2.4
2+
name: B
3+
version: 0.1.0.0
4+
license: BSD-3-Clause
5+
6+
library
7+
exposed-modules: B
8+
build-depends: base >=4.0.0.0, A
9+
hs-source-dirs: lib
10+
default-language: Haskell2010
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module B where
2+
3+
foo :: Int -> Int
4+
foo = id
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# cabal build
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- A-0.1.0.0 (lib) (first run)
6+
- A-0.1.0.0 (exe:A) (first run)
7+
- B-0.1.0.0 (lib) (first run)
8+
- A-0.1.0.0 (test:A-tests) (first run)
9+
Configuring library for A-0.1.0.0..
10+
Preprocessing library for A-0.1.0.0..
11+
Building library for A-0.1.0.0..
12+
Configuring executable 'A' for A-0.1.0.0..
13+
Preprocessing executable 'A' for A-0.1.0.0..
14+
Building executable 'A' for A-0.1.0.0..
15+
Configuring library for B-0.1.0.0..
16+
Preprocessing library for B-0.1.0.0..
17+
Building library for B-0.1.0.0..
18+
Configuring test suite 'A-tests' for A-0.1.0.0..
19+
Preprocessing test suite 'A-tests' for A-0.1.0.0..
20+
Building test suite 'A-tests' for A-0.1.0.0..
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
import Test.Cabal.Prelude
3+
import Test.Cabal.DecodeShowBuildInfo
4+
5+
main = cabalTest $ do
6+
runShowBuildInfo ["all", "--enable-tests"]
7+
withPlan $ do
8+
assertComponent "A" (exe "A")
9+
defCompAssertion
10+
{ sourceFiles = ["Main.hs"]
11+
, sourceDirs = ["src"]
12+
}
13+
assertComponent "A" mainLib
14+
defCompAssertion
15+
{ modules = ["A"]
16+
, sourceDirs = ["src"]
17+
}
18+
19+
assertComponent "B" mainLib
20+
defCompAssertion
21+
{ modules = ["B"]
22+
, sourceDirs = ["lib"]
23+
}
24+
assertComponent "A" (test "A-tests")
25+
defCompAssertion
26+
{ sourceFiles = ["Test.hs"]
27+
, sourceDirs = ["src"]
28+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# cabal build
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- A-0.1.0.0 (exe:A) (first run)
6+
Configuring executable 'A' for A-0.1.0.0..
7+
Preprocessing executable 'A' for A-0.1.0.0..
8+
Building executable 'A' for A-0.1.0.0..
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
import Test.Cabal.Prelude
3+
import Test.Cabal.DecodeShowBuildInfo
4+
5+
main = cabalTest $ do
6+
runShowBuildInfo ["exe:A"]
7+
withPlan $ do
8+
assertComponent "A" (exe "A")
9+
defCompAssertion
10+
{ sourceFiles = ["Main.hs"]
11+
, sourceDirs = ["src"]
12+
-- does not list lib as a target
13+
, compilerArgsPred = all (/= "A-0.1.0.0-inplace")
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: . ./B/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# cabal build
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- A-0.1.0.0 (exe:A) (first run)
6+
Configuring executable 'A' for A-0.1.0.0..
7+
Preprocessing executable 'A' for A-0.1.0.0..
8+
Building executable 'A' for A-0.1.0.0..
9+
# cabal v2-build
10+
Build profile: -w ghc-<GHCVER> -O1
11+
In order, the following will be built:
12+
- A-0.1.0.0 (exe:A) (configuration changed)
13+
Configuring executable 'A' for A-0.1.0.0..
14+
Preprocessing executable 'A' for A-0.1.0.0..
15+
Building executable 'A' for A-0.1.0.0..
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
import Test.Cabal.Prelude
3+
import Test.Cabal.DecodeShowBuildInfo
4+
import Test.Cabal.Plan
5+
import Control.Monad.Trans.Reader
6+
import System.Directory
7+
8+
main = cabalTest $ do
9+
runShowBuildInfo ["exe:A"]
10+
withPlan $ do
11+
assertComponent "A" (exe "A")
12+
defCompAssertion
13+
{ sourceFiles = ["Main.hs"]
14+
, sourceDirs = ["src"]
15+
-- does not list lib as a target
16+
, compilerArgsPred = all (/= "A-0.1.0.0-inplace")
17+
}
18+
19+
cabal' "v2-build" ["exe:A", "--disable-build-info"]
20+
withPlan $ do
21+
Just plan <- fmap testPlan ask
22+
let fp = buildInfoFile plan "A" (exe "A")
23+
shouldNotExist fp

0 commit comments

Comments
 (0)