on e94de40 help sign in
70 lines 2.6 kB history raw
1{ stdenv, mkCabalProjectPkgSet, cabalProject', haskellLib, util, recurseIntoAttrs, testSrc, compiler-nix-name }:
3with stdenv.lib;
5let
6 project = cabalProject' {
7 inherit compiler-nix-name;
8 src = testSrc "cabal-22";
9 };
11 packages = project.hsPkgs;
13in recurseIntoAttrs {
14 ifdInputs = {
15 inherit (project) plan-nix;
16 };
17 shell = util.addCabalInstall packages.project.components.library;
18 run = stdenv.mkDerivation {
19 name = "cabal-22-test";
21 buildCommand = ''
22 exe="${packages.project.components.exes.project}/bin/project${stdenv.hostPlatform.extensions.executable}"
24 size=$(command stat --format '%s' "$exe")
25 printf "size of executable $exe is $size. \n" >& 2
27 # fixme: run on target platform when cross-compiled
28 printf "checking whether executable runs... " >& 2
29 cat ${haskellLib.check packages.project.components.exes.project}/test-stdout
31 '' +
32 # Aarch is statically linked and does not produce a .so file.
33 # Musl is also statically linked, but it does make a .so file so we should check that still.
34 optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64) (''
35 printf "checking that executable is dynamically linked to system libraries... " >& 2
36 '' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
37 ldd $exe | grep libgmp
38 '' + optionalString stdenv.isDarwin ''
39 otool -L $exe | grep "libSystem.B"
40 '' + ''
41 # fixme: posix-specific
42 printf "checking that dynamic library is produced... " >& 2
43 '' + optionalString stdenv.isLinux ''
44 sofile=$(find "${packages.project.components.library}" | grep -e '\.so$')
45 '' + optionalString stdenv.isDarwin ''
46 sofile=$(find "${packages.project.components.library}" | grep -e '\.dylib$')
47 '' + ''
48 echo "$sofile"
49 '' + optionalString (!stdenv.hostPlatform.isMusl) (''
50 printf "checking that dynamic library is dynamically linked to prim... " >& 2
51 '' + optionalString stdenv.isLinux ''
52 ldd $sofile | grep libHSghc-prim
53 '' + optionalString stdenv.isDarwin ''
54 otool -L $sofile | grep libHSghc-prim
55 '')) + ''
56 touch $out
58 printf "checking whether benchmark ran... " >& 2
59 cat ${haskellLib.check packages.project.components.benchmarks.project-bench}/test-stdout
61 printf "checking whether tests ran... " >& 2
62 cat ${haskellLib.check packages.project.components.tests.unit}/test-stdout
63 '';
65 meta.platforms = platforms.all;
66 passthru = {
67 inherit project;
68 };
69 };