Skip to content

Commit 1c17566

Browse files
committed
Try to fix CI by splitting package
1 parent 1c76258 commit 1c17566

File tree

7 files changed

+149
-111
lines changed

7 files changed

+149
-111
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@ jobs:
4343
rm -rf C:/ProgramData/Chocolatey/bin/ghc*
4444
stack ${{ matrix.args }} exec pacman -- --sync --refresh --noconfirm autoconf
4545
fi
46-
stack test --bench --no-run-benchmarks --haddock --no-terminal ${{ matrix.args }}
46+
stack build
4747
stack sdist --test-tarball
48+
cd test
49+
stack test --bench --no-run-benchmarks --haddock --no-terminal ${{ matrix.args }}

Setup.hs

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,12 @@
1-
{-# OPTIONS_GHC -Wall #-}
2-
31
module Main (main) where
42

53
-- Cabal
64
import Distribution.Simple
75
( defaultMainWithHooks
86
, autoconfUserHooks
9-
, UserHooks(buildHook)
10-
)
11-
import Distribution.Simple.BuildPaths
12-
( autogenComponentModulesDir
13-
, exeExtension
14-
)
15-
import Distribution.Simple.LocalBuildInfo
16-
( hostPlatform
17-
, buildDir
18-
, withTestLBI
197
)
20-
import Distribution.Types.LocalBuildInfo
21-
( LocalBuildInfo
22-
, allTargetsInBuildOrder'
23-
)
24-
import Distribution.Types.Component
25-
( Component(CExe) )
26-
import Distribution.Types.Executable
27-
( Executable(exeName) )
28-
import Distribution.Types.PackageDescription
29-
( PackageDescription )
30-
import Distribution.Types.TargetInfo
31-
( targetComponent )
32-
import Distribution.Types.UnqualComponentName
33-
( unUnqualComponentName )
34-
35-
-- directory
36-
import System.Directory
37-
( createDirectoryIfMissing )
38-
39-
-- filepath
40-
import System.FilePath
41-
( (</>), (<.>), takeDirectory )
428

439
--------------------------------------------------------------------------------
4410

4511
main :: IO ()
46-
main = defaultMainWithHooks processHooks
47-
48-
-- The following code works around Cabal bug #9854.
49-
--
50-
-- The process package has an executable component named "cli-child",
51-
-- used for testing. We want to invoke this executable when running tests;
52-
-- however, due to the Cabal bug this executable does not get added to PATH.
53-
-- To fix this, we create a "Test.Paths" module in a Custom setup script,
54-
-- which contains paths to executables used for testing.
55-
processHooks :: UserHooks
56-
processHooks =
57-
defaultConfigureHooks
58-
{ buildHook = \ pd lbi userHooks buildFlags ->
59-
withTestLBI pd lbi $ \ _testSuite clbi -> do
60-
let pathsFile = autogenComponentModulesDir lbi clbi </> "Test" </> "Paths" <.> "hs"
61-
createDirectoryIfMissing True (takeDirectory pathsFile)
62-
writeFile pathsFile $ unlines
63-
[ "module Test.Paths where"
64-
, "processInternalExes :: [(String, FilePath)]"
65-
, "processInternalExes = " ++ show (processInternalExes pd lbi)
66-
]
67-
buildHook defaultConfigureHooks pd lbi userHooks buildFlags
68-
}
69-
70-
defaultConfigureHooks :: UserHooks
71-
defaultConfigureHooks = autoconfUserHooks
72-
73-
processInternalExes :: PackageDescription -> LocalBuildInfo -> [(String, FilePath)]
74-
processInternalExes pd lbi =
75-
[ (toolName, toolLocation)
76-
| tgt <- allTargetsInBuildOrder' pd lbi
77-
, CExe exe <- [targetComponent tgt]
78-
, let toolName = unUnqualComponentName $ exeName exe
79-
toolLocation =
80-
buildDir lbi
81-
</> (toolName </> toolName <.> exeExtension (hostPlatform lbi))
82-
]
12+
main = defaultMainWithHooks autoconfUserHooks

process.cabal

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ maintainer: [email protected]
88
bug-reports: https://github.com/haskell/process/issues
99
synopsis: Process libraries
1010
category: System
11-
build-type: Custom
11+
build-type: Configure
1212
description:
1313
This package contains libraries for dealing with system processes.
1414
.
@@ -39,13 +39,6 @@ source-repository head
3939
type: git
4040
location: https://github.com/haskell/process.git
4141

42-
custom-setup
43-
setup-depends:
44-
base >= 4.10 && < 4.20,
45-
directory >= 1.1 && < 1.4,
46-
filepath >= 1.2 && < 1.6,
47-
Cabal >= 2.4 && < 3.12,
48-
4942
library
5043
default-language: Haskell2010
5144
other-extensions:
@@ -98,33 +91,3 @@ library
9891
directory >= 1.1 && < 1.4,
9992
filepath >= 1.2 && < 1.6,
10093
deepseq >= 1.1 && < 1.6
101-
102-
-- Test executable for the CommunicationHandle functionality
103-
executable cli-child
104-
default-language: Haskell2010
105-
hs-source-dirs: test/cli-child
106-
main-is: main.hs
107-
build-depends: base >= 4 && < 5
108-
, deepseq
109-
, process
110-
ghc-options: -threaded -rtsopts
111-
112-
test-suite test
113-
default-language: Haskell2010
114-
hs-source-dirs: test
115-
main-is: main.hs
116-
type: exitcode-stdio-1.0
117-
-- Add otherwise redundant bounds on base since GHC's build system runs
118-
-- `cabal check`, which mandates bounds on base.
119-
build-depends: base >= 4 && < 5
120-
, bytestring
121-
, deepseq
122-
, directory
123-
, filepath
124-
, process
125-
-- The autogenerated Test.Paths module works around Cabal bug #9854.
126-
-- See the custom Setup for details.
127-
other-modules: Test.Paths
128-
autogen-modules: Test.Paths
129-
build-tool-depends: process:cli-child
130-
ghc-options: -threaded -rtsopts -with-rtsopts "-N"

test/Setup.hs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{-# OPTIONS_GHC -Wall #-}
2+
3+
module Main (main) where
4+
5+
-- Cabal
6+
import Distribution.Simple
7+
( defaultMainWithHooks
8+
, simpleUserHooks
9+
, UserHooks(buildHook)
10+
)
11+
import Distribution.Simple.BuildPaths
12+
( autogenComponentModulesDir
13+
, exeExtension
14+
)
15+
import Distribution.Simple.LocalBuildInfo
16+
( hostPlatform
17+
, buildDir
18+
, withTestLBI
19+
)
20+
import Distribution.Types.LocalBuildInfo
21+
( LocalBuildInfo
22+
, allTargetsInBuildOrder'
23+
)
24+
import Distribution.Types.Component
25+
( Component(CExe) )
26+
import Distribution.Types.Executable
27+
( Executable(exeName) )
28+
import Distribution.Types.PackageDescription
29+
( PackageDescription )
30+
import Distribution.Types.TargetInfo
31+
( targetComponent )
32+
import Distribution.Types.UnqualComponentName
33+
( unUnqualComponentName )
34+
35+
-- directory
36+
import System.Directory
37+
( createDirectoryIfMissing )
38+
39+
-- filepath
40+
import System.FilePath
41+
( (</>), (<.>), takeDirectory )
42+
43+
--------------------------------------------------------------------------------
44+
45+
main :: IO ()
46+
main = defaultMainWithHooks testProcessHooks
47+
48+
-- The following code works around Cabal bug #9854.
49+
--
50+
-- The process-tests package has an executable component named "cli-child",
51+
-- used for testing. We want to invoke this executable when running tests;
52+
-- however, due to the Cabal bug this executable does not get added to PATH.
53+
-- To fix this, we create a "Test.Paths" module in a Custom setup script,
54+
-- which contains paths to executables used for testing.
55+
testProcessHooks :: UserHooks
56+
testProcessHooks =
57+
simpleUserHooks
58+
{ buildHook = \ pd lbi userHooks buildFlags ->
59+
withTestLBI pd lbi $ \ _testSuite clbi -> do
60+
let pathsFile = autogenComponentModulesDir lbi clbi </> "Test" </> "Paths" <.> "hs"
61+
createDirectoryIfMissing True (takeDirectory pathsFile)
62+
writeFile pathsFile $ unlines
63+
[ "module Test.Paths where"
64+
, "processInternalExes :: [(String, FilePath)]"
65+
, "processInternalExes = " ++ show (processInternalExes pd lbi)
66+
]
67+
buildHook simpleUserHooks pd lbi userHooks buildFlags
68+
}
69+
70+
processInternalExes :: PackageDescription -> LocalBuildInfo -> [(String, FilePath)]
71+
processInternalExes pd lbi =
72+
[ (toolName, toolLocation)
73+
| tgt <- allTargetsInBuildOrder' pd lbi
74+
, CExe exe <- [targetComponent tgt]
75+
, let toolName = unUnqualComponentName $ exeName exe
76+
toolLocation =
77+
buildDir lbi
78+
</> (toolName </> toolName <.> exeExtension (hostPlatform lbi))
79+
]

test/cli-child/main.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ main = do
4242
hPutStr hWrite output
4343
putStrLn "cli-child }"
4444
hClose hWrite
45-
_ -> error "expected two CommunicationHandle arguments"
45+
_ -> error $
46+
unlines [ "expected two CommunicationHandle arguments, but got:"
47+
, show args ]

test/process-tests.cabal

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
cabal-version: 2.4
2+
name: process-tests
3+
version: 1.6.19.0
4+
license: BSD-3-Clause
5+
license-file: ../LICENSE
6+
maintainer: [email protected]
7+
bug-reports: https://github.com/haskell/process/issues
8+
synopsis: Testing package for the process library
9+
category: System
10+
build-type: Custom
11+
description:
12+
This package contains the testing infrastructure for the process library
13+
14+
source-repository head
15+
type: git
16+
location: https://github.com/haskell/process.git
17+
subdir: tests
18+
19+
custom-setup
20+
setup-depends:
21+
base >= 4.10 && < 4.20,
22+
directory >= 1.1 && < 1.4,
23+
filepath >= 1.2 && < 1.6,
24+
Cabal >= 2.4 && < 3.12,
25+
26+
-- Test executable for the CommunicationHandle functionality
27+
executable cli-child
28+
default-language: Haskell2010
29+
hs-source-dirs: cli-child
30+
main-is: main.hs
31+
build-depends: base >= 4 && < 5
32+
, deepseq
33+
, process
34+
ghc-options: -threaded -rtsopts
35+
36+
test-suite test
37+
default-language: Haskell2010
38+
hs-source-dirs: .
39+
main-is: main.hs
40+
type: exitcode-stdio-1.0
41+
-- Add otherwise redundant bounds on base since GHC's build system runs
42+
-- `cabal check`, which mandates bounds on base.
43+
build-depends: base >= 4 && < 5
44+
, bytestring
45+
, deepseq
46+
, directory
47+
, filepath
48+
, process == 1.6.19.0
49+
build-tool-depends: process-tests:cli-child
50+
ghc-options: -threaded -rtsopts -with-rtsopts "-N"
51+
other-modules: Test.Paths
52+
autogen-modules: Test.Paths
53+

test/stack.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resolver: ghc-9.2.3
2+
3+
extra-deps:
4+
- ..
5+
- Cabal-3.10.2.0
6+
7+
allow-newer: True
8+
allow-newer-deps:
9+
- Cabal

0 commit comments

Comments
 (0)