Skip to content

Commit ddd099d

Browse files
snoybergTom Sydney Kerckhove
authored andcommitted
Detailed test support (fixes #4453)
1 parent 1994bd3 commit ddd099d

File tree

7 files changed

+139
-46
lines changed

7 files changed

+139
-46
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ Bug fixes:
118118
inside docker on Mac. See
119119
[#4506](https://github.com/commercialhaskell/stack/issues/4506)
120120
* Using `--ghc-options` with `stack script --compile` now works.
121+
* Ensure the detailed-0.9 type tests work.
122+
See [#4453](https://github.com/commercialhaskell/stack/issues/4453).
121123

122124
## v1.9.3
123125

src/Stack/Build/Execute.hs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import Crypto.Hash
2828
import Data.Attoparsec.Text hiding (try)
2929
import qualified Data.ByteArray as Mem (convert)
3030
import qualified Data.ByteString as S
31+
import qualified Data.ByteString.Lazy as BL
3132
import qualified Data.ByteString.Base64.URL as B64URL
3233
import Data.Char (isSpace)
3334
import Conduit
@@ -36,9 +37,8 @@ import qualified Data.Conduit.Filesystem as CF
3637
import qualified Data.Conduit.List as CL
3738
import Data.Conduit.Process.Typed
3839
(ExitCodeException (..), waitExitCode,
39-
useHandleOpen, setStdin, setStdout, setStderr, getStdin,
40-
createPipe, runProcess_, getStdout,
41-
getStderr, createSource)
40+
useHandleOpen, setStdin, setStdout, setStderr,
41+
runProcess_, getStdout, getStderr, createSource)
4242
import qualified Data.Conduit.Text as CT
4343
import Data.List hiding (any)
4444
import qualified Data.Map.Strict as M
@@ -84,7 +84,7 @@ import qualified System.Directory as D
8484
import System.Environment (getExecutablePath)
8585
import System.Exit (ExitCode (..))
8686
import qualified System.FilePath as FP
87-
import System.IO (hPutStr, stderr, stdout)
87+
import System.IO (stderr, stdout)
8888
import System.PosixCompat.Files (createLink, modificationTime, getFileStatus)
8989
import System.PosixCompat.Time (epochTime)
9090
import RIO.PrettyPrint
@@ -1805,16 +1805,19 @@ singleTest topts testsToRun ac ee task installedMap = do
18051805

18061806
ec <- withWorkingDir (toFilePath pkgDir) $
18071807
proc (toFilePath exePath) args $ \pc0 -> do
1808-
let pc = setStdin createPipe
1808+
stdinBS <-
1809+
if isTestTypeLib
1810+
then do
1811+
logPath <- buildLogPath package (Just stestName)
1812+
ensureDir (parent logPath)
1813+
pure $ BL.fromStrict
1814+
$ encodeUtf8 $ fromString $ show (logPath, testName)
1815+
else pure mempty
1816+
let pc = setStdin (byteStringInput stdinBS)
18091817
$ output setStdout
18101818
$ output setStderr
18111819
pc0
1812-
withProcess pc $ \p -> do
1813-
when isTestTypeLib $ do
1814-
logPath <- buildLogPath package (Just stestName)
1815-
ensureDir (parent logPath)
1816-
liftIO $ hPutStr (getStdin p) $ show (logPath, testName)
1817-
waitExitCode p
1820+
runProcess pc
18181821
-- Add a trailing newline, incase the test
18191822
-- output didn't finish with a newline.
18201823
case outputType of
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
cabal-version: 1.12
2+
3+
-- This file has been generated from package.yaml by hpack version 0.31.1.
4+
--
5+
-- see: https://github.com/sol/hpack
6+
--
7+
-- hash: 6a3d670e6f645b1ae099ce4d47325765448bfe194c0f497059a5fe3524388288
8+
9+
name: http-download
10+
version: 0.1.0.0
11+
synopsis: Verified downloads with retries
12+
category: Development
13+
homepage: https://github.com/commercialhaskell/http-download#readme
14+
bug-reports: https://github.com/commercialhaskell/http-download/issues
15+
author: Michael Snoyman
16+
maintainer: michael@snoyman.com
17+
copyright: 2018-2019 FP Complete
18+
license: MIT
19+
build-type: Simple
20+
21+
source-repository head
22+
type: git
23+
location: https://github.com/commercialhaskell/http-download
24+
25+
library
26+
exposed-modules:
27+
Network.HTTP.Download
28+
Network.HTTP.Download.Verified
29+
other-modules:
30+
Paths_http_download
31+
hs-source-dirs:
32+
src/
33+
build-depends:
34+
base
35+
, base64-bytestring
36+
, bytestring
37+
, conduit
38+
, conduit-extra
39+
, cryptonite
40+
, cryptonite-conduit
41+
, directory
42+
, exceptions
43+
, filepath
44+
, http-client
45+
, http-conduit
46+
, http-types
47+
, memory
48+
, path
49+
, path-io
50+
, retry
51+
, rio
52+
, rio-prettyprint
53+
default-language: Haskell2010
54+
55+
test-suite spec
56+
type: exitcode-stdio-1.0
57+
main-is: Spec.hs
58+
other-modules:
59+
Network.HTTP.Download.VerifiedSpec
60+
Paths_http_download
61+
hs-source-dirs:
62+
test
63+
build-depends:
64+
base
65+
, cryptonite
66+
, hspec
67+
, http-client
68+
, http-download
69+
, path
70+
, path-io
71+
, retry
72+
, rio
73+
, rio-prettyprint
74+
default-language: Haskell2010
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
cabal-version: 1.12
2+
3+
-- This file has been generated from package.yaml by hpack version 0.31.1.
4+
--
5+
-- see: https://github.com/sol/hpack
6+
--
7+
-- hash: 4695b863639ee3242a4625aad63f566d63d6a52a61d08e2792516e6219a12f45
8+
9+
name: rio-prettyprint
10+
version: 0.1.0.0
11+
synopsis: Pretty-printing for RIO
12+
category: Development
13+
homepage: https://github.com/commercialhaskell/rio-prettyprint#readme
14+
bug-reports: https://github.com/commercialhaskell/rio-prettyprint/issues
15+
author: Michael Snoyman
16+
maintainer: michael@snoyman.com
17+
copyright: 2018-2019 FP Complete
18+
license: MIT
19+
build-type: Simple
20+
21+
source-repository head
22+
type: git
23+
location: https://github.com/commercialhaskell/rio-prettyprint
24+
25+
library
26+
exposed-modules:
27+
RIO.PrettyPrint
28+
RIO.PrettyPrint.DefaultStyles
29+
RIO.PrettyPrint.StylesUpdate
30+
RIO.PrettyPrint.Types
31+
Text.PrettyPrint.Leijen.Extended
32+
other-modules:
33+
Paths_rio_prettyprint
34+
hs-source-dirs:
35+
src/
36+
build-depends:
37+
Cabal
38+
, aeson
39+
, annotated-wl-pprint
40+
, ansi-terminal
41+
, array
42+
, base
43+
, colour
44+
, mtl
45+
, path
46+
, rio
47+
, text
48+
default-language: Haskell2010

test/integration/tests/4453-detailed/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import System.Directory
44
main :: IO ()
55
main = do
66
removeDirIgnore ".stack-work"
7-
stack ["test"]
7+
stack [defaultResolverArg, "test"]

test/integration/tests/4453-detailed/files/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/integration/tests/4453-detailed/files/LICENSE

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)