mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
Add golden coverage test (#964)
* Add golden coverage test - Other coverage tests check that the coverage tests can be generated, but don't check the coverage output itself. This commit adds a test to ensure that the coverage output is correct. * Use niv and haskell.nix for hpc-coveralls * Get `sources` from `haskell-nix.callPackages` * Use `builtin: false` for hydra in sources.json * Fix for cross compilation. Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
This commit is contained in:
parent
fed18267e0
commit
ce0187b2a4
@ -12,6 +12,19 @@
|
||||
"url": "https://github.com/haskell/cabal/archive/94aaa8e4720081f9c75497e2735b90f6a819b08e.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"cardano-shell": {
|
||||
"branch": "master",
|
||||
"builtin": false,
|
||||
"description": "Node shell, a thin layer for running the node and it's modules.",
|
||||
"homepage": null,
|
||||
"owner": "input-output-hk",
|
||||
"repo": "cardano-shell",
|
||||
"rev": "8e0d6f5548c1c13a9edfeb56e4ea27c0a6d10948",
|
||||
"sha256": "07yjl3agiacmy5irxxmrmm7ffpnvz84zgrylnp3wmcrn417pc5fq",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/cardano-shell/archive/8e0d6f5548c1c13a9edfeb56e4ea27c0a6d10948.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"ghc-8.6.5-iohk": {
|
||||
"branch": "release/8.6.5-iohk",
|
||||
"deepClone": true,
|
||||
@ -26,6 +39,19 @@
|
||||
"url": "https://github.com/input-output-hk/ghc.git",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"hpc-coveralls": {
|
||||
"branch": "master",
|
||||
"builtin": false,
|
||||
"description": "coveralls.io support for haskell code coverage with hpc",
|
||||
"homepage": "http://hackage.haskell.org/package/hpc-coveralls",
|
||||
"owner": "sevanspowell",
|
||||
"repo": "hpc-coveralls",
|
||||
"rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430",
|
||||
"sha256": "02dmcmqc845s7sdgdnk3xxn7l6jj8faa7547b4cii9mgv09arspj",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/sevanspowell/hpc-coveralls/archive/14df0f7d229f4cd2e79f8eabb1a740097fdfa430.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"niv": {
|
||||
"branch": "master",
|
||||
"builtin": false,
|
||||
|
50
test/coverage-golden/default.nix
Normal file
50
test/coverage-golden/default.nix
Normal file
@ -0,0 +1,50 @@
|
||||
{ stdenv, fetchFromGitHub, recurseIntoAttrs, runCommand, testSrc, compiler-nix-name, buildPackages, sources }:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
# Using buildPackages.buildPackages here because buildPackages.git
|
||||
# is built with a cross compiler version of gdb (needed by python).
|
||||
# So buildPackages.buildPackages.git is more likely to be in the cache.
|
||||
inherit (buildPackages.buildPackages) jq git;
|
||||
|
||||
hpc-coveralls-exes = (buildPackages.haskell-nix.project' {
|
||||
compiler-nix-name = "ghc865"; # TODO use `inherit compiler-nix-name;` once it is working with 8.8 and 8.10
|
||||
src = sources.hpc-coveralls;
|
||||
}).hsPkgs.hpc-coveralls.components.exes;
|
||||
|
||||
exampleProjectSrc = sources.cardano-shell;
|
||||
|
||||
exampleProject = import "${exampleProjectSrc}" { config = { haskellNix = { coverage = true; }; }; };
|
||||
exampleCoverageReport = exampleProject.cardanoShellHaskellPackages.projectCoverageReport;
|
||||
|
||||
in recurseIntoAttrs ({
|
||||
run = stdenv.mkDerivation {
|
||||
name = "coverage-golden-test";
|
||||
|
||||
nativeBuildInputs = [ git jq hpc-coveralls-exes.hpc-coveralls hpc-coveralls-exes.run-cabal-test ];
|
||||
buildCommand = ''
|
||||
########################################################################
|
||||
# Test that the coverage reports haven't materially changed
|
||||
|
||||
TRAVIS=1 TRAVIS_JOB_ID=1 hpc-coveralls all \
|
||||
--package-dir ${exampleProjectSrc}/cardano-shell/ \
|
||||
--package-dir ${exampleProjectSrc}/cardano-launcher \
|
||||
--hpc-dir ${exampleCoverageReport}/share/hpc/vanilla \
|
||||
--coverage-mode StrictlyFullLines \
|
||||
--dont-send
|
||||
|
||||
# Format JSON for better diffing error messages and remove
|
||||
# references to Nix path, our golden coverage file contains no
|
||||
# Nix paths
|
||||
cat ./travis-ci-1.json | jq -S | sed "s;${exampleProjectSrc}/;;g" > ./actual.json
|
||||
|
||||
# Fail if doesn't match golden, i.e. our coverage has changed
|
||||
diff ${./golden.json} ./actual.json
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
||||
meta.platforms = platforms.all;
|
||||
};
|
||||
})
|
2069
test/coverage-golden/golden.json
Normal file
2069
test/coverage-golden/golden.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -193,6 +193,7 @@ let
|
||||
} // lib.optionalAttrs (!stdenv.hostPlatform.isGhcjs) {
|
||||
# These do not work on ghcjs because it needs zlib.
|
||||
coverage = callTest ./coverage { inherit compiler-nix-name; };
|
||||
coverage-golden = callTest ./coverage-golden { inherit compiler-nix-name;};
|
||||
coverage-no-libs = callTest ./coverage-no-libs { inherit compiler-nix-name; };
|
||||
snapshots = callTest ./snapshots {};
|
||||
} // lib.optionalAttrs (!stdenv.hostPlatform.isGhcjs && compiler-nix-name != "ghc8101" && compiler-nix-name != "ghc8102" && compiler-nix-name != "ghc810220201118" ) {
|
||||
|
Loading…
Reference in New Issue
Block a user