7
7
} :
8
8
9
9
let
10
+ identifier = name + "-" + version ;
11
+ toBashArray = arr : "(" + ( lib . concatStringsSep " " arr ) + ")" ;
12
+
10
13
testsAsList = lib . attrValues tests ;
11
14
checks = builtins . map ( d : haskellLib . check d ) testsAsList ;
12
15
13
- identifier = name + "-" + version ;
14
-
15
- toBashArray = arr : "(" + ( lib . concatStringsSep " " arr ) + ")" ;
16
+ # Exclude test modules from tix file. The Main module is
17
+ # hard-coded here because the Main module is not listed in
18
+ # "$test.config.modules" (the plan.nix) but must be excluded.
19
+ # Note that the name of the Main module file does not matter. So
20
+ # a line in your cabal file such as:
21
+ # main-is: Spec.hs
22
+ # still generates a "Main.mix" file with the contents:
23
+ # Mix "Spec.hs" ...
24
+ # Hence we can hardcode the name "Main" here.
25
+ testModules = lib . foldl' ( acc : test : acc ++ test . config . modules ) [ "Main" ] testsAsList ;
26
+
27
+ # Mix information HPC will need.
28
+ # For libraries, where we copy the mix information from differs from
29
+ # where HPC should look for the mix files. For tests, they are the
30
+ # same location.
31
+ mixInfo = [ { rootDir = "${ library } /share/hpc/vanilla/mix" ;
32
+ searchSubDir = "${ identifier } " ;
33
+ }
34
+ ] ++ map ( drv : { rootDir = "${ drv } /share/hpc/vanilla/mix" ; searchSubDir = null ; } ) testsAsList ;
35
+
36
+ mixDirs = map ( info : info . rootDir ) mixInfo ;
37
+ mixSearchDirs = map ( info : if info . searchSubDir == null then info . rootDir else info . rootDir + "/" + info . searchSubDir ) mixInfo ;
16
38
17
39
in pkgs . runCommand ( identifier + "-coverage-report" )
18
40
{ buildInputs = ( with pkgs ; [ ghc ] ) ; }
@@ -44,8 +66,6 @@ in pkgs.runCommand (identifier + "-coverage-report")
44
66
local -n tixFs=$2
45
67
local outFile="$3"
46
68
47
- echo "EXCLUDED '' ${excludedModules[@]}"
48
- echo "EXCLUDED '' ${tixFs[@]}"
49
69
local hpcSumCmd=("hpc" "sum" "--union" "--output=$outFile")
50
70
51
71
for module in "'' ${excludedModules[@]}"; do
@@ -60,43 +80,31 @@ in pkgs.runCommand (identifier + "-coverage-report")
60
80
eval "'' ${hpcSumCmd[@]}"
61
81
}
62
82
83
+ local mixDirs=${ toBashArray mixDirs }
84
+
63
85
mkdir -p $out/share/hpc/vanilla/mix/${ identifier }
64
86
mkdir -p $out/share/hpc/vanilla/tix/${ identifier }
65
87
mkdir -p $out/share/hpc/vanilla/html/${ identifier }
66
88
67
- local src=${ library . src . outPath }
68
- local mixDirs=${ toBashArray ( map ( drv : "${ drv } /share/hpc/vanilla/mix" ) ( [ library ] ++ testsAsList ) ) }
69
- # Exclude test modules from tix file. The Main module is
70
- # hard-coded here because the Main module is not listed in
71
- # "$test.config.modules" (the plan.nix) but must be excluded.
72
- # Note that the name of the Main module file does not matter. So
73
- # a line in your cabal file such as:
74
- # main-is: Spec.hs
75
- # still generates a "Main.mix" file with the contents:
76
- # Mix "Spec.hs" ...
77
- # Hence we can hardcode the name "Main" here.
78
- local testModules=${ toBashArray ( [ "Main" ] ++ ( lib . foldl' ( acc : test : acc ++ test . config . modules ) [ ] testsAsList ) ) }
79
- local totalTixFile="$out/share/hpc/vanilla/tix/${ identifier } /${ identifier } .tix"
80
- local markupOutDir="$out/share/hpc/vanilla/html/${ identifier } "
81
-
82
- echo "'' ${testModules[@]}"
83
-
84
89
# Copy over mix files verbatim
85
- for dir in $ mixDirs; do
86
- if [ ! -z "$mixDir " ]; then
87
- cp -R "$mixDir" $out/share/hpc/vanilla/mix/
90
+ for dir in " '' ${ mixDirs[@]}" ; do
91
+ if [ -d "$dir " ]; then
92
+ cp -R "$dir"/* $out/share/hpc/vanilla/mix/
88
93
fi
89
94
done
90
95
96
+ # Copy over tix files verbatim
91
97
${ lib . optionalString ( ( builtins . length testsAsList ) > 0 ) ''
92
98
local tixFiles=()
93
99
${ lib . concatStringsSep "\n " ( builtins . map ( check : ''
94
100
if [ -d "${ check } /share/hpc/vanilla/tix" ]; then
95
101
pushd ${ check } /share/hpc/vanilla/tix
96
102
97
103
tixFile="$(find . -iwholename "*.tix" -type f -print -quit)"
104
+ local newTixFile=$out/share/hpc/vanilla/tix/"$tixFile"
98
105
99
- cp "$tixFile" $out/share/hpc/vanilla/tix/
106
+ mkdir -p "$(dirname $newTixFile)"
107
+ cp "$tixFile" "$newTixFile"
100
108
101
109
tixFiles+=("${ check } /share/hpc/vanilla/tix/$tixFile")
102
110
@@ -105,10 +113,18 @@ in pkgs.runCommand (identifier + "-coverage-report")
105
113
'' ) checks )
106
114
}
107
115
116
+ # Sum tix files to create a tix file with all relevant tix
117
+ # information and markup a HTML report from this info.
108
118
if (( "'' ${#tixFiles[@]}" > 0 )); then
109
- sumTix testModules tixFiles "$totalTixFile"
110
-
111
- markup "$src" mixDirs testModules "$markupOutDir" "$totalTixFile"
119
+ local src=${ library . src . outPath }
120
+ local mixSearchDirs=${ toBashArray mixSearchDirs }
121
+ local testModules=${ toBashArray testModules }
122
+ local sumTixFile="$out/share/hpc/vanilla/tix/${ identifier } /${ identifier } .tix"
123
+ local markupOutDir="$out/share/hpc/vanilla/html/${ identifier } "
124
+
125
+ sumTix testModules tixFiles "$sumTixFile"
126
+
127
+ markup "$src" mixSearchDirs testModules "$markupOutDir" "$sumTixFile"
112
128
fi
113
129
'' }
114
130
''
0 commit comments