diff --git a/ChangeLog.md b/ChangeLog.md index 6138507b8b..22acc59333 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -118,6 +118,8 @@ Bug fixes: inside docker on Mac. See [#4506](https://github.com/commercialhaskell/stack/issues/4506) * Using `--ghc-options` with `stack script --compile` now works. +* Ensure the detailed-0.9 type tests work. + See [#4453](https://github.com/commercialhaskell/stack/issues/4453). ## v1.9.3 diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index 7d84c3f39b..c342df45f1 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -28,6 +28,7 @@ import Crypto.Hash import Data.Attoparsec.Text hiding (try) import qualified Data.ByteArray as Mem (convert) import qualified Data.ByteString as S +import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Base64.URL as B64URL import Data.Char (isSpace) import Conduit @@ -36,9 +37,8 @@ import qualified Data.Conduit.Filesystem as CF import qualified Data.Conduit.List as CL import Data.Conduit.Process.Typed (ExitCodeException (..), waitExitCode, - useHandleOpen, setStdin, setStdout, setStderr, getStdin, - createPipe, runProcess_, getStdout, - getStderr, createSource) + useHandleOpen, setStdin, setStdout, setStderr, + runProcess_, getStdout, getStderr, createSource) import qualified Data.Conduit.Text as CT import Data.List hiding (any) import qualified Data.Map.Strict as M @@ -84,7 +84,7 @@ import qualified System.Directory as D import System.Environment (getExecutablePath) import System.Exit (ExitCode (..)) import qualified System.FilePath as FP -import System.IO (hPutStr, stderr, stdout) +import System.IO (stderr, stdout) import System.PosixCompat.Files (createLink, modificationTime, getFileStatus) import System.PosixCompat.Time (epochTime) import RIO.PrettyPrint @@ -1805,16 +1805,19 @@ singleTest topts testsToRun ac ee task installedMap = do ec <- withWorkingDir (toFilePath pkgDir) $ proc (toFilePath exePath) args $ \pc0 -> do - let pc = setStdin createPipe + stdinBS <- + if isTestTypeLib + then do + logPath <- buildLogPath package (Just stestName) + ensureDir (parent logPath) + pure $ BL.fromStrict + $ encodeUtf8 $ fromString $ show (logPath, testName) + else pure mempty + let pc = setStdin (byteStringInput stdinBS) $ output setStdout $ output setStderr pc0 - withProcess pc $ \p -> do - when isTestTypeLib $ do - logPath <- buildLogPath package (Just stestName) - ensureDir (parent logPath) - liftIO $ hPutStr (getStdin p) $ show (logPath, testName) - waitExitCode p + runProcess pc -- Add a trailing newline, incase the test -- output didn't finish with a newline. case outputType of diff --git a/subs/http-download/http-download.cabal b/subs/http-download/http-download.cabal new file mode 100644 index 0000000000..8a893ab258 --- /dev/null +++ b/subs/http-download/http-download.cabal @@ -0,0 +1,74 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.1. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 6a3d670e6f645b1ae099ce4d47325765448bfe194c0f497059a5fe3524388288 + +name: http-download +version: 0.1.0.0 +synopsis: Verified downloads with retries +category: Development +homepage: https://github.com/commercialhaskell/http-download#readme +bug-reports: https://github.com/commercialhaskell/http-download/issues +author: Michael Snoyman +maintainer: michael@snoyman.com +copyright: 2018-2019 FP Complete +license: MIT +build-type: Simple + +source-repository head + type: git + location: https://github.com/commercialhaskell/http-download + +library + exposed-modules: + Network.HTTP.Download + Network.HTTP.Download.Verified + other-modules: + Paths_http_download + hs-source-dirs: + src/ + build-depends: + base + , base64-bytestring + , bytestring + , conduit + , conduit-extra + , cryptonite + , cryptonite-conduit + , directory + , exceptions + , filepath + , http-client + , http-conduit + , http-types + , memory + , path + , path-io + , retry + , rio + , rio-prettyprint + default-language: Haskell2010 + +test-suite spec + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + Network.HTTP.Download.VerifiedSpec + Paths_http_download + hs-source-dirs: + test + build-depends: + base + , cryptonite + , hspec + , http-client + , http-download + , path + , path-io + , retry + , rio + , rio-prettyprint + default-language: Haskell2010 diff --git a/subs/rio-prettyprint/rio-prettyprint.cabal b/subs/rio-prettyprint/rio-prettyprint.cabal new file mode 100644 index 0000000000..da3b19d3ac --- /dev/null +++ b/subs/rio-prettyprint/rio-prettyprint.cabal @@ -0,0 +1,48 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.1. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 4695b863639ee3242a4625aad63f566d63d6a52a61d08e2792516e6219a12f45 + +name: rio-prettyprint +version: 0.1.0.0 +synopsis: Pretty-printing for RIO +category: Development +homepage: https://github.com/commercialhaskell/rio-prettyprint#readme +bug-reports: https://github.com/commercialhaskell/rio-prettyprint/issues +author: Michael Snoyman +maintainer: michael@snoyman.com +copyright: 2018-2019 FP Complete +license: MIT +build-type: Simple + +source-repository head + type: git + location: https://github.com/commercialhaskell/rio-prettyprint + +library + exposed-modules: + RIO.PrettyPrint + RIO.PrettyPrint.DefaultStyles + RIO.PrettyPrint.StylesUpdate + RIO.PrettyPrint.Types + Text.PrettyPrint.Leijen.Extended + other-modules: + Paths_rio_prettyprint + hs-source-dirs: + src/ + build-depends: + Cabal + , aeson + , annotated-wl-pprint + , ansi-terminal + , array + , base + , colour + , mtl + , path + , rio + , text + default-language: Haskell2010 diff --git a/test/integration/tests/4453-detailed/Main.hs b/test/integration/tests/4453-detailed/Main.hs new file mode 100644 index 0000000000..8f13e72bcd --- /dev/null +++ b/test/integration/tests/4453-detailed/Main.hs @@ -0,0 +1,7 @@ +import StackTest +import System.Directory + +main :: IO () +main = do + removeDirIgnore ".stack-work" + stack [defaultResolverArg, "test"] diff --git a/test/integration/tests/4453-detailed/files/src/Lib.hs b/test/integration/tests/4453-detailed/files/src/Lib.hs new file mode 100644 index 0000000000..d36ff2714d --- /dev/null +++ b/test/integration/tests/4453-detailed/files/src/Lib.hs @@ -0,0 +1,6 @@ +module Lib + ( someFunc + ) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/test/integration/tests/4453-detailed/files/stack.yaml b/test/integration/tests/4453-detailed/files/stack.yaml new file mode 100644 index 0000000000..9651d88a3f --- /dev/null +++ b/test/integration/tests/4453-detailed/files/stack.yaml @@ -0,0 +1,3 @@ +resolver: lts-11.22 +packages: +- '.' diff --git a/test/integration/tests/4453-detailed/files/test-detailed-example.cabal b/test/integration/tests/4453-detailed/files/test-detailed-example.cabal new file mode 100644 index 0000000000..87a973ce4d --- /dev/null +++ b/test/integration/tests/4453-detailed/files/test-detailed-example.cabal @@ -0,0 +1,18 @@ +name: test-detailed-example +version: 0.1.0.0 +build-type: Simple +cabal-version: >=1.20 + +library + hs-source-dirs: src + exposed-modules: Lib + build-depends: base >= 4.7 && < 5 + default-language: Haskell2010 + +test-suite test-detailed-example-test + type: detailed-0.9 + hs-source-dirs: test + test-module: Spec + build-depends: base >= 4.7, + Cabal >= 1.20 + default-language: Haskell2010 diff --git a/test/integration/tests/4453-detailed/files/test/Spec.hs b/test/integration/tests/4453-detailed/files/test/Spec.hs new file mode 100644 index 0000000000..78acaf4517 --- /dev/null +++ b/test/integration/tests/4453-detailed/files/test/Spec.hs @@ -0,0 +1,21 @@ +module Spec (tests) where + +import Distribution.TestSuite + +tests :: IO [Test] +tests = do + return [ + test "foo" Pass + , test "bar" (Fail "It did not work out!") + ] + +test :: String -> Result -> Test +test name r = Test t + where + t = TestInstance { + run = return (Finished r) + , name = name + , tags = [] + , options = [] + , setOption = \_ _ -> Right t + }