Skip to content

Commit 5580ce1

Browse files
committed
Add cabal new-build tests for shellFor
1 parent 1704cac commit 5580ce1

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

test/regen.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,9 @@ writeScript "regen-tests.sh" ''
5757
cd stack-simple
5858
stack-to-nix -o .
5959
cd ..
60+
61+
cd shell-for
62+
cabal_configure
63+
plan-to-nix -o . --plan-json dist-newstyle/cache/plan.json --cabal-project cabal.project
64+
cd ..
6065
''

test/shell-for/default.nix

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
1-
{ stdenv, cabal-install, mkStackSnapshotPkgSet }:
1+
{ stdenv, cabal-install, mkStackSnapshotPkgSet, mkCabalProjectPkgSet }:
22

33
with stdenv.lib;
44

55
let
6-
pkgSet = mkStackSnapshotPkgSet {
7-
resolver = "lts-12.21";
8-
# Work around a mismatch between stackage metadata and the
9-
# libraries shipped with GHC.
10-
# https://github.com/commercialhaskell/stackage/issues/4466
11-
pkg-def-extras = [(hackage: {
12-
packages = {
13-
"transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
14-
"process" = (((hackage.process)."1.6.5.0").revisions).default;
15-
};
16-
})];
6+
pkgSet = {
7+
stack = mkStackSnapshotPkgSet {
8+
resolver = "lts-12.21";
9+
# Work around a mismatch between stackage metadata and the
10+
# libraries shipped with GHC.
11+
# https://github.com/commercialhaskell/stackage/issues/4466
12+
pkg-def-extras = [(hackage: {
13+
packages = {
14+
"transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
15+
"process" = (((hackage.process)."1.6.5.0").revisions).default;
16+
};
17+
})];
18+
};
19+
20+
cabal = mkCabalProjectPkgSet {
21+
plan-pkgs = import ./pkgs.nix;
22+
pkg-def-extras = [{
23+
pkga = ./.plan.nix/pkga.nix;
24+
pkgb = ./.plan.nix/pkgb.nix;
25+
}];
26+
};
1727
};
1828

19-
env = pkgSet.config.hsPkgs.shellFor {
20-
packages = ps: with ps; [ conduit conduit-extra resourcet ];
21-
withHoogle = true;
22-
# This adds cabal-install to the shell, which helps tests because
23-
# they use a nix-shell --pure. Normally you would BYO cabal-install.
24-
buildInputs = [ cabal-install ];
29+
env = {
30+
stack = pkgSet.stack.config.hsPkgs.shellFor {
31+
packages = ps: with ps; [ conduit conduit-extra resourcet ];
32+
withHoogle = true;
33+
# This adds cabal-install to the shell, which helps tests because
34+
# they use a nix-shell --pure. Normally you would BYO cabal-install.
35+
buildInputs = [ cabal-install ];
36+
};
37+
38+
cabal = pkgSet.cabal.config.hsPkgs.shellFor {
39+
packages = ps: with ps; [ pkga pkgb ];
40+
};
2541
};
2642

2743
in
@@ -33,7 +49,7 @@ in
3349
# test shell-for with an example program
3450
3551
printf "checking that the shell env has the dependencies...\n" >& 2
36-
${env.ghc}/bin/runghc ${./conduit.hs}
52+
${env.stack.ghc}/bin/runghc ${./pkgb/src/conduit.hs}
3753
3854
touch $out
3955
'';

test/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ echo >& 2
5757
printf "*** Checking shellFor works with a Stackage snapshot...\n" >& 2
5858
nix-shell $NIX_BUILD_ARGS \
5959
--pure ./default.nix \
60-
-A shell-for.env \
60+
-A shell-for.env.stack \
6161
--run 'cd shell-for && runghc conduit.hs'
6262
echo >& 2
6363

0 commit comments

Comments
 (0)