Skip to content

Commit a675618

Browse files
committed
Fix existing tests
1 parent c003add commit a675618

File tree

16 files changed

+64
-52
lines changed

16 files changed

+64
-52
lines changed

lib/cover-project.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let
6464
'';
6565
in
6666
stdenv.mkDerivation {
67-
name = "coverage-report";
67+
name = "project-coverage-report";
6868

6969
phases = ["buildPhase"];
7070

@@ -88,22 +88,28 @@ stdenv.mkDerivation {
8888
# Create tix file with test run information for all packages
8989
tixFile="$out/share/hpc/tix/all/all.tix"
9090
hpcSumCmd=("hpc" "sum" "--union" "--output=$tixFile")
91+
tixFiles=()
9192
9293
${with lib; concatStringsSep "\n" (mapAttrsToList (n: package: ''
9394
identifier="${package.identifier.name}-${package.identifier.version}"
9495
report=${package.coverageReport}
9596
tix="$report/share/hpc/tix/$identifier/$identifier.tix"
96-
hpcSumCmd+=("$tix")
97+
if test -f "$tix"; then
98+
tixFiles+=("$tix")
99+
fi
97100
98101
# Copy mix and tix information over from each report
99102
cp -R $report/share/hpc/mix/* $out/share/hpc/mix
100103
cp -R $report/share/hpc/tix/* $out/share/hpc/tix
101104
cp -R $report/share/hpc/html/* $out/share/hpc/html
102105
'') project)}
103106
104-
eval "''${hpcSumCmd[@]}"
107+
if [ ''${#tixFiles[@]} -ne 0 ]; then
108+
hpcSumCmd+=("''${tixFiles[@]}")
109+
echo "''${hpcSumCmd[@]}"
110+
eval "''${hpcSumCmd[@]}"
111+
fi
105112
106-
# TODO insert project-wide HTML page here
107113
cp ${projectIndexHtml} $out/share/hpc/html/index.html
108114
'';
109115
}

lib/cover.nix

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ in stdenv.mkDerivation {
3232
3333
mkdir -p $out/share/hpc/mix/${identifier}
3434
mkdir -p $out/share/hpc/tix/${identifier}
35+
mkdir -p $out/share/hpc/html/${identifier}
3536
3637
local src=${libraryCovered.src.outPath}
3738
@@ -44,49 +45,54 @@ in stdenv.mkDerivation {
4445
hpcMarkupCmdBase+=("--hpcdir=$mixDir")
4546
done
4647
47-
# Exclude test modules from tix file
48-
excludedModules=('Main')
49-
# Exclude test modules
50-
local cabalFile=$(findCabalFile $src)
51-
testModules="${with lib; concatStringsSep " " (foldl' (acc: test: acc ++ (getTestModulesFor test)) [] testsWithCoverage)}"
52-
for module in $testModules; do
53-
excludedModules+=("$module")
54-
done
48+
${lib.optionalString ((builtins.length tests) > 0) ''
49+
# Exclude test modules from tix file
50+
excludedModules=('Main')
51+
# Exclude test modules
52+
local cabalFile=$(findCabalFile $src)
53+
testModules="${with lib; concatStringsSep " " (foldl' (acc: test: acc ++ (getTestModulesFor test)) [] testsWithCoverage)}"
54+
for module in $testModules; do
55+
excludedModules+=("$module")
56+
done
5557
56-
hpcSumCmdBase=("hpc" "sum" "--union" "--output=$out/share/hpc/tix/${identifier}/${identifier}.tix")
57-
for exclude in ''${excludedModules[@]}; do
58-
hpcSumCmdBase+=("--exclude=$exclude")
59-
hpcMarkupCmdBase+=("--exclude=$exclude")
60-
done
58+
hpcSumCmdBase=("hpc" "sum" "--union" "--output=$out/share/hpc/tix/${identifier}/${identifier}.tix")
59+
for exclude in ''${excludedModules[@]}; do
60+
hpcSumCmdBase+=("--exclude=$exclude")
61+
hpcMarkupCmdBase+=("--exclude=$exclude")
62+
done
6163
62-
hpcMarkupCmdAll=("''${hpcMarkupCmdBase[@]}" "--destdir=$out/share/hpc/html/${identifier}")
64+
hpcMarkupCmdAll=("''${hpcMarkupCmdBase[@]}" "--destdir=$out/share/hpc/html/${identifier}")
6365
64-
hpcSumCmd=("''${hpcSumCmdBase[@]}")
65-
${lib.concatStringsSep "\n" (builtins.map (check: ''
66-
local hpcMarkupCmdEachTest=("''${hpcMarkupCmdBase[@]}" "--destdir=$out/share/hpc/html/${check.exeName}")
66+
hpcSumCmd=("''${hpcSumCmdBase[@]}")
67+
${lib.concatStringsSep "\n" (builtins.map (check: ''
68+
local hpcMarkupCmdEachTest=("''${hpcMarkupCmdBase[@]}" "--destdir=$out/share/hpc/html/${check.exeName}")
6769
68-
pushd ${check}/share/hpc/tix
70+
pushd ${check}/share/hpc/tix
6971
70-
tixFileRel="$(find . -iwholename "*.tix" -type f -print -quit)"
72+
tixFileRel="$(find . -iwholename "*.tix" -type f -print -quit)"
7173
72-
mkdir -p $out/share/hpc/tix/$(dirname $tixFileRel)
73-
cp $tixFileRel $out/share/hpc/tix/$tixFileRel
74-
75-
# Output tix file with test modules excluded
76-
hpcSumCmd+=("$out/share/hpc/tix/$tixFileRel")
74+
mkdir -p $out/share/hpc/tix/$(dirname $tixFileRel)
75+
cp $tixFileRel $out/share/hpc/tix/$tixFileRel
7776
78-
hpcMarkupCmdEachTest+=("$out/share/hpc/tix/$tixFileRel")
77+
# Output tix file with test modules excluded
78+
hpcSumCmd+=("$out/share/hpc/tix/$tixFileRel")
7979
80-
eval "''${hpcMarkupCmdEachTest[@]}"
80+
hpcMarkupCmdEachTest+=("$out/share/hpc/tix/$tixFileRel")
8181
82-
popd
83-
'') checks)
84-
}
82+
echo "''${hpcMarkupCmdEachTest[@]}"
83+
eval "''${hpcMarkupCmdEachTest[@]}"
84+
85+
popd
86+
'') checks)
87+
}
8588
86-
hpcMarkupCmdAll+=("$out/share/hpc/tix/${identifier}/${identifier}.tix")
89+
hpcMarkupCmdAll+=("$out/share/hpc/tix/${identifier}/${identifier}.tix")
8790
88-
eval "''${hpcSumCmd[@]}"
91+
echo "''${hpcSumCmd[@]}"
92+
eval "''${hpcSumCmd[@]}"
8993
90-
eval "''${hpcMarkupCmdAll[@]}"
94+
echo "''${hpcMarkupCmdAll[@]}"
95+
eval "''${hpcMarkupCmdAll[@]}"
96+
''}
9197
'';
9298
}

test/buildable/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ in recurseIntoAttrs {
2020
buildCommand =
2121
(concatStrings (mapAttrsToList (name: value: ''
2222
printf "checking whether executable runs... " >& 2
23-
cat ${haskellLib.check value}
23+
cat ${haskellLib.check value}/test
2424
'') packages.buildable-test.components.exes)) + ''
2525
touch $out
2626
'';

test/cabal-22/default.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ in recurseIntoAttrs {
2525
2626
# fixme: run on target platform when cross-compiled
2727
printf "checking whether executable runs... " >& 2
28-
cat ${haskellLib.check packages.project.components.exes.project}
28+
cat ${haskellLib.check packages.project.components.exes.project}/test
2929
3030
'' +
3131
# Aarch is statically linked and does not produce a .so file.
@@ -55,10 +55,10 @@ in recurseIntoAttrs {
5555
touch $out
5656
5757
printf "checking whether benchmark ran... " >& 2
58-
cat ${haskellLib.check packages.project.components.benchmarks.project-bench}
58+
cat ${haskellLib.check packages.project.components.benchmarks.project-bench}/test
5959
6060
printf "checking whether tests ran... " >& 2
61-
cat ${haskellLib.check packages.project.components.tests.unit}
61+
cat ${haskellLib.check packages.project.components.tests.unit}/test
6262
'';
6363

6464
meta.platforms = platforms.all;

test/cabal-simple/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ in recurseIntoAttrs {
3939
4040
# fixme: run on target platform when cross-compiled
4141
printf "checking whether executable runs... " >& 2
42-
cat ${haskellLib.check packages.cabal-simple.components.exes.cabal-simple}
42+
cat ${haskellLib.check packages.cabal-simple.components.exes.cabal-simple}/test
4343
'' + (if stdenv.hostPlatform.isMusl
4444
then ''
4545
printf "checking that executable is statically linked... " >& 2

test/cabal-source-repo/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in recurseIntoAttrs {
1919
exe="${packages.use-cabal-simple.components.exes.use-cabal-simple}/bin/use-cabal-simple${stdenv.hostPlatform.extensions.executable}"
2020
2121
printf "checking whether executable runs... " >& 2
22-
cat ${haskellLib.check packages.use-cabal-simple.components.exes.use-cabal-simple}
22+
cat ${haskellLib.check packages.use-cabal-simple.components.exes.use-cabal-simple}/test
2323
2424
touch $out
2525
'';

test/cabal-sublib/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ in recurseIntoAttrs {
3535
3636
# fixme: run on target platform when cross-compiled
3737
printf "checking whether executable runs... " >& 2
38-
cat ${haskellLib.check packages.cabal-sublib.components.exes.cabal-sublib}
38+
cat ${haskellLib.check packages.cabal-sublib.components.exes.cabal-sublib}/test
3939
4040
'' +
4141
# Musl and Aarch are statically linked..

test/call-cabal-project-to-nix/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ in recurseIntoAttrs {
2828
exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple${stdenv.hostPlatform.extensions.executable}"
2929
3030
printf "checking whether executable runs... " >& 2
31-
cat ${haskellLib.check packages.cabal-simple.components.exes.cabal-simple}
31+
cat ${haskellLib.check packages.cabal-simple.components.exes.cabal-simple}/test
3232
3333
touch $out
3434
'';

test/call-stack-to-nix/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ in recurseIntoAttrs {
2424
exe="${packages.stack-simple.components.exes.stack-simple-exe}/bin/stack-simple-exe${stdenv.hostPlatform.extensions.executable}"
2525
2626
printf "checking whether executable runs... " >& 2
27-
cat ${haskellLib.check packages.stack-simple.components.exes.stack-simple-exe}
27+
cat ${haskellLib.check packages.stack-simple.components.exes.stack-simple-exe}/test
2828
2929
touch $out
3030
'';

test/exe-only/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ in recurseIntoAttrs {
2525
2626
# fixme: run on target platform when cross-compiled
2727
printf "checking whether executable ran... " >& 2
28-
cat ${haskellLib.check packages.exe-only.components.exes.exe-only}
28+
cat ${haskellLib.check packages.exe-only.components.exes.exe-only}/test
2929
'' +
3030
# Aarch are statically linked and does not have ldd for these tests.
3131
optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64) (

test/extra-hackage/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ in project // (recurseIntoAttrs {
4040
printf "size of executable $exe is $size. \n" >& 2
4141
# fixme: run on target platform when cross-compiled
4242
printf "checking whether executable runs... " >& 2
43-
cat ${haskellLib.check packages.external-package-user.components.exes.external-package-user}
43+
cat ${haskellLib.check packages.external-package-user.components.exes.external-package-user}/test
4444
'' + (if stdenv.hostPlatform.isMusl
4545
then ''
4646
printf "checking that executable is statically linked... " >& 2

test/ghc-options/cabal.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ in recurseIntoAttrs {
2020

2121
buildCommand = ''
2222
printf "checking whether executable runs... " >& 2
23-
cat ${haskellLib.check packages.test-ghc-options.components.exes.test-ghc-options-exe}
23+
cat ${haskellLib.check packages.test-ghc-options.components.exes.test-ghc-options-exe}/test
2424
2525
touch $out
2626
'';

test/ghc-options/stack.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ in recurseIntoAttrs {
2222

2323
buildCommand = ''
2424
printf "checking whether executable runs... " >& 2
25-
cat ${haskellLib.check packages.test-ghc-options.components.exes.test-ghc-options-exe}
25+
cat ${haskellLib.check packages.test-ghc-options.components.exes.test-ghc-options-exe}/test
2626
2727
echo '${concatStringsSep " " packageNames}' > $out
2828
'';

test/project-flags/cabal.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ in recurseIntoAttrs {
2020
exe="${packages.test-project-flags.components.exes.test-project-flags-exe}/bin/test-project-flags-exe${stdenv.hostPlatform.extensions.executable}"
2121
2222
printf "checking whether executable runs... " >& 2
23-
cat ${haskellLib.check packages.test-project-flags.components.exes.test-project-flags-exe}
23+
cat ${haskellLib.check packages.test-project-flags.components.exes.test-project-flags-exe}/test
2424
2525
touch $out
2626
'';

test/project-flags/stack.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in recurseIntoAttrs {
1919
exe="${packages.test-project-flags.components.exes.test-project-flags-exe}/bin/test-project-flags-exe${stdenv.hostPlatform.extensions.executable}"
2020
2121
printf "checking whether executable runs... " >& 2
22-
cat ${haskellLib.check packages.test-project-flags.components.exes.test-project-flags-exe}
22+
cat ${haskellLib.check packages.test-project-flags.components.exes.test-project-flags-exe}/test
2323
2424
touch $out
2525
'';

test/sublib-docs/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ in recurseIntoAttrs {
2525
2626
# fixme: run on target platform when cross-compiled
2727
printf "checking whether executable runs... " >& 2
28-
cat ${haskellLib.check packages.sublib-docs.components.exes.sublib-docs}
28+
cat ${haskellLib.check packages.sublib-docs.components.exes.sublib-docs}/test
2929
3030
'' +
3131
# Musl and Aarch are statically linked..

0 commit comments

Comments
 (0)