Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cabal: Honour -working-dir flag when running test executables #10725

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Cabal/src/Distribution/Simple/Test/ExeV10.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ runTest pkg_descr lbi clbi hpcMarkupInfo flags suite = do
-- drain the output.
evaluate (force logText)

let mbWorkDir =
interpretSymbolicPathCWD
<$> flagToMaybe (setupWorkingDir (testCommonFlags flags))

(exit, logText) <- case testWrapper flags of
Flag path ->
rawSystemIOWithEnvAndAction
verbosity
path
(cmd : opts)
Nothing
mbWorkDir
(Just shellEnv')
getLogText
-- these handles are automatically closed
Expand All @@ -143,7 +147,7 @@ runTest pkg_descr lbi clbi hpcMarkupInfo flags suite = do
verbosity
cmd
opts
Nothing
mbWorkDir
(Just shellEnv')
getLogText
-- these handles are automatically closed
Expand Down
3 changes: 3 additions & 0 deletions cabal-testsuite/PackageTests/TestChangeDir/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages: regression-simple

tests: True
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/TestChangeDir/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

main = cabalTest . recordMode DoNotRecord $ do
-- Building a target that contains whitespace
cabal "test" ["regression-simple"]
cabal "bench" ["regression-simple"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Revision history for regression-simple

## 0.1.0.0 -- YYYY-mm-dd

* First version. Released on an unsuspecting world.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Main (main) where

main :: IO ()
main = readFile "do-i-exist.txt" >>= print
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I exist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cabal-version: 3.14
name: regression-simple
version: 0.1.0.0
license: NONE
author: Matthew Pickering
maintainer: [email protected]
build-type: Simple
extra-doc-files: CHANGELOG.md

common warnings
ghc-options: -Wall

test-suite regression-simple-test
import: warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs
build-depends: base

benchmark regression-simple-bench
import: warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: bench
main-is: Main.hs
build-depends: base
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Main (main) where

main :: IO ()
main = readFile "do-i-exist.txt" >>= print
12 changes: 12 additions & 0 deletions changelog.d/pr-10725
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
synopsis: Honour the `-working-dir` flag when executing testsuite executables.
packages: Cabal
prs: #10725
issues: #10704
significance:

description: {

Honour the `-working-dir` flag when executing testsuite executables. This fixes a
regression in Cabal-3.14.0.0.

}
Loading