Skip to content

Commit 3821cff

Browse files
committed
Add alt.project tests for ReplOptions
1 parent 4b2e5f0 commit 3821cff

12 files changed

+73
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: alt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ModuleA where
2+
3+
a :: Int
4+
a = 42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ModuleC where
2+
3+
c :: Int
4+
c = 42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: alt
2+
version: 0.1
3+
build-type: Simple
4+
cabal-version: >= 1.10
5+
6+
library
7+
exposed-modules: ModuleA, ModuleC
8+
build-depends: base
9+
default-language: Haskell2010
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# cabal clean
2+
# cabal v2-repl
3+
Configuration is affected by the following files:
4+
- alt.project
5+
Configuration is affected by the following files:
6+
- alt.project
7+
Resolving dependencies...
8+
Build profile: -w ghc-<GHCVER> -O1
9+
In order, the following will be built:
10+
- alt-0.1 (interactive) (lib) (first run)
11+
Configuring library for alt-0.1...
12+
Preprocessing library for alt-0.1...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# cabal clean
2+
# cabal v2-repl
3+
Configuration is affected by the following files:
4+
- alt.project
5+
Configuration is affected by the following files:
6+
- alt.project
7+
Resolving dependencies...
8+
Build profile: -w ghc-<GHCVER> -O1
9+
In order, the following will be built:
10+
- alt-0.1 (interactive) (lib) (first run)
11+
Configuring library for alt-0.1...
12+
Preprocessing library for alt-0.1...

cabal-testsuite/PackageTests/ReplOptions/cabal.multiple-repl-options-multiple-flags.out

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# cabal v2-repl
33
Configuration is affected by the following files:
44
- cabal.project
5+
Configuration is affected by the following files:
6+
- cabal.project
57
Resolving dependencies...
68
Build profile: -w ghc-<GHCVER> -O1
79
In order, the following will be built:

cabal-testsuite/PackageTests/ReplOptions/cabal.multiple-repl-options.out

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# cabal v2-repl
33
Configuration is affected by the following files:
44
- cabal.project
5+
Configuration is affected by the following files:
6+
- cabal.project
57
Resolving dependencies...
68
Build profile: -w ghc-<GHCVER> -O1
79
In order, the following will be built:

cabal-testsuite/PackageTests/ReplOptions/cabal.single-repl-options-multiple-flags-negative.out

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# cabal v2-repl
33
Configuration is affected by the following files:
44
- cabal.project
5+
Configuration is affected by the following files:
6+
- cabal.project
57
Resolving dependencies...
68
Build profile: -w ghc-<GHCVER> -O1
79
In order, the following will be built:

cabal-testsuite/PackageTests/ReplOptions/cabal.single-repl-options-multiple-flags.out

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# cabal v2-repl
33
Configuration is affected by the following files:
44
- cabal.project
5+
Configuration is affected by the following files:
6+
- cabal.project
57
Resolving dependencies...
68
Build profile: -w ghc-<GHCVER> -O1
79
In order, the following will be built:

cabal-testsuite/PackageTests/ReplOptions/cabal.single-repl-options.out

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# cabal v2-repl
33
Configuration is affected by the following files:
44
- cabal.project
5+
Configuration is affected by the following files:
6+
- cabal.project
57
Resolving dependencies...
68
Build profile: -w ghc-<GHCVER> -O1
79
In order, the following will be built:

cabal-testsuite/PackageTests/ReplOptions/cabal.test.hs

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
11
import Test.Cabal.Prelude
22

3+
singleOpts = ["--repl-options=-fwrite-interface"]
4+
multiOpts = "--repl-options=-fdefer-typed-holes" : singleOpts
5+
altProject = ("--project-file=alt.project" :)
6+
37
main = do
48
cabalTest' "single-repl-options" $ do
59
cabal' "clean" []
6-
res <- cabalWithStdin "v2-repl" ["--repl-options=-fwrite-interface"] ":set"
10+
res <- cabalWithStdin "v2-repl" singleOpts ":set"
711
assertOutputContains "Ok, two modules loaded." res
8-
assertOutputContains " -fwrite-interface" res
12+
13+
cabalTest' "alt-single-repl-options" $ do
14+
cabal' "clean" []
15+
-- Can we 'cabal repl' without a target when the project has a single package?
16+
void $ cabalWithStdin "v2-repl" (altProject singleOpts) ":set"
17+
918
cabalTest' "multiple-repl-options" $ do
1019
cabal' "clean" []
11-
res <- cabalWithStdin "v2-repl" ["--repl-options=-fwrite-interface", "--repl-options=-fdefer-typed-holes"] ":set"
20+
res <- cabalWithStdin "v2-repl" multiOpts ":set"
1221
assertOutputContains "Ok, two modules loaded." res
1322
assertOutputContains " -fwrite-interface" res
1423
assertOutputContains " -fdefer-typed-holes" res
24+
25+
cabalTest' "alt-multiple-repl-options" $ do
26+
cabal' "clean" []
27+
-- Can we 'cabal repl' without a target when the project has a single package?
28+
void $ cabalWithStdin "v2-repl" (altProject multiOpts) ":set"
29+
1530
cabalTest' "single-repl-options-multiple-flags" $ do
1631
cabal' "clean" []
1732
res <- cabalWithStdin "v2-repl" ["--repl-options=-fdefer-typed-holes -fwrite-interface"] ":set"
1833
assertOutputContains "Ok, two modules loaded." res
1934
assertOutputContains " -fwrite-interface" res
2035
assertOutputContains " -fdefer-typed-holes" res
36+
2137
cabalTest' "single-repl-options-multiple-flags-negative" $ do
2238
cabal' "clean" []
2339
res <- fails $ cabalWithStdin "v2-repl" ["--repl-options=-fwrite-interface -fdiagnostics-show-baret"] ":set"
2440
assertOutputDoesNotContain "Ok, two modules loaded." res
2541
assertOutputContains "unrecognised flag: -fdiagnostics-show-baret" res
2642
assertOutputContains "did you mean one of:" res
43+
2744
cabalTest' "multiple-repl-options-multiple-flags" $ do
2845
cabal' "clean" []
2946
res <- cabalWithStdin "v2-repl" [

0 commit comments

Comments
 (0)