on 19052d8 help sign in
84 lines 2.3 kB history raw
1{ mkCabalProjectPkgSet, stdenv, lib, testSrc }:
3with lib;
5let
6 pkgSet = mkCabalProjectPkgSet {
7 plan-pkgs = import ./pkgs.nix;
8 modules = [
9 # overrides to fix the build
10 {
11 packages.transformers-compat.components.library.doExactConfig = true;
12 }
14 {
15 # Add a hook to the haddock phase
16 packages.test-haddock.postHaddock = ''
17 echo "==="
18 echo "This is the postHaddock hook. The files are:"
19 find .
20 echo "==="
21 '';
23 # Check that the package option works
24 packages.stm.doHaddock = false;
25 }
26 ];
27 };
29 packages = pkgSet.config.hsPkgs;
31in
32 stdenv.mkDerivation {
33 name = "builder-haddock-test";
35 buildCommand = let
36 inherit (packages.test-haddock.components) library;
37 noDocLibrary = packages.stm.components.library;
38 in ''
39 ########################################################################
40 # test haddock
42 doc="${toString library.doc or null}"
43 docDir="${toString library.haddockDir}"
45 # exeDoc="$ disabled {toString packages.test-haddock.components.exes.test-haddock.doc}"
46 # printf "checking that executable output does not have docs ... " >& 2
47 # echo $exeDoc
48 # test "$exeDoc" = ""
50 printf "checking that documentation directory was built... " >& 2
51 echo "$doc" >& 2
52 test -n "$doc"
54 printf "checking that documentation was generated... " >& 2
55 grep hello "$docDir/TestHaddock.html" > /dev/null
56 echo yes >& 2
58 printf "checking for hoogle index of package... " >& 2
59 grep hello "$docDir/test-haddock.txt" > /dev/null
60 echo yes >& 2
62 printf "checking for absence of documentation in another package... " >& 2
63 if [ -d "${toString noDocLibrary.haddockDir}" ]; then
64 echo "it exists - FAIL" >& 2
65 else
66 echo PASS >& 2
67 fi
69 printf "checking for absence of library package store paths in docs... " >& 2
70 if grep -R ${library} "$docDir" > /dev/null; then
71 echo "Found ${library} - FAIL" >& 2
72 exit 1
73 else
74 echo "PASS" >& 2
75 fi
77 touch $out
78 '';
80 meta = {
81 platforms = platforms.all;
82 disabled = stdenv.hostPlatform != stdenv.buildPlatform || stdenv.hostPlatform.isMusl;
83 };
84} // { inherit packages pkgSet; }