mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
Add tests for benchmarks and hspec-discover (#181)
* tests: Add benchmarks and hspec-discover to cabal-22 test
This commit is contained in:
parent
dcec48a79b
commit
53c0498ec4
@ -17,5 +17,16 @@
|
||||
components = {
|
||||
"library" = { depends = [ (hsPkgs.base) ]; };
|
||||
exes = { "project" = { depends = [ (hsPkgs.base) (hsPkgs.project) ]; }; };
|
||||
tests = {
|
||||
"unit" = {
|
||||
depends = [ (hsPkgs.base) (hsPkgs.project) (hsPkgs.hspec) ];
|
||||
build-tools = [
|
||||
(hsPkgs.buildPackages.hspec-discover or (pkgs.buildPackages.hspec-discover))
|
||||
];
|
||||
};
|
||||
};
|
||||
benchmarks = {
|
||||
"project-bench" = { depends = [ (hsPkgs.base) (hsPkgs.project) ]; };
|
||||
};
|
||||
};
|
||||
} // rec { src = (pkgs.lib).mkDefault ../.; }
|
@ -1,4 +1,4 @@
|
||||
{ stdenv, mkCabalProjectPkgSet }:
|
||||
{ stdenv, mkCabalProjectPkgSet, util }:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
@ -45,7 +45,17 @@ in
|
||||
otool -L $sofile | grep libHSghc-prim
|
||||
'') + ''
|
||||
touch $out
|
||||
|
||||
printf "checking whether benchmark runs... " >& 2
|
||||
${packages.project.components.benchmarks.project-bench}/*/project-bench
|
||||
|
||||
printf "checking whether tests run... " >& 2
|
||||
${packages.project.components.tests.unit}/*/unit
|
||||
'';
|
||||
|
||||
meta.platforms = platforms.all;
|
||||
} // { inherit (packages) project; }
|
||||
passthru = {
|
||||
inherit (packages) project;
|
||||
shell = util.addCabalInstall packages.project.components.all;
|
||||
};
|
||||
}
|
||||
|
@ -2,9 +2,41 @@
|
||||
pkgs = hackage:
|
||||
{
|
||||
packages = {
|
||||
"tf-random".revision = (((hackage."tf-random")."0.5").revisions).default;
|
||||
"ghc-prim".revision = (((hackage."ghc-prim")."0.5.2.0").revisions).default;
|
||||
"stm".revision = (((hackage."stm")."2.4.5.1").revisions).default;
|
||||
"unix".revision = (((hackage."unix")."2.7.2.2").revisions).default;
|
||||
"rts".revision = (((hackage."rts")."1.0").revisions).default;
|
||||
"clock".revision = (((hackage."clock")."0.8").revisions).default;
|
||||
"clock".flags.llvm = false;
|
||||
"QuickCheck".revision = (((hackage."QuickCheck")."2.13.1").revisions).default;
|
||||
"QuickCheck".flags.templatehaskell = true;
|
||||
"hspec-discover".revision = (((hackage."hspec-discover")."2.7.1").revisions).default;
|
||||
"deepseq".revision = (((hackage."deepseq")."1.4.3.0").revisions).default;
|
||||
"random".revision = (((hackage."random")."1.1").revisions).default;
|
||||
"splitmix".revision = (((hackage."splitmix")."0.0.2").revisions).default;
|
||||
"HUnit".revision = (((hackage."HUnit")."1.6.0.0").revisions).default;
|
||||
"directory".revision = (((hackage."directory")."1.3.1.5").revisions).default;
|
||||
"template-haskell".revision = (((hackage."template-haskell")."2.13.0.0").revisions).default;
|
||||
"hspec-expectations".revision = (((hackage."hspec-expectations")."0.8.2").revisions).default;
|
||||
"call-stack".revision = (((hackage."call-stack")."0.1.0").revisions).default;
|
||||
"primitive".revision = (((hackage."primitive")."0.7.0.0").revisions).default;
|
||||
"ansi-terminal".revision = (((hackage."ansi-terminal")."0.9.1").revisions).default;
|
||||
"ansi-terminal".flags.example = false;
|
||||
"containers".revision = (((hackage."containers")."0.5.11.0").revisions).default;
|
||||
"bytestring".revision = (((hackage."bytestring")."0.10.8.2").revisions).default;
|
||||
"setenv".revision = (((hackage."setenv")."0.1.1.3").revisions).default;
|
||||
"base".revision = (((hackage."base")."4.11.1.0").revisions).default;
|
||||
"hspec".revision = (((hackage."hspec")."2.7.1").revisions).default;
|
||||
"time".revision = (((hackage."time")."1.8.0.2").revisions).default;
|
||||
"transformers".revision = (((hackage."transformers")."0.5.6.2").revisions).default;
|
||||
"quickcheck-io".revision = (((hackage."quickcheck-io")."0.2.0").revisions).default;
|
||||
"colour".revision = (((hackage."colour")."2.3.5").revisions).default;
|
||||
"filepath".revision = (((hackage."filepath")."1.4.2").revisions).default;
|
||||
"hspec-core".revision = (((hackage."hspec-core")."2.7.1").revisions).default;
|
||||
"pretty".revision = (((hackage."pretty")."1.1.3.6").revisions).default;
|
||||
"ghc-boot-th".revision = (((hackage."ghc-boot-th")."8.4.4").revisions).default;
|
||||
"array".revision = (((hackage."array")."0.5.2.0").revisions).default;
|
||||
"integer-gmp".revision = (((hackage."integer-gmp")."1.0.2.0").revisions).default;
|
||||
};
|
||||
compiler = {
|
||||
@ -12,8 +44,20 @@
|
||||
nix-name = "ghc844";
|
||||
packages = {
|
||||
"ghc-prim" = "0.5.2.0";
|
||||
"stm" = "2.4.5.1";
|
||||
"unix" = "2.7.2.2";
|
||||
"rts" = "1.0";
|
||||
"deepseq" = "1.4.3.0";
|
||||
"directory" = "1.3.1.5";
|
||||
"template-haskell" = "2.13.0.0";
|
||||
"containers" = "0.5.11.0";
|
||||
"bytestring" = "0.10.8.2";
|
||||
"base" = "4.11.1.0";
|
||||
"time" = "1.8.0.2";
|
||||
"filepath" = "1.4.2";
|
||||
"pretty" = "1.1.3.6";
|
||||
"ghc-boot-th" = "8.4.4";
|
||||
"array" = "0.5.2.0";
|
||||
"integer-gmp" = "1.0.2.0";
|
||||
};
|
||||
};
|
||||
|
@ -15,17 +15,31 @@ maintainer: rodney.lorrimar@iohk.io
|
||||
|
||||
library
|
||||
exposed-modules: Lib
|
||||
-- other-modules:
|
||||
-- other-extensions:
|
||||
build-depends: base ^>=4.11.1.0
|
||||
hs-source-dirs: lib
|
||||
default-language: Haskell2010
|
||||
|
||||
executable project
|
||||
main-is: Main.hs
|
||||
-- other-modules:
|
||||
-- other-extensions:
|
||||
build-depends: base ^>=4.11.1.0
|
||||
, project
|
||||
-- hs-source-dirs:
|
||||
default-language: Haskell2010
|
||||
|
||||
benchmark project-bench
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: Main.hs
|
||||
build-depends: base ^>=4.11.1.0
|
||||
, project
|
||||
default-language: Haskell2010
|
||||
ghc-options: -threaded -rtsopts -Wall -O2
|
||||
|
||||
test-suite unit
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: Main.hs
|
||||
build-depends: base ^>=4.11.1.0
|
||||
, project
|
||||
, hspec
|
||||
build-tools: hspec-discover
|
||||
other-modules: LibSpec
|
||||
default-language: Haskell2010
|
||||
hs-source-dirs: test
|
||||
|
@ -17,5 +17,16 @@
|
||||
components = {
|
||||
"library" = { depends = [ (hsPkgs.base) ]; };
|
||||
exes = { "project" = { depends = [ (hsPkgs.base) (hsPkgs.project) ]; }; };
|
||||
tests = {
|
||||
"unit" = {
|
||||
depends = [ (hsPkgs.base) (hsPkgs.project) (hsPkgs.hspec) ];
|
||||
build-tools = [
|
||||
(hsPkgs.buildPackages.hspec-discover or (pkgs.buildPackages.hspec-discover))
|
||||
];
|
||||
};
|
||||
};
|
||||
benchmarks = {
|
||||
"project-bench" = { depends = [ (hsPkgs.base) (hsPkgs.project) ]; };
|
||||
};
|
||||
};
|
||||
} // rec { src = (pkgs.lib).mkDefault ./.; }
|
||||
|
11
test/cabal-22/test/LibSpec.hs
Normal file
11
test/cabal-22/test/LibSpec.hs
Normal file
@ -0,0 +1,11 @@
|
||||
module LibSpec
|
||||
( spec
|
||||
) where
|
||||
|
||||
import Test.Hspec
|
||||
import Lib
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Lib message" $
|
||||
it "should greet appropriately" $
|
||||
message `shouldContain` "Hello"
|
1
test/cabal-22/test/Main.hs
Normal file
1
test/cabal-22/test/Main.hs
Normal file
@ -0,0 +1 @@
|
||||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
|
@ -12,7 +12,7 @@ in pkgs.recurseIntoAttrs {
|
||||
cabal-simple = haskell.callPackage ./cabal-simple { inherit util; };
|
||||
cabal-simple-prof = haskell.callPackage ./cabal-simple-prof { inherit util; };
|
||||
cabal-sublib = haskell.callPackage ./cabal-sublib { inherit util; };
|
||||
cabal-22 = haskell.callPackage ./cabal-22 {};
|
||||
cabal-22 = haskell.callPackage ./cabal-22 { inherit util; };
|
||||
with-packages = haskell.callPackage ./with-packages { inherit util; };
|
||||
builder-haddock = haskell.callPackage ./builder-haddock {};
|
||||
stack-simple = haskell.callPackage ./stack-simple {};
|
||||
|
@ -189,4 +189,4 @@
|
||||
{
|
||||
packages = { pkga = ./.plan.nix/pkga.nix; pkgb = ./.plan.nix/pkgb.nix; };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,15 @@ nix-shell $NIX_BUILD_ARGS \
|
||||
--run 'echo CABAL_CONFIG=$CABAL_CONFIG && echo GHC_ENVIRONMENT=$GHC_ENVIRONMENT && cd with-packages && cabal new-build'
|
||||
echo >& 2
|
||||
|
||||
printf "*** Checking that a nix-shell works for a project with test-suite build-tools and benchmarks...\n" >& 2
|
||||
printf "!!! This is expected to fail until https://github.com/input-output-hk/haskell.nix/issues/231 is resolved! \n" >& 2
|
||||
nix-shell $NIX_BUILD_ARGS \
|
||||
--pure ./default.nix \
|
||||
-A cabal-22.shell \
|
||||
--run 'cd cabal-22 && cabal new-build all --enable-tests --enable-benchmarks' \
|
||||
|| true
|
||||
echo >& 2
|
||||
|
||||
printf "*** Checking that a nix-shell works for a multi-target project...\n" >& 2
|
||||
nix-shell $NIX_BUILD_ARGS \
|
||||
--pure ./default.nix \
|
||||
|
Loading…
Reference in New Issue
Block a user