Skip to content

Commit

Permalink
Detailed test support (fixes #4453)
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg authored and Tom Sydney Kerckhove committed Jan 28, 2019
1 parent 1994bd3 commit ddd099d
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 46 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 14 additions & 11 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
74 changes: 74 additions & 0 deletions subs/http-download/http-download.cabal
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions subs/rio-prettyprint/rio-prettyprint.cabal
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test/integration/tests/4453-detailed/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import System.Directory
main :: IO ()
main = do
removeDirIgnore ".stack-work"
stack ["test"]
stack [defaultResolverArg, "test"]
4 changes: 0 additions & 4 deletions test/integration/tests/4453-detailed/files/.gitignore

This file was deleted.

30 changes: 0 additions & 30 deletions test/integration/tests/4453-detailed/files/LICENSE

This file was deleted.

0 comments on commit ddd099d

Please sign in to comment.