on e94de40 help sign in
87 lines 2.5 kB history raw
1{ mkCabalProjectPkgSet, stdenv, testSrc }:
3with stdenv.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 if (stdenv.hostPlatform != stdenv.buildPlatform)
39 then ''
40 echo "Skipping haddock tests when cross compiling" >& 2
41 touch $out
42 ''
43 else ''
44 ########################################################################
45 # test haddock
47 doc="${toString library.doc or null}"
48 docDir="${toString library.haddockDir}"
50 # exeDoc="$ disabled {toString packages.test-haddock.components.exes.test-haddock.doc}"
51 # printf "checking that executable output does not have docs ... " >& 2
52 # echo $exeDoc
53 # test "$exeDoc" = ""
55 printf "checking that documentation directory was built... " >& 2
56 echo "$doc" >& 2
57 test -n "$doc"
59 printf "checking that documentation was generated... " >& 2
60 grep hello "$docDir/TestHaddock.html" > /dev/null
61 echo yes >& 2
63 printf "checking for hoogle index of package... " >& 2
64 grep hello "$docDir/test-haddock.txt" > /dev/null
65 echo yes >& 2
67 printf "checking for absence of documentation in another package... " >& 2
68 if [ -d "${toString noDocLibrary.haddockDir}" ]; then
69 echo "it exists - FAIL" >& 2
70 else
71 echo PASS >& 2
72 fi
74 printf "checking for absence of library package store paths in docs... " >& 2
75 if grep -R ${library} "$docDir" > /dev/null; then
76 echo "Found ${library} - FAIL" >& 2
77 exit 1
78 else
79 echo "PASS" >& 2
80 fi
82 touch $out
83 '';
85 meta.platforms = platforms.all;
86 meta.disabled = stdenv.hostPlatform.isMusl;
87} // { inherit packages pkgSet; }