1{ stdenv, lib, cabal-install, cabalProject', stackProject', recurseIntoAttrs, runCommand, testSrc, compiler-nix-name }:
7 src = testSrc "coverage";
9 # Package has no exposed modules which causes
10 # haddock: No input file(s)
11 packages.bytestring-builder.doHaddock = false;
14 packages.pkga.components.library.doCoverage = true;
15 packages.pkgb.components.library.doCoverage = true;
19 # We can easily select a different compiler when using cabal,
20 # but for stack we would need a different resolver to be used..
21 cabalProj = (cabalProject' projectArgs // { inherit compiler-nix-name; });
22 stackProj = (stackProject' projectArgs);
24 exeExt = stdenv.hostPlatform.extensions.executable;
27 # Does not work on ghcjs because it needs zlib.
28 meta.disabled = stdenv.hostPlatform.isGhcjs;
29 run = stdenv.mkDerivation {
30 name = "coverage-test";
33 ########################################################################
34 # test coverage reports with an example project
36 fileExistsNonEmpty() {
38 if [ ! -f "$file" ]; then
42 local filesize=$(command stat --format '%s' "$file")
43 if [ $filesize -eq 0 ]; then
44 echo "File must not be empty: $file"
48 findFileExistsNonEmpty() {
52 local file="$(find $searchDir -name $filePattern -print -quit)"
55 echo "Couldn't find file \"$filePattern\" in directory \"$searchDir\"."
59 local filesize=$(command stat --format '%s' "$file")
60 if [ $filesize -eq 0 ]; then
61 echo "File must not be empty: $file"
67 if [ ! -d "$dir" ]; then
71 if [ "$(ls -A $dir)" ]; then
72 echo "Dir should be empty: $dir"
78 if [ ! -d "$dir" ]; then
84 ${concatStringsSep "\n" (map (project: ''
85 pkga_basedir="${project.hsPkgs.pkga.coverageReport}/share/hpc/vanilla"
86 findFileExistsNonEmpty "$pkga_basedir/mix/pkga-0.1.0.0/" "PkgA.mix"
87 dirExistsEmpty "$pkga_basedir/tix/pkga-0.1.0.0"
88 dirExistsEmpty "$pkga_basedir/html/pkga-0.1.0.0"
90 pkgb_basedir="${project.hsPkgs.pkgb.coverageReport}/share/hpc/vanilla"
91 testTix="$pkgb_basedir/tix/pkgb-0.1.0.0/tests${exeExt}/tests${exeExt}.tix"
92 libTix="$pkgb_basedir/tix/pkgb-0.1.0.0/pkgb-0.1.0.0.tix"
93 fileExistsNonEmpty "$testTix"
94 fileExistsNonEmpty "$libTix"
95 findFileExistsNonEmpty "$pkgb_basedir/mix/pkgb-0.1.0.0/" "ConduitExample.mix"
96 findFileExistsNonEmpty "$pkgb_basedir/mix/pkgb-0.1.0.0/" "PkgB.mix"
97 fileExistsNonEmpty "$pkgb_basedir/html/pkgb-0.1.0.0/hpc_index.html"
99 filesizeTestsTix=$(command stat --format '%s' "$testTix")
100 filesizeLibTix=$(command stat --format '%s' "$libTix")
101 if (( filesizeTestsTix <= filesizeLibTix )); then
102 echo "Filesize of \"$testTix\" ($filesizeTestsTix) should be greather than that of \"$libTix\" ($filesizeLibTix). Did you forget to exclude test modules when creating \"$libTix\"?"
106 project_basedir="${project.projectCoverageReport}/share/hpc/vanilla"
107 fileExistsNonEmpty "$project_basedir/html/index.html"
108 dirExists "$project_basedir/html/pkga-0.1.0.0"
109 dirExists "$project_basedir/html/pkgb-0.1.0.0"
110 findFileExistsNonEmpty "$project_basedir/mix/" "PkgA.mix"
111 findFileExistsNonEmpty "$project_basedir/mix/" "PkgB.mix"
112 findFileExistsNonEmpty "$project_basedir/mix/" "ConduitExample.mix"
113 dirExists "$project_basedir/tix/all"
114 fileExistsNonEmpty "$project_basedir/tix/all/all.tix"
115 dirExists "$project_basedir/tix/pkga-0.1.0.0"
116 dirExists "$project_basedir/tix/pkgb-0.1.0.0"
117 fileExistsNonEmpty "$project_basedir/tix/pkgb-0.1.0.0/pkgb-0.1.0.0.tix"
118 dirExists "$project_basedir/tix/pkgb-0.1.0.0/tests${exeExt}"
119 fileExistsNonEmpty "$project_basedir/tix/pkgb-0.1.0.0/tests${exeExt}/tests${exeExt}.tix"
120 '') (optional (compiler-nix-name == "ghc865") stackProj))}
125 meta.platforms = platforms.all;
128 # Used for debugging with nix repl
129 inherit cabalProj stackProj;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list