-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
cabal-testsuite/PackageTests/Status/Invalid/InvalidDep.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cabal-version: 2.4 | ||
name: InvalidDep | ||
version: 0.1.0.0 | ||
|
||
executable Inv | ||
main-is: Main.hs | ||
hs-source-dirs: src | ||
build-depends: another-framework | ||
default-language: Haskell2010 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
packages: ./ |
8 changes: 8 additions & 0 deletions
8
...tsuite/PackageTests/Status/Invalid/repo/another-framework-0.8.1.1/another-framework.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: another-framework | ||
version: 0.8.1.1 | ||
build-type: Simple | ||
cabal-version: >= 1.10 | ||
|
||
library | ||
build-depends: base <3 && >=3 | ||
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Main where | ||
|
||
main :: IO () | ||
main = putStr "Test" |
20 changes: 20 additions & 0 deletions
20
cabal-testsuite/PackageTests/Status/Invalid/unbuildabledep.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# cabal v2-update | ||
Downloading the latest package list from test-local-repo | ||
# cabal status | ||
Resolving dependencies... | ||
Error: cabal: Could not resolve dependencies: | ||
[__0] trying: InvalidDep-0.1.0.0 (user goal) | ||
[__1] trying: another-framework-0.8.1.1 (dependency of InvalidDep) | ||
[__2] next goal: base (dependency of another-framework) | ||
[__2] rejecting: base-<VERSION>/installed-<HASH> (conflict: another-framework => base<3 && >=3) | ||
[__2] fail (backjumping, conflict set: another-framework, base) | ||
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) | ||
# cabal status | ||
Resolving dependencies... | ||
Error: cabal: Could not resolve dependencies: | ||
[__0] trying: InvalidDep-0.1.0.0 (user goal) | ||
[__1] trying: another-framework-0.8.1.1 (dependency of InvalidDep) | ||
[__2] next goal: base (dependency of another-framework) | ||
[__2] rejecting: base-<VERSION>/installed-<HASH> (conflict: another-framework => base<3 && >=3) | ||
[__2] fail (backjumping, conflict set: another-framework, base) | ||
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) |
11 changes: 11 additions & 0 deletions
11
cabal-testsuite/PackageTests/Status/Invalid/unbuildabledep.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
import Test.Cabal.Prelude | ||
import Test.Cabal.DecodeShowBuildInfo | ||
|
||
main = cabalTest $ withRepo "repo" $ do | ||
-- no build plan available | ||
r <- fails $ cabal' "status" ["--output-format=json", "--target", "src/Main.hs"] | ||
assertOutputContains "Could not resolve dependencies" r | ||
-- TODO: should this actually work? | ||
r <- fails $ cabal' "status" ["--output-format=json", "--compiler"] | ||
assertOutputContains "Could not resolve dependencies" r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
cabal-version: 2.4 | ||
name: Simple | ||
version: 0.1.0.0 | ||
|
||
library | ||
exposed-modules: | ||
MyLib | ||
MyLib2 | ||
|
||
build-depends: base | ||
hs-source-dirs: src | ||
default-language: Haskell2010 | ||
|
||
library unbuildable | ||
exposed-modules: MyLib2 | ||
hs-source-dirs: src | ||
build-depends: base | ||
default-language: Haskell2010 | ||
buildable: False | ||
|
||
library compilefail | ||
exposed-modules: Fails | ||
hs-source-dirs: src | ||
build-depends: base | ||
default-language: Haskell2010 | ||
buildable: False | ||
|
||
executable Simple | ||
main-is: Main.hs | ||
|
||
-- Module that belongs to multiple components | ||
other-modules: MyLib | ||
hs-source-dirs: src exe | ||
default-language: Haskell2010 | ||
|
||
-- Just some simple config to test 'exes' meta command | ||
executable Simple2 | ||
main-is: Main2.hs | ||
|
||
-- Module that belongs to multiple components | ||
other-modules: MyLib | ||
hs-source-dirs: src exe | ||
default-language: Haskell2010 | ||
|
||
test-suite Tests | ||
type: exitcode-stdio-1.0 | ||
main-is: Main.hs | ||
hs-source-dirs: test | ||
build-depends: base | ||
|
||
benchmark Benchs | ||
type: exitcode-stdio-1.0 | ||
main-is: Main.hs | ||
hs-source-dirs: test | ||
build-depends: base | ||
|
||
foreign-library myforeignlib | ||
type: native-shared | ||
|
||
if os(windows) | ||
options: standalone | ||
|
||
other-modules: MyForeignLib.Hello | ||
MyForeignLib.SomeBindings | ||
MyForeignLib.AnotherVal | ||
build-depends: base | ||
hs-source-dirs: flibsrc | ||
c-sources: csrc/MyForeignLibWrapper.c | ||
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Bench where | ||
|
||
main = putStr "Benchmarks!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
packages: ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# cabal status | ||
Resolving dependencies... | ||
{"cabal-version":"3.9","compiler":{"flavour":"ghc","compiler-id":"ghc-<GHCVER>","path":"<GHCPATH>"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Test.Cabal.Prelude | ||
import Test.Cabal.DecodeShowBuildInfo | ||
import Data.Maybe | ||
|
||
main = cabalTest $ do | ||
r <- cabal' "status" ["--output-format=json", "--compiler"] | ||
statusInfo <- withJsonOutput r | ||
assertBool "Must contain compiler information" (isJust $ siCompiler statusInfo) |
24 changes: 24 additions & 0 deletions
24
cabal-testsuite/PackageTests/Status/Simple/csrc/MyForeignLibWrapper.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
#include "HsFFI.h" | ||
|
||
bool myForeignLibInit(void){ | ||
int argc = 2; | ||
char *argv[] = { "+RTS", "-A32m", NULL }; | ||
char **pargv = argv; | ||
|
||
// Initialize Haskell runtime | ||
hs_init(&argc, &pargv); | ||
|
||
// do any other initialization here and | ||
// return false if there was a problem | ||
return true; | ||
} | ||
|
||
void myForeignLibExit(void){ | ||
hs_exit(); | ||
} | ||
|
||
int cFoo2() { | ||
return 1234; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Main where | ||
|
||
main :: IO () | ||
main = putStrLn "Test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Main where | ||
|
||
main :: IO () | ||
main = putStrLn "Test" |
3 changes: 3 additions & 0 deletions
3
cabal-testsuite/PackageTests/Status/Simple/flibsrc/MyForeignLib/AnotherVal.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module MyForeignLib.AnotherVal where | ||
|
||
anotherVal = 189 |
13 changes: 13 additions & 0 deletions
13
cabal-testsuite/PackageTests/Status/Simple/flibsrc/MyForeignLib/Hello.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- | Module with single foreign export | ||
module MyForeignLib.Hello (sayHi) where | ||
|
||
import MyForeignLib.SomeBindings | ||
import MyForeignLib.AnotherVal | ||
|
||
foreign export ccall sayHi :: IO () | ||
|
||
-- | Say hi! | ||
sayHi :: IO () | ||
sayHi = putStrLn $ | ||
"Hi from a foreign library! Foo has value " ++ show valueOfFoo | ||
++ " and anotherVal has value " ++ show anotherVal |
10 changes: 10 additions & 0 deletions
10
cabal-testsuite/PackageTests/Status/Simple/flibsrc/MyForeignLib/SomeBindings.hsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- | Module that needs the hsc2hs preprocessor | ||
module MyForeignLib.SomeBindings where | ||
|
||
#define FOO 1 | ||
|
||
#ifdef FOO | ||
-- | Value guarded by a CPP flag | ||
valueOfFoo :: Int | ||
valueOfFoo = 5678 | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# cabal status | ||
Resolving dependencies... | ||
{"cabal-version":"3.9","targets":[{"target":"src/Main.hs","unit-id":null}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest $ do | ||
-- Make sure plan.json is generated, even if no target is resolved | ||
cabal "status" ["--output-format=json", "--target", "src/Main.hs"] | ||
withPlan $ do | ||
pure () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# cabal status | ||
Error: cabal: The status command requires the flag '--output-format'. | ||
# cabal status | ||
Resolving dependencies... | ||
{"cabal-version":"3.9","targets":[{"target":"exe/Main.hs","unit-id":"Simple-0.1.0.0-inplace-Simple"}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"exe/Main.hs","unit-id":"Simple-0.1.0.0-inplace-Simple"},{"target":"exe/Main2.hs","unit-id":"Simple-0.1.0.0-inplace-Simple2"}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"src/MyLib.hs","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"src/MyLib2.hs","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"bench/Bench.hs","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"test/Main.hs","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"flibsrc/MyForeignLib/AnotherVal.hs","unit-id":"Simple-0.1.0.0-inplace-myforeignlib"},{"target":"flibsrc/MyForeignLib/Hello.hs","unit-id":"Simple-0.1.0.0-inplace-myforeignlib"},{"target":"flibsrc/MyForeignLib/SomeBindings.hsc","unit-id":"Simple-0.1.0.0-inplace-myforeignlib"},{"target":"csrc/MyForeignLibWrapper.c","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"Benchs","unit-id":"Simple-0.1.0.0-inplace-Benchs"}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"all","unit-id":"Simple-0.1.0.0-inplace"},{"target":"all","unit-id":"Simple-0.1.0.0-inplace-Simple"},{"target":"all","unit-id":"Simple-0.1.0.0-inplace-Simple2"},{"target":"all","unit-id":"Simple-0.1.0.0-inplace-myforeignlib"}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"exes","unit-id":"Simple-0.1.0.0-inplace-Simple"},{"target":"exes","unit-id":"Simple-0.1.0.0-inplace-Simple2"}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"tests","unit-id":"Simple-0.1.0.0-inplace-Tests"}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"benchmarks","unit-id":"Simple-0.1.0.0-inplace-Benchs"}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"executables","unit-id":"Simple-0.1.0.0-inplace-Simple"},{"target":"executables","unit-id":"Simple-0.1.0.0-inplace-Simple2"}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"Main2.hs","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"Main3.hs","unit-id":null},{"target":"src/MyLib2.hs","unit-id":null},{"target":"Main3.hs","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"Lib.hs","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","compiler":{"flavour":"ghc","compiler-id":"ghc-<GHCVER>","path":"<GHCPATH>"},"targets":[{"target":"Lib.hs","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","targets":[{"target":"Lib2.hs","unit-id":null}]} | ||
# cabal status | ||
{"cabal-version":"3.9","compiler":{"flavour":"ghc","compiler-id":"ghc-<GHCVER>","path":"<GHCPATH>"},"targets":[{"target":"Lib.hs","unit-id":null}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Test.Cabal.Prelude | ||
import Test.Cabal.DecodeShowBuildInfo | ||
import Data.Maybe (isJust) | ||
import Data.List (sort, nub) | ||
|
||
main = cabalTest $ do | ||
-- output-format flag is missing but required, must fail | ||
r <- fails $ cabal' "status" ["--target", "Main.hs"] | ||
assertOutputContains "The status command requires the flag '--output-format'." r | ||
|
||
-- Simple file target tests | ||
runStatusWithTargets ["exe/Main.hs"] | ||
runStatusWithTargets ["exe/Main.hs", "exe/Main2.hs"] -- multiple targets | ||
runStatusWithTargets ["src/MyLib.hs"] -- belongs to multiple components | ||
runStatusWithTargets ["src/MyLib2.hs"] | ||
runStatusWithTargets ["bench/Bench.hs"] | ||
runStatusWithTargets ["test/Main.hs"] | ||
runStatusWithTargets ["flibsrc/MyForeignLib/AnotherVal.hs", | ||
"flibsrc/MyForeignLib/Hello.hs", | ||
"flibsrc/MyForeignLib/SomeBindings.hsc", | ||
"csrc/MyForeignLibWrapper.c" | ||
] | ||
-- TODO: this should not fail, that's a bug! | ||
-- runStatusWithTargets ["lib:Simple", "exe:Simple", "Simple:exe:Simple"] | ||
-- pkgs syntax twsts | ||
runStatusWithTargets ["Benchs"] | ||
|
||
-- meta targets | ||
runStatusWithTargets ["all"] | ||
runStatusWithTargets ["exes"] | ||
runStatusWithTargets ["tests"] | ||
runStatusWithTargets ["benchmarks"] | ||
|
||
-- unknown target selectors | ||
runStatusWithTargets ["executables"] | ||
runStatusWithTargets ["Main2.hs"] | ||
|
||
-- partially works, Main3.hs isn't known while `src/MyLib2.hs` is. | ||
runStatusWithTargets ["Main3.hs", "src/MyLib2.hs"] | ||
|
||
-- component fails to compile, still works | ||
cabal "status" ["--output-format=json", "--target", "Lib.hs"] | ||
cabal "status" ["--output-format=json", "--compiler", "--target", "Lib.hs"] | ||
-- unbuildable target, resolves to 'null' | ||
cabal "status" ["--output-format=json", "--target", "Lib2.hs"] | ||
cabal "status" ["--output-format=json", "--compiler", "--target", "Lib.hs"] | ||
where | ||
runStatusWithTargets :: [String] -> TestM () | ||
runStatusWithTargets targets = do | ||
r <- cabal' "status" $ ["--output-format=json"] ++ concatMap (\t -> ["--target", t]) targets | ||
statusInfo <- withJsonOutput r | ||
assertBool "Must contain targets" (isJust $ siTargetResolving statusInfo) | ||
assertBool "Must contain all targets at least once" | ||
(Just (nub $ sort targets) == fmap (nub . sort . map rtOriginalTarget) (siTargetResolving statusInfo)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Fails where | ||
|
||
-- fails to compile intentionally | ||
foo = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module MyLib (someFunc) where | ||
|
||
someFunc :: IO () | ||
someFunc = putStrLn "someFunc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module MyLib2 (someFunc) where | ||
|
||
someFunc :: IO () | ||
someFunc = putStrLn "someFunc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Bench where | ||
|
||
main = putStr "Tests!" |
Oops, something went wrong.