Skip to content

Commit cdc0caf

Browse files
committed
Fix coverage reports
1 parent c45c70f commit cdc0caf

File tree

5 files changed

+35
-16
lines changed

5 files changed

+35
-16
lines changed

lib/cover-project.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ in pkgs.runCommand "project-coverage-report"
8282
fi
8383
8484
# Copy mix, tix, and html information over from each report
85-
for f in $report/share/hpc/vanilla/mix/$identifier*; do
85+
for f in $report/share/hpc/vanilla/mix/*; do
8686
cp -Rn $f $out/share/hpc/vanilla/mix
8787
done
8888
cp -R $report/share/hpc/vanilla/tix/* $out/share/hpc/vanilla/tix/

lib/default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,13 @@ in {
9898
# Was there a reference to the package source in the `cabal.project` or `stack.yaml` file.
9999
# This is used to make the default `packages` list for `shellFor`.
100100
isLocalPackage = p: p.isLocal or false;
101-
selectLocalPackages = lib.filterAttrs (_n: p: p != null && isLocalPackage p);
101+
isRedirectPackage = p: p.isRedirect or false;
102+
selectLocalPackages = lib.filterAttrs (_n: p: p != null && isLocalPackage p && !isRedirectPackage p);
102103

103104
# if it's a project package it has a src attribute set with an origSubDir attribute.
104105
# project packages are a subset of localPackages
105106
isProjectPackage = p: p.isProject or false;
106-
selectProjectPackages = lib.filterAttrs (n: p: p != null && !(p.isRedirect or false) && isLocalPackage p && isProjectPackage p);
107+
selectProjectPackages = lib.filterAttrs (_n: p: p != null && isLocalPackage p && isProjectPackage p && !isRedirectPackage p);
107108

108109
# Format a componentId as it should appear as a target on the
109110
# command line of the setup script.

modules/package.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ in
4545
type = types.str;
4646
};
4747

48+
identifier.id = lib.mkOption {
49+
type = types.str;
50+
default = "${config.package.identifier.name}-${config.package.identifier.version}";
51+
};
52+
4853
license = lib.mkOption {
4954
type = types.str;
5055
};
@@ -131,6 +136,12 @@ in
131136
default = false;
132137
};
133138

139+
# Package in `hsPkgs` that is a composite pointing components of the packages keyed by UnitID
140+
isRedirect = lib.mkOption {
141+
type = types.bool;
142+
default = false;
143+
};
144+
134145
isProject = lib.mkOption {
135146
type = types.bool;
136147
default = false;

overlays/haskell.nix

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ final: prev: {
730730
flags = p.flags;
731731
components = getComponents cabal2nix.components hsPkgs p;
732732
package = cabal2nix.package // {
733-
identifier = { name = p.pkg-name; version = p.pkg-version; };
733+
identifier = { name = p.pkg-name; version = p.pkg-version; id = p.id; };
734734
isProject = false;
735735
setup-depends = [];
736736
};
@@ -755,15 +755,21 @@ final: prev: {
755755
} // final.lib.optionalAttrs (p.pkg-src.type or "" == "local") {
756756
src = if final.lib.hasPrefix "/" p.pkg-src.path
757757
then p.pkg-src.path
758-
else callProjectResults.src + final.lib.removeSuffix "/." (final.lib.removeSuffix "/." (
759-
if final.lib.hasPrefix ".${callProjectResults.src.origSubDir or ""}/" (p.pkg-src.path + "/")
760-
then final.lib.removePrefix ".${callProjectResults.src.origSubDir or ""}" p.pkg-src.path
761-
else throw "Unexpected path ${p.pkg-src.path} expected it to start with .${callProjectResults.src.origSubDir or ""}"));
758+
else haskellLib.appendSubDir {
759+
inherit (callProjectResults) src;
760+
subDir = final.lib.removePrefix "/" (final.lib.removeSuffix "/." (final.lib.removeSuffix "/." (
761+
if final.lib.hasPrefix ".${callProjectResults.src.origSubDir or ""}/" (p.pkg-src.path + "/")
762+
then final.lib.removePrefix ".${callProjectResults.src.origSubDir or ""}" p.pkg-src.path
763+
else throw "Unexpected path ${p.pkg-src.path} expected it to start with .${callProjectResults.src.origSubDir or ""}")));
764+
includeSiblings = true; # Filtering sibling dirs of the package dir is done in the
765+
# component builder so that relative paths can be used to
766+
# reference project directories not in the package subDir.
767+
};
762768
} // {
763769
flags = p.flags;
764770
components = getComponents cabal2nix.components hsPkgs p;
765771
package = cabal2nix.package // {
766-
identifier = { name = p.pkg-name; version = p.pkg-version; };
772+
identifier = { name = p.pkg-name; version = p.pkg-version; id = p.id; };
767773
isProject = true;
768774
setup-depends = [];
769775
};
@@ -861,7 +867,8 @@ final: prev: {
861867
in { inherit name value; }
862868
)) componentsByName));
863869
in rec {
864-
identifier = { name = packageName; version = builtins.head versions; };
870+
isRedirect = true;
871+
identifier = rec { name = packageName; version = builtins.head versions; id = "${name}-${version}"; };
865872
components =
866873
final.lib.mapAttrs componentsWithPrefix haskellLib.componentPrefix
867874
// final.lib.optionalAttrs (componentsByName ? lib) {
@@ -963,7 +970,7 @@ final: prev: {
963970
else components.${haskellLib.prefixComponent.${builtins.elemAt m 0}}.${builtins.elemAt m 1};
964971

965972
coverageReport = haskellLib.coverageReport ({
966-
name = package.identifier.name + "-" + package.identifier.version;
973+
name = package.identifier.id;
967974
# Include the checks for a single package.
968975
checks = final.lib.filter (final.lib.isDerivation) (final.lib.attrValues package'.checks);
969976
# Checks from that package may provide coverage information for any library in the project.

test/coverage/default.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@ in recurseIntoAttrs ({
108108
109109
project_basedir="${project.projectCoverageReport}/share/hpc/vanilla"
110110
fileExistsNonEmpty "$project_basedir/html/index.html"
111-
dirExists "$project_basedir/html/pkga-0.1.0.0"
112-
dirExists "$project_basedir/html/pkgb-0.1.0.0"
111+
dirExists "$project_basedir/html/pkga-0.1.0.0-inplace"
112+
dirExists "$project_basedir/html/pkgb-0.1.0.0-inplace"
113113
findFileExistsNonEmpty "$project_basedir/mix/" "PkgA.mix"
114114
findFileExistsNonEmpty "$project_basedir/mix/" "PkgB.mix"
115115
findFileExistsNonEmpty "$project_basedir/mix/" "ConduitExample.mix"
116116
dirExists "$project_basedir/tix/all"
117117
fileExistsNonEmpty "$project_basedir/tix/all/all.tix"
118-
dirExists "$project_basedir/tix/pkga-0.1.0.0"
119-
dirExists "$project_basedir/tix/pkgb-0.1.0.0"
120-
fileExistsNonEmpty "$project_basedir/tix/pkgb-0.1.0.0/pkgb-0.1.0.0.tix"
118+
dirExists "$project_basedir/tix/pkga-0.1.0.0-inplace"
119+
dirExists "$project_basedir/tix/pkgb-0.1.0.0-inplace"
120+
fileExistsNonEmpty "$project_basedir/tix/pkgb-0.1.0.0-inplace/pkgb-0.1.0.0-inplace.tix"
121121
dirExists "$project_basedir/tix/pkgb-test-tests${crossSuffix}-0.1.0.0-check${crossSuffix}"
122122
fileExistsNonEmpty "$project_basedir/tix/pkgb-test-tests${crossSuffix}-0.1.0.0-check${crossSuffix}/tests${exeExt}.tix"
123123
'') ([cabalProj] ++ optional (compiler-nix-name == "ghc865") stackProj))}

0 commit comments

Comments
 (0)