mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-10-10 14:48:13 +03:00
tests: Add more tests for "all" component merging
- Make the cabal-simple executable depend on the library component -- a better exercise for the merged all component build. - Test building cabal-simple with "cabal new-build" in nix-shell. - Check the contents of components.all.depends for the with-packages test.
This commit is contained in:
parent
70f01c2029
commit
33e8d115f7
@ -30,6 +30,7 @@ executable cabal-simple
|
||||
-- other-modules:
|
||||
-- other-extensions:
|
||||
build-depends: base >=4.11 && <4.12
|
||||
, cabal-simple
|
||||
, extra
|
||||
, optparse-applicative
|
||||
-- hs-source-dirs:
|
||||
|
@ -36,6 +36,7 @@
|
||||
"cabal-simple" = {
|
||||
depends = [
|
||||
(hsPkgs.base)
|
||||
(hsPkgs.cabal-simple)
|
||||
(hsPkgs.extra)
|
||||
(hsPkgs.optparse-applicative)
|
||||
];
|
||||
|
@ -2,11 +2,16 @@
|
||||
{ pkgs
|
||||
, haskell
|
||||
, stdenv
|
||||
, util
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
## steps to generate local files
|
||||
# 1. cabal-to-nix cabal-simple.cabal > cabal-simple.nix
|
||||
# 2. cabal new-build
|
||||
# 3. plan-to-nix ./dist-newstyle/cache/plan.json > plan.nix
|
||||
pkgSet = haskell.mkPkgSet {
|
||||
inherit pkgs;
|
||||
pkg-def = import ./plan.nix;
|
||||
@ -49,9 +54,14 @@ in
|
||||
'';
|
||||
|
||||
meta.platforms = platforms.all;
|
||||
} // { inherit (packages) cabal-simple; inherit pkgSet; }
|
||||
|
||||
## steps to generate local files
|
||||
# 1. cabal-to-nix cabal-simple.cabal > cabal-simple.nix
|
||||
# 2. cabal new-build
|
||||
# 3. plan-to-nix ./dist-newstyle/cache/plan.json > plan.nix
|
||||
passthru = {
|
||||
inherit (packages) cabal-simple;
|
||||
inherit pkgSet;
|
||||
|
||||
# Used for testing externally with nix-shell (../tests.sh).
|
||||
# This just adds cabal-install to the existing shells.
|
||||
test-shell = util.addCabalInstall packages.cabal-simple.components.all;
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -15,10 +15,12 @@ let
|
||||
|
||||
haskellLib = let hl = import ../lib { inherit lib; haskellLib = hl; }; in hl;
|
||||
|
||||
util = callPackage ./util.nix {};
|
||||
|
||||
in {
|
||||
cabal-simple = callPackage ./cabal-simple { inherit haskell; };
|
||||
cabal-simple = callPackage ./cabal-simple { inherit haskell util; };
|
||||
cabal-22 = callPackage ./cabal-22 { inherit haskell; };
|
||||
with-packages = callPackage ./with-packages { inherit haskell; };
|
||||
with-packages = callPackage ./with-packages { inherit haskell util; };
|
||||
|
||||
# Run unit tests with: nix-instantiate --eval --strict -A unit
|
||||
# An empty list means success.
|
||||
|
@ -43,4 +43,11 @@ nix-shell $NIX_BUILD_ARGS \
|
||||
--run 'echo CABAL_CONFIG=$CABAL_CONFIG && echo GHC_ENVIRONMENT=$GHC_ENVIRONMENT && cd with-packages && rm -rf dist-newstyle .ghc-environment* && cabal new-build'
|
||||
echo >& 2
|
||||
|
||||
printf "*** Checking that a nix-shell works for a multi-target project...\n" >& 2
|
||||
nix-shell $NIX_BUILD_ARGS \
|
||||
--pure ./default.nix \
|
||||
-A cabal-simple.test-shell \
|
||||
--run 'cd cabal-simple && rm -rf dist-newstyle .ghc-environment* && cabal new-build'
|
||||
echo >& 2
|
||||
|
||||
printf "\n*** Finished successfully\n" >& 2
|
||||
|
8
test/util.nix
Normal file
8
test/util.nix
Normal file
@ -0,0 +1,8 @@
|
||||
{ cabal-install }:
|
||||
|
||||
{
|
||||
# Add cabal as a buildInput for a haskell derivation. Useful for nix-shell.
|
||||
addCabalInstall = drv: drv.overrideAttrs (oldAttrs: {
|
||||
buildInputs = (oldAttrs.buildInputs or []) ++ [ cabal-install ];
|
||||
});
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
{ pkgs
|
||||
, haskell
|
||||
, stdenv
|
||||
, util
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
with util;
|
||||
|
||||
let
|
||||
pkgSet = haskell.mkPkgSet {
|
||||
@ -34,22 +36,32 @@ let
|
||||
|
||||
packages = pkgSet.config.hsPkgs;
|
||||
|
||||
# Add cabal as a buildInput for a haskell derivation. Useful for nix-shell.
|
||||
addCabalInstall = drv: drv.overrideAttrs (oldAttrs: {
|
||||
buildInputs = (oldAttrs.buildInputs or []) ++ [ pkgs.cabal-install ];
|
||||
});
|
||||
package = packages.test-with-packages;
|
||||
inherit (package.components) library;
|
||||
|
||||
pkgId = p: "${p.identifier.name}-${p.identifier.version}";
|
||||
showDepends = component: concatMapStringsSep " " pkgId component.depends;
|
||||
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "with-packages-test";
|
||||
libraryDepends = showDepends pkgSet.config.packages.test-with-packages.components.library;
|
||||
allDepends = showDepends pkgSet.config.packages.test-with-packages.components.all;
|
||||
|
||||
buildCommand = let
|
||||
package = packages.test-with-packages;
|
||||
inherit (package.components) library;
|
||||
in ''
|
||||
buildCommand = ''
|
||||
########################################################################
|
||||
# test with-packages
|
||||
|
||||
printf "checking merging of the 'all' component depends ... " >& 2
|
||||
if [ -n "$libraryDepends" -a "$libraryDepends" = "$allDepends" ]; then
|
||||
echo "PASS" >& 2
|
||||
else
|
||||
echo "FAIL" >& 2
|
||||
echo "libraryDepends = $libraryDepends"
|
||||
echo "allDepends = $allDepends"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "checking that the 'all' component works... " >& 2
|
||||
echo ${package.components.all} >& 2
|
||||
|
||||
@ -62,7 +74,7 @@ in
|
||||
|
||||
printf "checking that components.library.env has the dependencies... " >& 2
|
||||
${library.env}/bin/runghc ${./Point.hs}
|
||||
# echo >& 2
|
||||
echo >& 2
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user