mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
tests: Add test for haddock generation
This commit is contained in:
parent
d1457606ed
commit
8ad8731e29
2
test/builder-haddock/Setup.hs
Normal file
2
test/builder-haddock/Setup.hs
Normal file
@ -0,0 +1,2 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
6
test/builder-haddock/TestHaddock.hs
Normal file
6
test/builder-haddock/TestHaddock.hs
Normal file
@ -0,0 +1,6 @@
|
||||
-- | Haddock test stuff
|
||||
module TestHaddock (hello) where
|
||||
|
||||
-- | Standard hello text.
|
||||
hello :: String
|
||||
hello = "Hello, world!"
|
92
test/builder-haddock/default.nix
Normal file
92
test/builder-haddock/default.nix
Normal file
@ -0,0 +1,92 @@
|
||||
{ pkgs
|
||||
, haskell
|
||||
, stdenv
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
pkgSet = haskell.mkPkgSet {
|
||||
inherit pkgs;
|
||||
# generated with:
|
||||
# cabal new-build
|
||||
# plan-to-nix dist-newstyle/cache/plan.json > plan.nix
|
||||
# cabal-to-nix test-haddock.cabal > test-haddock.nix
|
||||
pkg-def = import ./plan.nix;
|
||||
pkg-def-overlays = [
|
||||
{ test-haddock = ./test-haddock.nix; }
|
||||
];
|
||||
modules = [
|
||||
# overrides to fix the build
|
||||
{
|
||||
packages.transformers-compat.components.library.doExactConfig = true;
|
||||
}
|
||||
|
||||
{
|
||||
# Add a hook to the haddock phase
|
||||
packages.test-haddock.postHaddock = ''
|
||||
echo "==="
|
||||
echo "This is the postHaddock hook. The files are:"
|
||||
find .
|
||||
echo "==="
|
||||
'';
|
||||
|
||||
# Check that the package option works
|
||||
packages.stm.doHaddock = false;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
packages = pkgSet.config.hsPkgs;
|
||||
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "builder-haddock-test";
|
||||
|
||||
buildCommand = let
|
||||
inherit (packages.test-haddock.components) library;
|
||||
noDocLibrary = packages.stm.components.library;
|
||||
in ''
|
||||
########################################################################
|
||||
# test haddock
|
||||
|
||||
doc="${toString library.doc}"
|
||||
docDir="${toString library.haddockDir}"
|
||||
|
||||
# exeDoc="$ disabled {toString packages.test-haddock.components.exes.test-haddock.doc}"
|
||||
# printf "checking that executable output does not have docs ... " >& 2
|
||||
# echo $exeDoc
|
||||
# test "$exeDoc" = ""
|
||||
|
||||
printf "checking that documentation directory was built... " >& 2
|
||||
echo "$doc" >& 2
|
||||
test -n "$doc"
|
||||
|
||||
printf "checking that documentation was generated... " >& 2
|
||||
grep hello "$docDir/TestHaddock.html" > /dev/null
|
||||
echo yes >& 2
|
||||
|
||||
printf "checking for hoogle index of package... " >& 2
|
||||
grep hello "$docDir/test-haddock.txt" > /dev/null
|
||||
echo yes >& 2
|
||||
|
||||
printf "checking for absence of documentation in another package... " >& 2
|
||||
if [ -d "${toString noDocLibrary.haddockDir}" ]; then
|
||||
echo "it exists - FAIL" >& 2
|
||||
else
|
||||
echo PASS >& 2
|
||||
fi
|
||||
|
||||
printf "checking for absence of library package store paths in docs... " >& 2
|
||||
if grep -R ${library} "$docDir" > /dev/null; then
|
||||
echo "Found ${library} - FAIL" >& 2
|
||||
exit 1
|
||||
else
|
||||
echo "PASS" >& 2
|
||||
fi
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
||||
meta.platforms = platforms.all;
|
||||
} // { inherit packages pkgSet; }
|
23
test/builder-haddock/plan.nix
Normal file
23
test/builder-haddock/plan.nix
Normal file
@ -0,0 +1,23 @@
|
||||
hackage:
|
||||
{
|
||||
packages = {
|
||||
"ghc-prim".revision = hackage."ghc-prim"."0.5.2.0".revisions.default;
|
||||
"stm".revision = hackage."stm"."2.4.5.1".revisions.default;
|
||||
"rts".revision = hackage."rts"."1.0".revisions.default;
|
||||
"base".revision = hackage."base"."4.11.1.0".revisions.default;
|
||||
"array".revision = hackage."array"."0.5.2.0".revisions.default;
|
||||
"integer-gmp".revision = hackage."integer-gmp"."1.0.2.0".revisions.default;
|
||||
};
|
||||
compiler = {
|
||||
version = "8.4.4";
|
||||
nix-name = "ghc844";
|
||||
packages = {
|
||||
"ghc-prim" = "0.5.2.0";
|
||||
"stm" = "2.4.5.1";
|
||||
"rts" = "1.0";
|
||||
"base" = "4.11.1.0";
|
||||
"array" = "0.5.2.0";
|
||||
"integer-gmp" = "1.0.2.0";
|
||||
};
|
||||
};
|
||||
}
|
15
test/builder-haddock/test-haddock.cabal
Normal file
15
test/builder-haddock/test-haddock.cabal
Normal file
@ -0,0 +1,15 @@
|
||||
cabal-version: 2.2
|
||||
name: test-haddock
|
||||
version: 0.1.0.0
|
||||
license: NONE
|
||||
author: Rodney Lorrimar
|
||||
maintainer: rodney.lorrimar@iohk.io
|
||||
|
||||
library
|
||||
exposed-modules: TestHaddock
|
||||
other-modules: Paths_test_haddock
|
||||
-- other-extensions:
|
||||
build-depends: base ^>=4.11.1.0
|
||||
, stm
|
||||
-- hs-source-dirs:
|
||||
default-language: Haskell2010
|
36
test/builder-haddock/test-haddock.nix
Normal file
36
test/builder-haddock/test-haddock.nix
Normal file
@ -0,0 +1,36 @@
|
||||
{ system
|
||||
, compiler
|
||||
, flags
|
||||
, pkgs
|
||||
, hsPkgs
|
||||
, pkgconfPkgs
|
||||
, ... }:
|
||||
{
|
||||
flags = {};
|
||||
package = {
|
||||
specVersion = "2.2";
|
||||
identifier = {
|
||||
name = "test-haddock";
|
||||
version = "0.1.0.0";
|
||||
};
|
||||
license = "NONE";
|
||||
copyright = "";
|
||||
maintainer = "rodney.lorrimar@iohk.io";
|
||||
author = "Rodney Lorrimar";
|
||||
homepage = "";
|
||||
url = "";
|
||||
synopsis = "";
|
||||
description = "";
|
||||
buildType = "Simple";
|
||||
};
|
||||
components = {
|
||||
"library" = {
|
||||
depends = [
|
||||
(hsPkgs.base)
|
||||
(hsPkgs.stm)
|
||||
];
|
||||
};
|
||||
};
|
||||
} // rec {
|
||||
src = pkgs.lib.mkDefault ./.;
|
||||
}
|
@ -21,6 +21,7 @@ in {
|
||||
cabal-simple = callPackage ./cabal-simple { inherit haskell util; };
|
||||
cabal-22 = callPackage ./cabal-22 { inherit haskell; };
|
||||
with-packages = callPackage ./with-packages { inherit haskell util; };
|
||||
builder-haddock = callPackage ./builder-haddock { inherit haskell; };
|
||||
|
||||
# Run unit tests with: nix-instantiate --eval --strict -A unit
|
||||
# An empty list means success.
|
||||
|
Loading…
Reference in New Issue
Block a user