Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alt.project tests for ReplOptions #10690

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/ReplOptions/alt.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: alt
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/ReplOptions/alt/ModuleA.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ModuleA where

a :: Int
a = 42
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/ReplOptions/alt/ModuleC.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ModuleC where

c :: Int
c = 42
10 changes: 10 additions & 0 deletions cabal-testsuite/PackageTests/ReplOptions/alt/alt.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: alt
version: 0.1
build-type: Simple
cabal-version: >= 1.10

library
exposed-modules: ModuleA, ModuleC
build-depends: base
default-language: Haskell2010

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# cabal clean
# cabal v2-repl
Configuration is affected by the following files:
- alt.project
Configuration is affected by the following files:
- alt.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- alt-0.1 (interactive) (lib) (first run)
Configuring library for alt-0.1...
Preprocessing library for alt-0.1...
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# cabal clean
# cabal v2-repl
Configuration is affected by the following files:
- alt.project
Configuration is affected by the following files:
- alt.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- alt-0.1 (interactive) (lib) (first run)
Configuring library for alt-0.1...
Preprocessing library for alt-0.1...
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# cabal v2-repl
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# cabal v2-repl
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# cabal v2-repl
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# cabal v2-repl
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# cabal v2-repl
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
Expand Down
23 changes: 20 additions & 3 deletions cabal-testsuite/PackageTests/ReplOptions/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
import Test.Cabal.Prelude

singleOpts = ["--repl-options=-fwrite-interface"]
multiOpts = "--repl-options=-fdefer-typed-holes" : singleOpts
altProject = ("--project-file=alt.project" :)

main = do
cabalTest' "single-repl-options" $ do
cabal' "clean" []
res <- cabalWithStdin "v2-repl" ["--repl-options=-fwrite-interface"] ":set"
res <- cabalWithStdin "v2-repl" singleOpts ":set"
assertOutputContains "Ok, two modules loaded." res
assertOutputContains " -fwrite-interface" res

cabalTest' "alt-single-repl-options" $ do
cabal' "clean" []
-- Can we 'cabal repl' without a target when the project has a single package?
void $ cabalWithStdin "v2-repl" (altProject singleOpts) ":set"

cabalTest' "multiple-repl-options" $ do
cabal' "clean" []
res <- cabalWithStdin "v2-repl" ["--repl-options=-fwrite-interface", "--repl-options=-fdefer-typed-holes"] ":set"
res <- cabalWithStdin "v2-repl" multiOpts ":set"
assertOutputContains "Ok, two modules loaded." res
assertOutputContains " -fwrite-interface" res
assertOutputContains " -fdefer-typed-holes" res

cabalTest' "alt-multiple-repl-options" $ do
cabal' "clean" []
-- Can we 'cabal repl' without a target when the project has a single package?
void $ cabalWithStdin "v2-repl" (altProject multiOpts) ":set"

cabalTest' "single-repl-options-multiple-flags" $ do
cabal' "clean" []
res <- cabalWithStdin "v2-repl" ["--repl-options=-fdefer-typed-holes -fwrite-interface"] ":set"
assertOutputContains "Ok, two modules loaded." res
assertOutputContains " -fwrite-interface" res
assertOutputContains " -fdefer-typed-holes" res

cabalTest' "single-repl-options-multiple-flags-negative" $ do
cabal' "clean" []
res <- fails $ cabalWithStdin "v2-repl" ["--repl-options=-fwrite-interface -fdiagnostics-show-baret"] ":set"
assertOutputDoesNotContain "Ok, two modules loaded." res
assertOutputContains "unrecognised flag: -fdiagnostics-show-baret" res
assertOutputContains "did you mean one of:" res

cabalTest' "multiple-repl-options-multiple-flags" $ do
cabal' "clean" []
res <- cabalWithStdin "v2-repl" [
Expand Down
Loading