Skip to content

Commit b245f7e

Browse files
committed
Provide an empty coverage report when package has no coverage
- When covering a project with multiple packages, the project coverage report will produce a table of individual coverage reports for each package. The links in this table don't go anywhere when a package is uncovered (they are broken links). - By producing an empty coverage report when a package has no coverage, we fix the broken links, and provide a tad more information about the coverage state of that package.
1 parent a9130c2 commit b245f7e

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

lib/cover.nix

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,25 @@ in pkgs.runCommand (name + "-coverage-report")
7070
local -n tixFs=$2
7171
local outFile="$3"
7272
73-
local hpcSumCmd=("hpc" "sum" "--union" "--output=$outFile")
74-
75-
for module in "''${includedModules[@]}"; do
76-
hpcSumCmd+=("--include=$module")
77-
done
78-
79-
for tixFile in "''${tixFs[@]}"; do
80-
hpcSumCmd+=("$tixFile")
81-
done
82-
83-
echo "''${hpcSumCmd[@]}"
84-
eval "''${hpcSumCmd[@]}"
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
8592
}
8693
8794
function findModules() {
@@ -153,19 +160,17 @@ in pkgs.runCommand (name + "-coverage-report")
153160
154161
# Sum tix files to create a tix file with all relevant tix
155162
# information and markup a HTML report from this info.
156-
if (( "''${#tixFiles[@]}" > 0 )); then
157-
local sumTixFile="$out/share/hpc/vanilla/tix/${name}/${name}.tix"
158-
local markupOutDir="$out/share/hpc/vanilla/html/${name}"
163+
local sumTixFile="$out/share/hpc/vanilla/tix/${name}/${name}.tix"
164+
local markupOutDir="$out/share/hpc/vanilla/html/${name}"
159165
160-
# Sum all of our tix file, including modules from any local package
161-
sumTix allMixModules tixFiles "$sumTixFile"
166+
# Sum all of our tix file, including modules from any local package
167+
sumTix allMixModules tixFiles "$sumTixFile"
162168
163-
# Markup a HTML report, included modules from only this package
164-
markup srcDirs mixDirs pkgMixModules "$markupOutDir" "$sumTixFile"
169+
# Markup a HTML report, included modules from only this package
170+
markup srcDirs mixDirs pkgMixModules "$markupOutDir" "$sumTixFile"
165171
166-
# Provide a HTML zipfile and Hydra links
167-
( cd "$markupOutDir" ; zip -r $out/share/hpc/vanilla/${name}-html.zip . )
168-
echo "report coverage $markupOutDir/hpc_index.html" >> $out/nix-support/hydra-build-products
169-
echo "file zip $out/share/hpc/vanilla/${name}-html.zip" >> $out/nix-support/hydra-build-products
170-
fi
172+
# Provide a HTML zipfile and Hydra links
173+
( cd "$markupOutDir" ; zip -r $out/share/hpc/vanilla/${name}-html.zip . )
174+
echo "report coverage $markupOutDir/hpc_index.html" >> $out/nix-support/hydra-build-products
175+
echo "file zip $out/share/hpc/vanilla/${name}-html.zip" >> $out/nix-support/hydra-build-products
171176
''

0 commit comments

Comments
 (0)