Skip to content
Merged
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
25 changes: 15 additions & 10 deletions tests/integration/tests/4001-excess-recompilation/Main.hs
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import Control.Monad (unless)
import Data.List (isInfixOf)
import StackTest
-- Stack does not recompile a package when a test suite or benchmark is dirty
-- but the test suite or benchmark is not a build target.
--
-- See: https://github.com/commercialhaskell/stack/issues/4001

import Control.Monad ( unless )
import Data.List ( isInfixOf )
import StackTest

main :: IO ()
main = do
copy "test/Main1.hs" "test/Main.hs"
copy "bench/Main1.hs" "bench/Main.hs"
copy "test/Main.v1" "test/Main.hs"
copy "bench/Main.v1" "bench/Main.hs"
stack ["build"]

copy "test/Main2.hs" "test/Main.hs"
copy "bench/Main2.hs" "bench/Main.hs"
copy "test/Main.v2" "test/Main.hs"
copy "bench/Main.v2" "bench/Main.hs"
res <- unregisteringLines . snd <$> stackStderr ["build"]
removeFileIgnore "test/Main.hs"
removeFileIgnore "bench/Main.hs"
unless (null res) $ fail "Stack recompiled when a test or benchmark file was changed, but only the library was targeted"
unless (null res) $
fail "Stack recompiled when a test or benchmark file was changed, but only \
\the library was targeted."

unregisteringLines :: String -> [String]
unregisteringLines = filter (isInfixOf " unregistering ") . lines
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
myPackage.Cabal

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Lib

main :: IO ()
main = pure ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Lib

main :: IO ()
main = putStrLn "Version 1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Lib

main :: IO ()
main = putStrLn "Version 2"

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
spec-version: 0.36.0

name: myPackage
version: 0.1.0.0

dependencies:
- base

library:
source-dirs: src

tests:
test:
source-dirs: test
main: Main.hs
dependencies:
- myPackage

benchmarks:
bench:
source-dirs: bench
main: Main.hs
dependencies:
- myPackage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Lib

main :: IO ()
main = pure ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Lib

main :: IO ()
main = putStrLn "Version 1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Lib

main :: IO ()
main = putStrLn "Version 2"

This file was deleted.

This file was deleted.

8 changes: 6 additions & 2 deletions tests/integration/tests/4044-no-run-tests-config/Main.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import StackTest
-- Stack can be configured not to run test suites.
--
-- See: https://github.com/commercialhaskell/stack/issues/4044

import StackTest

main :: IO ()
main = do
stack ["test"]
stack ["build", "foo:test:foo"]
stack ["build", "myPackage:test:test"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.cabal
myPackage.cabal

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: foo
version: 0
spec-version: 0.36.0

name: myPackage
version: 0.1.0.0

dependencies:
- base

library: {}

tests:
foo:
main: Test.hs
test:
source-dirs: test
main: Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main :: IO ()
main = error "This test will fail if run."
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- See: https://github.com/commercialhaskell/stack/issues/4044

{-# LANGUAGE OverloadedStrings #-}

{--
Expand Down
13 changes: 8 additions & 5 deletions tests/integration/tests/4095-utf8-pure-nix/Main.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import StackTest
-- Stack supports Unicode code points in a Nix environment.
--
-- See: https://github.com/commercialhaskell/stack/issues/4095

import Control.Monad ( unless )
import Data.Maybe ( isJust )
import System.Environment ( lookupEnv )
import Control.Monad ( unless )
import Data.Maybe ( isJust )
import StackTest
import System.Environment ( lookupEnv )

-- This test requires that Nix is installed and that the NIX_PATH has been set
-- so as to allow the path <nixpkgs> to be used.
Expand All @@ -18,7 +21,7 @@ main
isInContainer <- getInContainer
unless isInContainer $ do
stack ["build", "--nix-pure"]
stack ["exec", "--nix-pure", "ShowUnicode"]
stack ["exec", "--nix-pure", "myExe"]

-- | 'True' if we are currently running inside a Docker container.
getInContainer :: IO Bool
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.cabal
myPackage.cabal

This file was deleted.

5 changes: 5 additions & 0 deletions tests/integration/tests/4095-utf8-pure-nix/files/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import System.IO ( stdout )
import Text.Printf ( hPrintf )

main :: IO ()
main = hPrintf stdout "平和"
12 changes: 8 additions & 4 deletions tests/integration/tests/4095-utf8-pure-nix/files/package.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: foo
version: 0
spec-version: 0.36.0

name: myPackage
version: 0.1.0.0

dependencies:
- base

executables:
ShowUnicode:
main: ShowUnicode.hs
myExe:
source-dirs: app
main: Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
#
# 948 (GHC 9.4.8), 967 (GHC 9.6.7), 984 (GHC 9.8.4), 9102 (GHC 9.10.2),
# 9103 (GHC 9.10.3), 9122 (GHC 9.12.2).
snapshot: lts-24.32 # GHC 9.10.3
snapshot: ghc-9.10.3
24 changes: 14 additions & 10 deletions tests/integration/tests/4101-dependency-tree/Main.hs
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
import Control.Monad (when, unless)
import StackTest
import System.Directory (getCurrentDirectory)
import Data.List (isPrefixOf)
-- Stack can report the dependency tree of project packages.
--
-- See: https://github.com/commercialhaskell/stack/issues/4101

import Control.Monad ( unless, when )
import Data.List ( isPrefixOf )
import StackTest
import System.Directory ( getCurrentDirectory )

main :: IO ()
main = unless isWindows $ do
stackCheckStdout ["ls", "dependencies", "tree"] $ \stdOut -> do
let expected = unlines [ "Packages"
, "├─┬ files 0.1.0.0"
, "├─┬ myPackageA 0.1.0.0"
, "│ ├─┬ base 4.20.2.0"
]
unless (expected `isPrefixOf` stdOut) $
error $ unlines [ "Expected:", expected, "Actual:", stdOut ]

stackCheckStdout ["ls", "dependencies", "tree", "--depth=1"] $ \stdOut -> do
let expected = unlines [ "Packages"
, "├─┬ files 0.1.0.0"
, "├─┬ myPackageA 0.1.0.0"
, "│ ├── base 4.20.2.0"
, "│ ├── filelock 0.1.1.2"
, "│ ├── mtl 2.3.1"
, "│ └── subproject 0.1.0.0"
, "└─┬ subproject 0.1.0.0"
, "│ └── myPackageB 0.1.0.0"
, "└─┬ myPackageB 0.1.0.0"
, " └── base 4.20.2.0"
]
when (stdOut /= expected) $
error $ unlines [ "Expected:", expected, "Actual:", stdOut ]

stackCheckStdout ["ls", "dependencies", "tree", "subproject"] $ \stdOut -> do
stackCheckStdout ["ls", "dependencies", "tree", "myPackageB"] $ \stdOut -> do
let expected = unlines [ "Packages"
, "└─┬ subproject 0.1.0.0"
, "└─┬ myPackageB 0.1.0.0"
, " └─┬ base 4.20.2.0"
, " ├─┬ ghc-internal 9.1003.0"
, " │ ├─┬ ghc-bignum 1.3"
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/tests/4101-dependency-tree/files/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
myPackageA.cabal
myPackageB.cabal
10 changes: 0 additions & 10 deletions tests/integration/tests/4101-dependency-tree/files/files.cabal

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
spec-version: 0.36.0

name: myPackageB
version: 0.1.0.0

dependencies:
- base

library: {}
12 changes: 12 additions & 0 deletions tests/integration/tests/4101-dependency-tree/files/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
spec-version: 0.36.0

name: myPackageA
version: 0.1.0.0

dependencies:
- base
- filelock
- mtl
- myPackageB

library: {}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
snapshot: lts-24.37

packages:
- .
- subproject
- myPackageB

extra-deps:
- github: snoyberg/filelock
commit: 4f080496d8bf153fbe26e64d1f52cf73c7db25f6

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import Control.Monad ( unless )
import Data.List ( isInfixOf, isPrefixOf )
import StackTest
-- Stack generates coverage reports for main libraries and private named
-- libraries (internal libraries).
--
-- See: https://github.com/commercialhaskell/stack/issues/4105

import Control.Monad ( unless )
import Data.List ( isInfixOf, isPrefixOf )
import StackTest

main :: IO ()
main = do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
myPackage.cabal
Loading
Loading