on iko/ghcjs-patch-master help sign in
tests: Add test for haddock generation
commit8ad8731e2956a57d6c9268593ce96f9d01ded0a8 authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateTue 12 Feb 2019, 12:45 (8 years ago) parentd145760
7 files changed+175
test/builder-haddock/Setup.hs+2 test/builder-haddock/TestHaddock.hs+6 test/builder-haddock/default.nix+92 test/builder-haddock/plan.nix+23 test/builder-haddock/test-haddock.cabal+15 test/builder-haddock/test-haddock.nix+36 test/default.nix+1
test/builder-haddock/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
test/builder-haddock/TestHaddock.hsnew file+6
@@ -0,0 +1,6 @@
1+-- | Haddock test stuff
2+module TestHaddock (hello) where
3+
4+-- | Standard hello text.
5+hello :: String
6+hello = "Hello, world!"
test/builder-haddock/default.nixnew file+92
@@ -0,0 +1,92 @@
1+{ pkgs
2+, haskell
3+, stdenv
4+}:
5+
6+with stdenv.lib;
7+
8+let
9+ pkgSet = haskell.mkPkgSet {
10+ inherit pkgs;
11+ # generated with:
12+ # cabal new-build
13+ # plan-to-nix dist-newstyle/cache/plan.json > plan.nix
14+ # cabal-to-nix test-haddock.cabal > test-haddock.nix
15+ pkg-def = import ./plan.nix;
16+ pkg-def-overlays = [
17+ { test-haddock = ./test-haddock.nix; }
18+ ];
19+ modules = [
20+ # overrides to fix the build
21+ {
22+ packages.transformers-compat.components.library.doExactConfig = true;
23+ }
24+
25+ {
26+ # Add a hook to the haddock phase
27+ packages.test-haddock.postHaddock = ''
28+ echo "==="
29+ echo "This is the postHaddock hook. The files are:"
30+ find .
31+ echo "==="
32+ '';
33+
34+ # Check that the package option works
35+ packages.stm.doHaddock = false;
36+ }
37+ ];
38+ };
39+
40+ packages = pkgSet.config.hsPkgs;
41+
42+in
43+ stdenv.mkDerivation {
44+ name = "builder-haddock-test";
45+
46+ buildCommand = let
47+ inherit (packages.test-haddock.components) library;
48+ noDocLibrary = packages.stm.components.library;
49+ in ''
50+ ########################################################################
51+ # test haddock
52+
53+ doc="${toString library.doc}"
54+ docDir="${toString library.haddockDir}"
55+
56+ # exeDoc="$ disabled {toString packages.test-haddock.components.exes.test-haddock.doc}"
57+ # printf "checking that executable output does not have docs ... " >& 2
58+ # echo $exeDoc
59+ # test "$exeDoc" = ""
60+
61+ printf "checking that documentation directory was built... " >& 2
62+ echo "$doc" >& 2
63+ test -n "$doc"
64+
65+ printf "checking that documentation was generated... " >& 2
66+ grep hello "$docDir/TestHaddock.html" > /dev/null
67+ echo yes >& 2
68+
69+ printf "checking for hoogle index of package... " >& 2
70+ grep hello "$docDir/test-haddock.txt" > /dev/null
71+ echo yes >& 2
72+
73+ printf "checking for absence of documentation in another package... " >& 2
74+ if [ -d "${toString noDocLibrary.haddockDir}" ]; then
75+ echo "it exists - FAIL" >& 2
76+ else
77+ echo PASS >& 2
78+ fi
79+
80+ printf "checking for absence of library package store paths in docs... " >& 2
81+ if grep -R ${library} "$docDir" > /dev/null; then
82+ echo "Found ${library} - FAIL" >& 2
83+ exit 1
84+ else
85+ echo "PASS" >& 2
86+ fi
87+
88+ touch $out
89+ '';
90+
91+ meta.platforms = platforms.all;
92+} // { inherit packages pkgSet; }
test/builder-haddock/plan.nixnew file+23
@@ -0,0 +1,23 @@
1+hackage:
2+ {
3+ packages = {
4+ "ghc-prim".revision = hackage."ghc-prim"."0.5.2.0".revisions.default;
5+ "stm".revision = hackage."stm"."2.4.5.1".revisions.default;
6+ "rts".revision = hackage."rts"."1.0".revisions.default;
7+ "base".revision = hackage."base"."4.11.1.0".revisions.default;
8+ "array".revision = hackage."array"."0.5.2.0".revisions.default;
9+ "integer-gmp".revision = hackage."integer-gmp"."1.0.2.0".revisions.default;
10+ };
11+ compiler = {
12+ version = "8.4.4";
13+ nix-name = "ghc844";
14+ packages = {
15+ "ghc-prim" = "0.5.2.0";
16+ "stm" = "2.4.5.1";
17+ "rts" = "1.0";
18+ "base" = "4.11.1.0";
19+ "array" = "0.5.2.0";
20+ "integer-gmp" = "1.0.2.0";
21+ };
22+ };
23+ }
test/builder-haddock/test-haddock.cabalnew file+15
@@ -0,0 +1,15 @@
1+cabal-version: 2.2
2+name: test-haddock
3+version: 0.1.0.0
4+license: NONE
5+author: Rodney Lorrimar
6+maintainer: rodney.lorrimar@iohk.io
7+
8+library
9+ exposed-modules: TestHaddock
10+ other-modules: Paths_test_haddock
11+ -- other-extensions:
12+ build-depends: base ^>=4.11.1.0
13+ , stm
14+ -- hs-source-dirs:
15+ default-language: Haskell2010
test/builder-haddock/test-haddock.nixnew file+36
@@ -0,0 +1,36 @@
1+{ system
2+, compiler
3+, flags
4+, pkgs
5+, hsPkgs
6+, pkgconfPkgs
7+, ... }:
8+ {
9+ flags = {};
10+ package = {
11+ specVersion = "2.2";
12+ identifier = {
13+ name = "test-haddock";
14+ version = "0.1.0.0";
15+ };
16+ license = "NONE";
17+ copyright = "";
18+ maintainer = "rodney.lorrimar@iohk.io";
19+ author = "Rodney Lorrimar";
20+ homepage = "";
21+ url = "";
22+ synopsis = "";
23+ description = "";
24+ buildType = "Simple";
25+ };
26+ components = {
27+ "library" = {
28+ depends = [
29+ (hsPkgs.base)
30+ (hsPkgs.stm)
31+ ];
32+ };
33+ };
34+ } // rec {
35+ src = pkgs.lib.mkDefault ./.;
36+ }
test/default.nix+1
@@ -21,6 +21,7 @@ in {
2121 cabal-simple = callPackage ./cabal-simple { inherit haskell util; };
2222 cabal-22 = callPackage ./cabal-22 { inherit haskell; };
2323 with-packages = callPackage ./with-packages { inherit haskell util; };
24+ builder-haddock = callPackage ./builder-haddock { inherit haskell; };
2425
2526 # Run unit tests with: nix-instantiate --eval --strict -A unit
2627 # An empty list means success.