Skip to content

Commit 6dd178f

Browse files
committed
Add tests
1 parent 206a54a commit 6dd178f

File tree

8 files changed

+76
-0
lines changed

8 files changed

+76
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# checking repl command with a project using an implicit default 'cabal.project'
2+
# cabal repl
3+
Configuration is affected by the following files:
4+
- cabal.project
5+
Error: [Cabal-7076]
6+
With a project, the REPL command requires a single target. The packages in this project are:
7+
- pkg-one
8+
- pkg-two
9+
# checking repl command with a project using an explicit 'cabal.project'
10+
# cabal repl
11+
Configuration is affected by the following files:
12+
- some.project
13+
Error: [Cabal-7076]
14+
With a project, the REPL command requires a single target. The packages in this project, 'some.project', are:
15+
- pkg-one
16+
- pkg-two
17+
# checking repl command with a project listing packages in reverse order
18+
# cabal repl
19+
Configuration is affected by the following files:
20+
- reverse.project
21+
Error: [Cabal-7076]
22+
With a project, the REPL command requires a single target. The packages in this project, 'reverse.project', are:
23+
- pkg-one
24+
- pkg-two
25+
# checking repl command with a project with no packages
26+
# cabal repl
27+
Configuration is affected by the following files:
28+
- empty.project
29+
Warning: There are no packages or optional-packages in the project
30+
Error: [Cabal-7076]
31+
With a project, the REPL command requires a single target but there are no packages in this project, 'empty.project', to choose a package (library) or other component from as the target for this command.
32+
# checking repl command with a missing project
33+
# cabal repl
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: pkg-one pkg-two
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Test.Cabal.Prelude
2+
3+
main = cabalTest . recordMode RecordMarked $ do
4+
let log = recordHeader . pure
5+
6+
log "checking repl command with a project using an implicit default 'cabal.project'"
7+
_ <- fails $ cabal' "repl" []
8+
9+
log "checking repl command with a project using an explicit 'cabal.project'"
10+
_ <- fails $ cabal' "repl" [ "--project-file=some.project" ]
11+
12+
log "checking repl command with a project listing packages in reverse order"
13+
_ <- fails $ cabal' "repl" [ "--project-file=reverse.project" ]
14+
15+
log "checking repl command with a project with no packages"
16+
_ <- fails $ cabal' "repl" [ "--project-file=empty.project" ]
17+
18+
log "checking repl command with a missing project"
19+
missing <- fails $ cabal' "repl" [ "--project-file=missing.project" ]
20+
assertOutputContains "The given project file 'missing.project' does not exist." missing
21+
22+
return ()

cabal-testsuite/PackageTests/ReplProjectTarget/empty.project

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: pkg-one
2+
version: 0.1
3+
license: BSD3
4+
cabal-version: >= 1.2
5+
build-type: Simple
6+
7+
library
8+
exposed-modules: Foo
9+
build-depends: base
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: pkg-one
2+
version: 0.1
3+
license: BSD3
4+
cabal-version: >= 1.2
5+
build-type: Simple
6+
7+
library
8+
exposed-modules: Foo
9+
build-depends: base
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: pkg-two pkg-one
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: pkg-one pkg-two

0 commit comments

Comments
 (0)