Skip to content

Commit 15f86f9

Browse files
committed
Cabal: Honour -working-dir flag when running test executables
A simple fix to run the test executable in the `-working-dir`. Fixes haskell#10704
1 parent 1c7243f commit 15f86f9

File tree

7 files changed

+40
-2
lines changed

7 files changed

+40
-2
lines changed

Cabal/src/Distribution/Simple/Test/ExeV10.hs

+5-2
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,16 @@ runTest pkg_descr lbi clbi hpcMarkupInfo flags suite = do
125125
-- drain the output.
126126
evaluate (force logText)
127127

128+
let mbWorkDir = interpretSymbolicPathCWD
129+
<$> flagToMaybe (setupWorkingDir (testCommonFlags flags))
130+
128131
(exit, logText) <- case testWrapper flags of
129132
Flag path ->
130133
rawSystemIOWithEnvAndAction
131134
verbosity
132135
path
133136
(cmd : opts)
134-
Nothing
137+
mbWorkDir
135138
(Just shellEnv')
136139
getLogText
137140
-- these handles are automatically closed
@@ -143,7 +146,7 @@ runTest pkg_descr lbi clbi hpcMarkupInfo flags suite = do
143146
verbosity
144147
cmd
145148
opts
146-
Nothing
149+
mbWorkDir
147150
(Just shellEnv')
148151
getLogText
149152
-- these handles are automatically closed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: regression-simple
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
main = cabalTest . recordMode DoNotRecord $ do
4+
-- Building a target that contains whitespace
5+
cabal "test" ["regression-simple"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for regression-simple
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I exist
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cabal-version: 3.14
2+
name: regression-simple
3+
version: 0.1.0.0
4+
license: NONE
5+
author: Matthew Pickering
6+
maintainer: [email protected]
7+
build-type: Simple
8+
extra-doc-files: CHANGELOG.md
9+
10+
common warnings
11+
ghc-options: -Wall
12+
13+
test-suite regression-simple-test
14+
import: warnings
15+
default-language: Haskell2010
16+
type: exitcode-stdio-1.0
17+
hs-source-dirs: test
18+
main-is: Main.hs
19+
build-depends: base ^>=4.20.0.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Main (main) where
2+
3+
main :: IO ()
4+
main = readFile "do-i-exist.txt" >>= print

0 commit comments

Comments
 (0)