2022-07-28 11:03:05 +03:00
|
|
|
{ stdenv, lib, mkCabalProjectPkgSet, cabalProject', haskellLib, util, recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages }:
|
2018-12-20 04:59:49 +03:00
|
|
|
|
2021-02-10 15:07:16 +03:00
|
|
|
with lib;
|
2018-12-20 04:59:49 +03:00
|
|
|
|
|
|
|
let
|
2019-11-20 03:47:15 +03:00
|
|
|
project = cabalProject' {
|
2022-07-28 11:03:05 +03:00
|
|
|
inherit compiler-nix-name evalPackages;
|
2020-04-20 04:27:52 +03:00
|
|
|
src = testSrc "cabal-22";
|
2018-12-20 04:59:49 +03:00
|
|
|
};
|
|
|
|
|
2019-11-20 03:47:15 +03:00
|
|
|
packages = project.hsPkgs;
|
2018-12-20 04:59:49 +03:00
|
|
|
|
2019-11-20 03:47:15 +03:00
|
|
|
in recurseIntoAttrs {
|
2021-03-28 11:03:20 +03:00
|
|
|
# When using ghcjs on darwin this test fails with
|
|
|
|
# ReferenceError: h$hs_clock_darwin_gettime is not defined
|
|
|
|
# https://github.com/input-output-hk/haskell.nix/issues/925
|
2022-03-07 10:31:52 +03:00
|
|
|
# Also `hspec` now depends on `ghc`, which breaks this test for cross compilation
|
2022-05-19 11:21:16 +03:00
|
|
|
meta.disabled = stdenv.hostPlatform.isGhcjs || stdenv.hostPlatform.isWindows || stdenv.hostPlatform.isMusl;
|
2019-11-29 13:28:47 +03:00
|
|
|
ifdInputs = {
|
|
|
|
inherit (project) plan-nix;
|
|
|
|
};
|
2020-07-21 07:06:54 +03:00
|
|
|
shell = util.addCabalInstall packages.project.components.library;
|
2019-11-20 03:47:15 +03:00
|
|
|
run = stdenv.mkDerivation {
|
2018-12-20 04:59:49 +03:00
|
|
|
name = "cabal-22-test";
|
|
|
|
|
|
|
|
buildCommand = ''
|
2020-11-17 12:22:53 +03:00
|
|
|
exe="${packages.project.components.exes.project.exePath}"
|
2018-12-20 04:59:49 +03:00
|
|
|
|
|
|
|
size=$(command stat --format '%s' "$exe")
|
|
|
|
printf "size of executable $exe is $size. \n" >& 2
|
|
|
|
|
|
|
|
# fixme: run on target platform when cross-compiled
|
2020-03-04 06:07:01 +03:00
|
|
|
printf "checking whether executable runs... " >& 2
|
2020-09-29 06:56:24 +03:00
|
|
|
cat ${haskellLib.check packages.project.components.exes.project}/test-stdout
|
2018-12-20 04:59:49 +03:00
|
|
|
|
2020-03-04 06:07:01 +03:00
|
|
|
'' +
|
|
|
|
# Aarch is statically linked and does not produce a .so file.
|
|
|
|
# Musl is also statically linked, but it does make a .so file so we should check that still.
|
|
|
|
optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64) (''
|
2018-12-20 04:59:49 +03:00
|
|
|
printf "checking that executable is dynamically linked to system libraries... " >& 2
|
2020-03-04 06:07:01 +03:00
|
|
|
'' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
|
2019-07-02 11:25:40 +03:00
|
|
|
ldd $exe | grep libgmp
|
2019-02-05 06:50:34 +03:00
|
|
|
'' + optionalString stdenv.isDarwin ''
|
2019-01-25 17:20:47 +03:00
|
|
|
otool -L $exe | grep "libSystem.B"
|
|
|
|
'' + ''
|
2018-12-20 04:59:49 +03:00
|
|
|
# fixme: posix-specific
|
|
|
|
printf "checking that dynamic library is produced... " >& 2
|
2019-02-05 06:50:34 +03:00
|
|
|
'' + optionalString stdenv.isLinux ''
|
2018-12-20 04:59:49 +03:00
|
|
|
sofile=$(find "${packages.project.components.library}" | grep -e '\.so$')
|
2019-02-05 06:50:34 +03:00
|
|
|
'' + optionalString stdenv.isDarwin ''
|
2019-01-25 17:20:47 +03:00
|
|
|
sofile=$(find "${packages.project.components.library}" | grep -e '\.dylib$')
|
|
|
|
'' + ''
|
2018-12-20 04:59:49 +03:00
|
|
|
echo "$sofile"
|
2019-07-02 11:25:40 +03:00
|
|
|
'' + optionalString (!stdenv.hostPlatform.isMusl) (''
|
2019-01-25 17:20:47 +03:00
|
|
|
printf "checking that dynamic library is dynamically linked to prim... " >& 2
|
2019-02-05 06:50:34 +03:00
|
|
|
'' + optionalString stdenv.isLinux ''
|
2019-01-25 17:20:47 +03:00
|
|
|
ldd $sofile | grep libHSghc-prim
|
2019-02-05 06:50:34 +03:00
|
|
|
'' + optionalString stdenv.isDarwin ''
|
2019-01-25 17:20:47 +03:00
|
|
|
otool -L $sofile | grep libHSghc-prim
|
2020-03-04 06:07:01 +03:00
|
|
|
'')) + ''
|
2018-12-20 04:59:49 +03:00
|
|
|
touch $out
|
2019-10-01 05:01:49 +03:00
|
|
|
|
2019-11-11 13:38:08 +03:00
|
|
|
printf "checking whether benchmark ran... " >& 2
|
2020-09-29 06:56:24 +03:00
|
|
|
cat ${haskellLib.check packages.project.components.benchmarks.project-bench}/test-stdout
|
2019-10-01 05:01:49 +03:00
|
|
|
|
2019-11-11 13:38:08 +03:00
|
|
|
printf "checking whether tests ran... " >& 2
|
2020-09-29 06:56:24 +03:00
|
|
|
cat ${haskellLib.check packages.project.components.tests.unit}/test-stdout
|
2018-12-20 04:59:49 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta.platforms = platforms.all;
|
2019-10-01 05:01:49 +03:00
|
|
|
passthru = {
|
2020-03-09 13:47:26 +03:00
|
|
|
inherit project;
|
2019-10-01 05:01:49 +03:00
|
|
|
};
|
2019-11-20 03:47:15 +03:00
|
|
|
};
|
2020-01-15 03:56:18 +03:00
|
|
|
}
|