16
16
} :
17
17
18
18
let
19
- toBashArray = arr : "(" + ( lib . concatStringsSep " " arr ) + ")" ;
20
-
21
19
mixDir = l : "${ l } /share/hpc/vanilla/mix/${ l . identifier . name } -${ l . identifier . version } " ;
22
20
mixDirs = map mixDir mixLibraries ;
23
21
@@ -39,130 +37,35 @@ in pkgs.runCommand (name + "-coverage-report")
39
37
LOCALE_ARCHIVE = "${ pkgs . buildPackages . glibcLocales } /lib/locale/locale-archive" ;
40
38
} )
41
39
''
42
- function markup() {
43
- local -n srcDs=$1
44
- local -n mixDs=$2
45
- local -n includedModules=$3
46
- local destDir=$4
47
- local tixFile=$5
48
-
49
- local hpcMarkupCmd=("hpc" "markup" "--destdir=$destDir")
50
- for srcDir in "'' ${srcDs[@]}"; do
51
- hpcMarkupCmd+=("--srcdir=$srcDir")
52
- done
53
-
54
- for mixDir in "'' ${mixDs[@]}"; do
55
- hpcMarkupCmd+=("--hpcdir=$mixDir")
56
- done
57
-
58
- for module in "'' ${includedModules[@]}"; do
59
- hpcMarkupCmd+=("--include=$module")
60
- done
61
-
62
- hpcMarkupCmd+=("$tixFile")
63
-
64
- echo "'' ${hpcMarkupCmd[@]}"
65
- eval "'' ${hpcMarkupCmd[@]}"
66
- }
67
-
68
- function sumTix() {
69
- local -n includedModules=$1
70
- local -n tixFs=$2
71
- local outFile="$3"
72
-
73
- if (( "'' ${#tixFs[@]}" > 0 )); then
74
- local hpcSumCmd=("hpc" "sum" "--union" "--output=$outFile")
75
-
76
- for module in "'' ${includedModules[@]}"; do
77
- hpcSumCmd+=("--include=$module")
78
- done
79
-
80
- for tixFile in "'' ${tixFs[@]}"; do
81
- hpcSumCmd+=("$tixFile")
82
- done
83
-
84
- echo "'' ${hpcSumCmd[@]}"
85
- eval "'' ${hpcSumCmd[@]}"
86
- else
87
- # If there are no tix files we output an empty tix file so that we can
88
- # markup an empty HTML coverage report. This is preferable to failing to
89
- # output a HTML report.
90
- echo 'Tix []' > $outFile
91
- fi
92
- }
93
-
94
- function findModules() {
95
- local -n result=$1
96
- local -n searchDirs=$2
97
- local pattern=$3
98
-
99
- for dir in "'' ${searchDirs[@]}"; do
100
- pushd $dir
101
- local temp=()
102
- mapfile -d $'\0' temp < <(find ./ -type f \
103
- -wholename "$pattern" -not -name "Paths*" \
104
- -exec basename {} \; \
105
- | sed "s/\.mix$//" \
106
- | tr "\n" "\0")
107
- result+=("'' ${temp[@]}")
108
- popd
109
- done
110
- }
111
-
112
40
mkdir -p $out/nix-support
113
41
mkdir -p $out/share/hpc/vanilla/mix/
114
42
mkdir -p $out/share/hpc/vanilla/tix/${ name }
115
43
mkdir -p $out/share/hpc/vanilla/html/${ name }
116
44
117
- local srcDirs=${ toBashArray srcDirs }
118
- local mixDirs=${ toBashArray mixDirs }
119
-
120
- # Copy out mix files used for this report
121
- for dir in "'' ${mixDirs[@]}"; do
122
- if [ -d "$dir" ]; then
123
- cp -R "$dir" $out/share/hpc/vanilla/mix/
124
- fi
125
- done
126
-
127
- local mixModules=()
128
- # Mix modules for all packages in "mixLibraries"
129
- findModules mixModules mixDirs "*.mix"
130
-
131
- # We need to make a distinction between library "exposed-modules" and
132
- # "other-modules" used in test suites:
133
- # - "exposed-modules" are addressed as "$library-$version-$hash/module"
134
- # - "other-modules" are addressed as "module"
135
- #
136
- # This complicates the code required to find the mix modules. For a given mix directory:
137
- #
138
- # mix
139
- # └── ntp-client-0.0.1
140
- # └── ntp-client-0.0.1-gYjRsBHUCaHX7ENcjHnw5
141
- # ├── Network.NTP.Client.mix
142
- # ├── Network.NTP.Client.Packet.mix
143
- # └── Network.NTP.Client.Query.mix
144
- #
145
- # Iff ntp-client uses "other-modules" in a test suite, both:
146
- # - "mix/ntp-client-0.0.1", and
147
- # - "mix/ntp-client-0.0.1/ntp-client-0.0.1-gYjRsBHUCaHX7ENcjHnw5"
148
- # need to be provided to hpc as search directories.
149
- #
150
- # I'd prefer to just exclude "other-modules", but I can't think of an easy
151
- # way to do that in bash.
152
- #
153
- # Here we expand the search dirs and modify the mix dirs accordingly:
154
- for dir in "'' ${mixDirs[@]}"; do
155
- local otherModulesSearchDirs=()
156
- # Simply consider any directory with a mix file as a search directory.
157
- mapfile -d $'\0' otherModulesSearchDirs < <(find $dir -type f \
158
- -wholename "*.mix" \
159
- -exec dirname {} \; \
160
- | uniq \
161
- | tr "\n" "\0")
162
- mixDirs+=("'' ${otherModulesSearchDirs[@]}")
163
- done
164
-
165
- local tixFiles=()
45
+ local srcDirArgs=$(mktemp)
46
+ ${ lib . concatStringsSep "\n " ( map ( srcDir : ''
47
+ echo --srcdir=${ srcDir } >> $srcDirArgs
48
+ '' ) srcDirs )
49
+ }
50
+ local mixDirArgs=$(mktemp)
51
+ ${ # Copy out mix files used for this report
52
+ lib . concatStrings ( map ( mixDir : ''
53
+ local dir=${ mixDir }
54
+ echo --hpcdir=$dir >> $mixDirArgs
55
+ if [ -d $dir ]; then
56
+ cp -R "$dir" $out/share/hpc/vanilla/mix/
57
+ fi
58
+ '' ) mixDirs )
59
+ }
60
+ local includeArgs=$(mktemp)
61
+ find $out/share/hpc/vanilla/mix/ -type f \
62
+ -wholename "*.mix" -not -name "Paths*" \
63
+ -exec basename {} \; \
64
+ | sed "s/\.mix$//" \
65
+ | sed "s/^.*$/--include=\0/" \
66
+ >> $includeArgs
67
+
68
+ local tixFiles=$(mktemp -d)/tixFiles
166
69
${ lib . concatStringsSep "\n " ( builtins . map ( check : ''
167
70
if [ -d "${ check } /share/hpc/vanilla/tix" ]; then
168
71
pushd ${ check } /share/hpc/vanilla/tix
@@ -175,11 +78,19 @@ in pkgs.runCommand (name + "-coverage-report")
175
78
cp "$tixFile" "$newTixFile"
176
79
177
80
# Add the tix file to our list
178
- tixFiles+=(" $newTixFile")
81
+ echo $newTixFile >> $tixFiles
179
82
180
83
# Create a coverage report for *just that check* affecting any of the
181
84
# "mixLibraries"
182
- markup srcDirs mixDirs mixModules "$out/share/hpc/vanilla/html/${ check . name } /" "$newTixFile"
85
+ local responseFile=$(mktemp)
86
+ echo markup > $responseFile
87
+ echo '--destdir'=$out/share/hpc/vanilla/html/${ check . name } / >> $responseFile
88
+ cat $srcDirArgs $mixDirArgs $includeArgs >> $responseFile
89
+ echo $newTixFile >> $responseFile
90
+
91
+ echo hpc response file:
92
+ cat $responseFile
93
+ hpc @$responseFile
183
94
184
95
popd
185
96
fi
@@ -192,10 +103,33 @@ in pkgs.runCommand (name + "-coverage-report")
192
103
local markupOutDir="$out/share/hpc/vanilla/html/${ name } "
193
104
194
105
# Sum all of our tix files
195
- sumTix mixModules tixFiles "$sumTixFile"
106
+ if [ -e $tixFiles ]; then
107
+ local responseFile=$(mktemp)
108
+ echo sum > $responseFile
109
+ echo '--union' >> $responseFile
110
+ echo '--output'=$sumTixFile >> $responseFile
111
+ cat $includeArgs >> $responseFile
112
+ cat $tixFiles >> $responseFile
113
+
114
+ echo hpc response file:
115
+ cat $responseFile
116
+ hpc @$responseFile
117
+ else
118
+ # If there are no tix files we output an empty tix file so that we can
119
+ # markup an empty HTML coverage report. This is preferable to failing to
120
+ # output a HTML report.
121
+ echo 'Tix []' > $sumTixFile
122
+ fi
196
123
197
124
# Markup a HTML report
198
- markup srcDirs mixDirs mixModules "$markupOutDir" "$sumTixFile"
125
+ local responseFile=$(mktemp)
126
+ echo markup > $responseFile
127
+ echo '--destdir'=$markupOutDir >> $responseFile
128
+ cat $srcDirArgs $mixDirArgs $includeArgs >> $responseFile
129
+ echo $sumTixFile >> $responseFile
130
+ echo hpc response file:
131
+ cat $responseFile
132
+ hpc @$responseFile
199
133
200
134
# Provide a HTML zipfile and Hydra links
201
135
( cd "$markupOutDir" ; zip -r $out/share/hpc/vanilla/${ name } -html.zip . )
0 commit comments