Skip to content

Commit e5a68bc

Browse files
committed
WIP: add tests for cabal status
1 parent ee7cd24 commit e5a68bc

File tree

27 files changed

+388
-0
lines changed

27 files changed

+388
-0
lines changed
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: InvalidDep
3+
version: 0.1.0.0
4+
5+
executable Inv
6+
main-is: Main.hs
7+
hs-source-dirs: src
8+
build-depends: another-framework
9+
default-language: Haskell2010
10+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: ./
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: another-framework
2+
version: 0.8.1.1
3+
build-type: Simple
4+
cabal-version: >= 1.10
5+
6+
library
7+
build-depends: base <3 && >=3
8+
default-language: Haskell2010
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Main where
2+
3+
main :: IO ()
4+
main = putStr "Test"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# cabal v2-update
2+
Downloading the latest package list from test-local-repo
3+
# cabal status
4+
Resolving dependencies...
5+
Error: cabal: Could not resolve dependencies:
6+
[__0] trying: InvalidDep-0.1.0.0 (user goal)
7+
[__1] trying: another-framework-0.8.1.1 (dependency of InvalidDep)
8+
[__2] next goal: base (dependency of another-framework)
9+
[__2] rejecting: base-<VERSION>/installed-<HASH> (conflict: another-framework => base<3 && >=3)
10+
[__2] fail (backjumping, conflict set: another-framework, base)
11+
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: another-framework (3), InvalidDep (2), base (2)
12+
# cabal status
13+
Resolving dependencies...
14+
Error: cabal: Could not resolve dependencies:
15+
[__0] trying: InvalidDep-0.1.0.0 (user goal)
16+
[__1] trying: another-framework-0.8.1.1 (dependency of InvalidDep)
17+
[__2] next goal: base (dependency of another-framework)
18+
[__2] rejecting: base-<VERSION>/installed-<HASH> (conflict: another-framework => base<3 && >=3)
19+
[__2] fail (backjumping, conflict set: another-framework, base)
20+
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: another-framework (3), InvalidDep (2), base (2)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
import Test.Cabal.Prelude
3+
import Test.Cabal.DecodeShowBuildInfo
4+
5+
main = cabalTest $ withRepo "repo" $ do
6+
-- no build plan available
7+
r <- fails $ cabal' "status" ["--output-format=json", "--target", "src/Main.hs"]
8+
assertOutputContains "Could not resolve dependencies" r
9+
-- TODO: should this actually work?
10+
r <- fails $ cabal' "status" ["--output-format=json", "--compiler"]
11+
assertOutputContains "Could not resolve dependencies" r
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
cabal-version: 2.4
2+
name: Simple
3+
version: 0.1.0.0
4+
5+
library
6+
exposed-modules:
7+
MyLib
8+
MyLib2
9+
10+
build-depends: base
11+
hs-source-dirs: src
12+
default-language: Haskell2010
13+
14+
library unbuildable
15+
exposed-modules: MyLib2
16+
hs-source-dirs: src
17+
build-depends: base
18+
default-language: Haskell2010
19+
buildable: False
20+
21+
library compilefail
22+
exposed-modules: Fails
23+
hs-source-dirs: src
24+
build-depends: base
25+
default-language: Haskell2010
26+
buildable: False
27+
28+
executable Simple
29+
main-is: Main.hs
30+
31+
-- Module that belongs to multiple components
32+
other-modules: MyLib
33+
hs-source-dirs: src exe
34+
default-language: Haskell2010
35+
36+
-- Just some simple config to test 'exes' meta command
37+
executable Simple2
38+
main-is: Main2.hs
39+
40+
-- Module that belongs to multiple components
41+
other-modules: MyLib
42+
hs-source-dirs: src exe
43+
default-language: Haskell2010
44+
45+
test-suite Tests
46+
type: exitcode-stdio-1.0
47+
main-is: Main.hs
48+
hs-source-dirs: test
49+
build-depends: base
50+
51+
benchmark Benchs
52+
type: exitcode-stdio-1.0
53+
main-is: Main.hs
54+
hs-source-dirs: test
55+
build-depends: base
56+
57+
foreign-library myforeignlib
58+
type: native-shared
59+
60+
if os(windows)
61+
options: standalone
62+
63+
other-modules: MyForeignLib.Hello
64+
MyForeignLib.SomeBindings
65+
MyForeignLib.AnotherVal
66+
build-depends: base
67+
hs-source-dirs: flibsrc
68+
c-sources: csrc/MyForeignLibWrapper.c
69+
default-language: Haskell2010
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Bench where
2+
3+
main = putStr "Benchmarks!"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: ./
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# cabal status
2+
Resolving dependencies...
3+
{"cabal-version":"3.9","compiler":{"flavour":"ghc","compiler-id":"ghc-<GHCVER>","path":"<GHCPATH>"}}

0 commit comments

Comments
 (0)