-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
149 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,12 @@ | ||
{-# OPTIONS_GHC -Wall #-} | ||
|
||
module Main (main) where | ||
|
||
-- Cabal | ||
import Distribution.Simple | ||
( defaultMainWithHooks | ||
, autoconfUserHooks | ||
, UserHooks(buildHook) | ||
) | ||
import Distribution.Simple.BuildPaths | ||
( autogenComponentModulesDir | ||
, exeExtension | ||
) | ||
import Distribution.Simple.LocalBuildInfo | ||
( hostPlatform | ||
, buildDir | ||
, withTestLBI | ||
) | ||
import Distribution.Types.LocalBuildInfo | ||
( LocalBuildInfo | ||
, allTargetsInBuildOrder' | ||
) | ||
import Distribution.Types.Component | ||
( Component(CExe) ) | ||
import Distribution.Types.Executable | ||
( Executable(exeName) ) | ||
import Distribution.Types.PackageDescription | ||
( PackageDescription ) | ||
import Distribution.Types.TargetInfo | ||
( targetComponent ) | ||
import Distribution.Types.UnqualComponentName | ||
( unUnqualComponentName ) | ||
|
||
-- directory | ||
import System.Directory | ||
( createDirectoryIfMissing ) | ||
|
||
-- filepath | ||
import System.FilePath | ||
( (</>), (<.>), takeDirectory ) | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
main :: IO () | ||
main = defaultMainWithHooks processHooks | ||
|
||
-- The following code works around Cabal bug #9854. | ||
-- | ||
-- The process package has an executable component named "cli-child", | ||
-- used for testing. We want to invoke this executable when running tests; | ||
-- however, due to the Cabal bug this executable does not get added to PATH. | ||
-- To fix this, we create a "Test.Paths" module in a Custom setup script, | ||
-- which contains paths to executables used for testing. | ||
processHooks :: UserHooks | ||
processHooks = | ||
defaultConfigureHooks | ||
{ buildHook = \ pd lbi userHooks buildFlags -> | ||
withTestLBI pd lbi $ \ _testSuite clbi -> do | ||
let pathsFile = autogenComponentModulesDir lbi clbi </> "Test" </> "Paths" <.> "hs" | ||
createDirectoryIfMissing True (takeDirectory pathsFile) | ||
writeFile pathsFile $ unlines | ||
[ "module Test.Paths where" | ||
, "processInternalExes :: [(String, FilePath)]" | ||
, "processInternalExes = " ++ show (processInternalExes pd lbi) | ||
] | ||
buildHook defaultConfigureHooks pd lbi userHooks buildFlags | ||
} | ||
|
||
defaultConfigureHooks :: UserHooks | ||
defaultConfigureHooks = autoconfUserHooks | ||
|
||
processInternalExes :: PackageDescription -> LocalBuildInfo -> [(String, FilePath)] | ||
processInternalExes pd lbi = | ||
[ (toolName, toolLocation) | ||
| tgt <- allTargetsInBuildOrder' pd lbi | ||
, CExe exe <- [targetComponent tgt] | ||
, let toolName = unUnqualComponentName $ exeName exe | ||
toolLocation = | ||
buildDir lbi | ||
</> (toolName </> toolName <.> exeExtension (hostPlatform lbi)) | ||
] | ||
main = defaultMainWithHooks autoconfUserHooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{-# OPTIONS_GHC -Wall #-} | ||
|
||
module Main (main) where | ||
|
||
-- Cabal | ||
import Distribution.Simple | ||
( defaultMainWithHooks | ||
, simpleUserHooks | ||
, UserHooks(buildHook) | ||
) | ||
import Distribution.Simple.BuildPaths | ||
( autogenComponentModulesDir | ||
, exeExtension | ||
) | ||
import Distribution.Simple.LocalBuildInfo | ||
( hostPlatform | ||
, buildDir | ||
, withTestLBI | ||
) | ||
import Distribution.Types.LocalBuildInfo | ||
( LocalBuildInfo | ||
, allTargetsInBuildOrder' | ||
) | ||
import Distribution.Types.Component | ||
( Component(CExe) ) | ||
import Distribution.Types.Executable | ||
( Executable(exeName) ) | ||
import Distribution.Types.PackageDescription | ||
( PackageDescription ) | ||
import Distribution.Types.TargetInfo | ||
( targetComponent ) | ||
import Distribution.Types.UnqualComponentName | ||
( unUnqualComponentName ) | ||
|
||
-- directory | ||
import System.Directory | ||
( createDirectoryIfMissing ) | ||
|
||
-- filepath | ||
import System.FilePath | ||
( (</>), (<.>), takeDirectory ) | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
main :: IO () | ||
main = defaultMainWithHooks testProcessHooks | ||
|
||
-- The following code works around Cabal bug #9854. | ||
-- | ||
-- The process-tests package has an executable component named "cli-child", | ||
-- used for testing. We want to invoke this executable when running tests; | ||
-- however, due to the Cabal bug this executable does not get added to PATH. | ||
-- To fix this, we create a "Test.Paths" module in a Custom setup script, | ||
-- which contains paths to executables used for testing. | ||
testProcessHooks :: UserHooks | ||
testProcessHooks = | ||
simpleUserHooks | ||
{ buildHook = \ pd lbi userHooks buildFlags -> | ||
withTestLBI pd lbi $ \ _testSuite clbi -> do | ||
let pathsFile = autogenComponentModulesDir lbi clbi </> "Test" </> "Paths" <.> "hs" | ||
createDirectoryIfMissing True (takeDirectory pathsFile) | ||
writeFile pathsFile $ unlines | ||
[ "module Test.Paths where" | ||
, "processInternalExes :: [(String, FilePath)]" | ||
, "processInternalExes = " ++ show (processInternalExes pd lbi) | ||
] | ||
buildHook simpleUserHooks pd lbi userHooks buildFlags | ||
} | ||
|
||
processInternalExes :: PackageDescription -> LocalBuildInfo -> [(String, FilePath)] | ||
processInternalExes pd lbi = | ||
[ (toolName, toolLocation) | ||
| tgt <- allTargetsInBuildOrder' pd lbi | ||
, CExe exe <- [targetComponent tgt] | ||
, let toolName = unUnqualComponentName $ exeName exe | ||
toolLocation = | ||
buildDir lbi | ||
</> (toolName </> toolName <.> exeExtension (hostPlatform lbi)) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
cabal-version: 2.4 | ||
name: process-tests | ||
version: 1.6.19.0 | ||
license: BSD-3-Clause | ||
license-file: ../LICENSE | ||
maintainer: libraries@haskell.org | ||
bug-reports: https://github.com/haskell/process/issues | ||
synopsis: Testing package for the process library | ||
category: System | ||
build-type: Custom | ||
description: | ||
This package contains the testing infrastructure for the process library | ||
|
||
source-repository head | ||
type: git | ||
location: https://github.com/haskell/process.git | ||
subdir: tests | ||
|
||
custom-setup | ||
setup-depends: | ||
base >= 4.10 && < 4.20, | ||
directory >= 1.1 && < 1.4, | ||
filepath >= 1.2 && < 1.6, | ||
Cabal >= 2.4 && < 3.12, | ||
|
||
-- Test executable for the CommunicationHandle functionality | ||
executable cli-child | ||
default-language: Haskell2010 | ||
hs-source-dirs: cli-child | ||
main-is: main.hs | ||
build-depends: base >= 4 && < 5 | ||
, deepseq | ||
, process | ||
ghc-options: -threaded -rtsopts | ||
|
||
test-suite test | ||
default-language: Haskell2010 | ||
hs-source-dirs: . | ||
main-is: main.hs | ||
type: exitcode-stdio-1.0 | ||
-- Add otherwise redundant bounds on base since GHC's build system runs | ||
-- `cabal check`, which mandates bounds on base. | ||
build-depends: base >= 4 && < 5 | ||
, bytestring | ||
, deepseq | ||
, directory | ||
, filepath | ||
, process == 1.6.19.0 | ||
build-tool-depends: process-tests:cli-child | ||
ghc-options: -threaded -rtsopts -with-rtsopts "-N" | ||
other-modules: Test.Paths | ||
autogen-modules: Test.Paths | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resolver: ghc-9.2.3 | ||
|
||
extra-deps: | ||
- .. | ||
- Cabal-3.10.2.0 | ||
|
||
allow-newer: True | ||
allow-newer-deps: | ||
- Cabal |