Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 28, 2024
1 parent 206a54a commit 6dd178f
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cabal-testsuite/PackageTests/ReplProjectTarget/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# checking repl command with a project using an implicit default 'cabal.project'
# cabal repl
Configuration is affected by the following files:
- cabal.project
Error: [Cabal-7076]
With a project, the REPL command requires a single target. The packages in this project are:
- pkg-one
- pkg-two
# checking repl command with a project using an explicit 'cabal.project'
# cabal repl
Configuration is affected by the following files:
- some.project
Error: [Cabal-7076]
With a project, the REPL command requires a single target. The packages in this project, 'some.project', are:
- pkg-one
- pkg-two
# checking repl command with a project listing packages in reverse order
# cabal repl
Configuration is affected by the following files:
- reverse.project
Error: [Cabal-7076]
With a project, the REPL command requires a single target. The packages in this project, 'reverse.project', are:
- pkg-one
- pkg-two
# checking repl command with a project with no packages
# cabal repl
Configuration is affected by the following files:
- empty.project
Warning: There are no packages or optional-packages in the project
Error: [Cabal-7076]
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.
# checking repl command with a missing project
# cabal repl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: pkg-one pkg-two
22 changes: 22 additions & 0 deletions cabal-testsuite/PackageTests/ReplProjectTarget/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Test.Cabal.Prelude

main = cabalTest . recordMode RecordMarked $ do
let log = recordHeader . pure

log "checking repl command with a project using an implicit default 'cabal.project'"
_ <- fails $ cabal' "repl" []

log "checking repl command with a project using an explicit 'cabal.project'"
_ <- fails $ cabal' "repl" [ "--project-file=some.project" ]

log "checking repl command with a project listing packages in reverse order"
_ <- fails $ cabal' "repl" [ "--project-file=reverse.project" ]

log "checking repl command with a project with no packages"
_ <- fails $ cabal' "repl" [ "--project-file=empty.project" ]

log "checking repl command with a missing project"
missing <- fails $ cabal' "repl" [ "--project-file=missing.project" ]
assertOutputContains "The given project file 'missing.project' does not exist." missing

return ()
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: pkg-one
version: 0.1
license: BSD3
cabal-version: >= 1.2
build-type: Simple

library
exposed-modules: Foo
build-depends: base
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: pkg-one
version: 0.1
license: BSD3
cabal-version: >= 1.2
build-type: Simple

library
exposed-modules: Foo
build-depends: base
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: pkg-two pkg-one
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: pkg-one pkg-two

0 comments on commit 6dd178f

Please sign in to comment.