Skip to content

Commit 3bfd51e

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 3bfd51e

File tree

9 files changed

+68
-2
lines changed

9 files changed

+68
-2
lines changed

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

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

128+
let mbWorkDir =
129+
interpretSymbolicPathCWD
130+
<$> flagToMaybe (setupWorkingDir (testCommonFlags flags))
131+
128132
(exit, logText) <- case testWrapper flags of
129133
Flag path ->
130134
rawSystemIOWithEnvAndAction
131135
verbosity
132136
path
133137
(cmd : opts)
134-
Nothing
138+
mbWorkDir
135139
(Just shellEnv')
136140
getLogText
137141
-- these handles are automatically closed
@@ -143,7 +147,7 @@ runTest pkg_descr lbi clbi hpcMarkupInfo flags suite = do
143147
verbosity
144148
cmd
145149
opts
146-
Nothing
150+
mbWorkDir
147151
(Just shellEnv')
148152
getLogText
149153
-- these handles are automatically closed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages: regression-simple
2+
3+
tests: True
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Test.Cabal.Prelude
2+
3+
main = cabalTest . recordMode DoNotRecord $ do
4+
-- Building a target that contains whitespace
5+
cabal "test" ["regression-simple"]
6+
cabal "bench" ["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,4 @@
1+
module Main (main) where
2+
3+
main :: IO ()
4+
main = readFile "do-i-exist.txt" >>= print
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,27 @@
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
20+
21+
benchmark regression-simple-bench
22+
import: warnings
23+
default-language: Haskell2010
24+
type: exitcode-stdio-1.0
25+
hs-source-dirs: bench
26+
main-is: Main.hs
27+
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

changelog.d/pr-10725

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
synopsis: Honour the `-working-dir` flag when executing testsuite executables.
2+
packages: Cabal
3+
prs: #10725
4+
issues: #10704
5+
significance:
6+
7+
description: {
8+
9+
Honour the `-working-dir` flag when executing testsuite executables. This fixes a
10+
regression in Cabal-3.14.0.0.
11+
12+
}

0 commit comments

Comments
 (0)