on iko/ghcjs-patch-master help sign in
tests: Add test cases for dev environments
commitce0f5e03930affddc25d75044478fc430897c121 authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateWed 30 Jan 2019, 15:28 (8 years ago) parent8642fac
8 files changed+239
test/default.nix+1 test/with-packages/Point.hs+12 test/with-packages/Setup.hs+2 test/with-packages/TestWithPackages.hs+6 test/with-packages/default.nix+68 test/with-packages/plan.nix+99 test/with-packages/test-with-packages.cabal+15 test/with-packages/test-with-packages.nix+36
test/default.nix+1
@@ -18,6 +18,7 @@ let
1818in {
1919 cabal-simple = callPackage ./cabal-simple { inherit haskell; };
2020 cabal-22 = callPackage ./cabal-22 { inherit haskell; };
21+ with-packages = callPackage ./with-packages { inherit haskell; };
2122
2223 # Run unit tests with: nix-instantiate --eval --strict -A unit
2324 # An empty list means success.
test/with-packages/Point.hsnew file+12
@@ -0,0 +1,12 @@
1+{-# LANGUAGE TemplateHaskell #-}
2+module Main where
3+
4+import Control.Lens
5+
6+data Point = Point { _x :: Double, _y :: Double }
7+makeLenses ''Point
8+
9+main :: IO ()
10+main = print (point^.x + point^.y)
11+ where
12+ point = Point { _x = 40.0, _y = 2.0 }
test/with-packages/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
test/with-packages/TestWithPackages.hsnew file+6
@@ -0,0 +1,6 @@
1+-- | Haddock test stuff
2+module TestWithPackages (hello) where
3+
4+-- | Standard hello text.
5+hello :: String
6+hello = "Hello, world!"
test/with-packages/default.nixnew file+68
@@ -0,0 +1,68 @@
1+{ pkgs
2+, haskell
3+, stdenv
4+}:
5+
6+with stdenv.lib;
7+
8+let
9+ pkgSet = haskell.mkPkgSet {
10+ inherit pkgs;
11+ # generated with:
12+ # cabal new-build
13+ # plan-to-nix dist-newstyle/cache/plan.json > plan.nix
14+ # cabal-to-nix test-with-packages.cabal > test-with-packages.nix
15+ pkg-def = import ./plan.nix;
16+ pkg-def-overlays = [
17+ { test-with-packages = ./test-with-packages.nix; }
18+ ];
19+ modules = [
20+ # overrides to fix the build
21+ {
22+ packages.transformers-compat.components.library.doExactConfig = true;
23+ }
24+ ];
25+ };
26+
27+ packages = pkgSet.config.hsPkgs;
28+
29+ # Add cabal as a buildInput for a haskell derivation. Useful for nix-shell.
30+ addCabalInstall = drv: drv.overrideAttrs (oldAttrs: {
31+ buildInputs = (oldAttrs.buildInputs or []) ++ [ pkgs.cabal-install ];
32+ });
33+
34+in
35+ stdenv.mkDerivation {
36+ name = "with-packages-test";
37+
38+ buildCommand = let
39+ package = packages.test-with-packages;
40+ inherit (package.components) library;
41+ in ''
42+ ########################################################################
43+ # test with-packages
44+
45+ printf "checking that the 'all' component works... " >& 2
46+ echo ${package.components.all}
47+ # echo >& 2
48+
49+ printf "checking that the package env has the dependencies... " >& 2
50+ ${package.components.all.env}/bin/runghc ${./Point.hs}
51+ echo >& 2
52+
53+ printf "checking that components.library.env has the dependencies... " >& 2
54+ ${library.env}/bin/runghc ${./Point.hs}
55+ # echo >& 2
56+
57+ touch $out
58+ '';
59+
60+ meta.platforms = platforms.all;
61+} // {
62+ # Used for debugging with nix repl
63+ inherit packages pkgSet;
64+
65+ # Used for testing externally with nix-shell (../tests.sh).
66+ # This just adds cabal-install to the existing shells.
67+ test-shell = addCabalInstall packages.test-with-packages.components.all;
68+}
test/with-packages/plan.nixnew file+99
@@ -0,0 +1,99 @@
1+hackage:
2+ {
3+ packages = {
4+ "void".revision = hackage."void"."0.7.2".revisions.default;
5+ "semigroupoids".revision = hackage."semigroupoids"."5.2.2".revisions.default;
6+ "free".revision = hackage."free"."5.0.2".revisions.default;
7+ "exceptions".revision = hackage."exceptions"."0.10.0".revisions.default;
8+ "binary".revision = hackage."binary"."0.8.5.1".revisions.default;
9+ "ghc-prim".revision = hackage."ghc-prim"."0.5.2.0".revisions.default;
10+ "bifunctors".revision = hackage."bifunctors"."5.5.3".revisions.default;
11+ "stm".revision = hackage."stm"."2.4.5.1".revisions.default;
12+ "mtl".revision = hackage."mtl"."2.2.2".revisions.default;
13+ "rts".revision = hackage."rts"."1.0".revisions.default;
14+ "adjunctions".revision = hackage."adjunctions"."4.4".revisions.default;
15+ "invariant".revision = hackage."invariant"."0.5.1".revisions.default;
16+ "distributive".revision = hackage."distributive"."0.5.3".revisions.default;
17+ "parallel".revision = hackage."parallel"."3.2.2.0".revisions.default;
18+ "deepseq".revision = hackage."deepseq"."1.4.3.0".revisions.default;
19+ "semigroups".revision = hackage."semigroups"."0.18.5".revisions.default;
20+ "transformers-compat".revision = hackage."transformers-compat"."0.6.2".revisions.default;
21+ "template-haskell".revision = hackage."template-haskell"."2.13.0.0".revisions.default;
22+ "vector".revision = hackage."vector"."0.12.0.1".revisions.default;
23+ "call-stack".revision = hackage."call-stack"."0.1.0".revisions.default;
24+ "primitive".revision = hackage."primitive"."0.6.3.0".revisions.default;
25+ "profunctors".revision = hackage."profunctors"."5.2.2".revisions.default;
26+ "tagged".revision = hackage."tagged"."0.8.5".revisions.default;
27+ "lens".revision = hackage."lens"."4.16.1".revisions.default;
28+ "containers".revision = hackage."containers"."0.5.11.0".revisions.default;
29+ "reflection".revision = hackage."reflection"."2.1.4".revisions.default;
30+ "bytestring".revision = hackage."bytestring"."0.10.8.2".revisions.default;
31+ "StateVar".revision = hackage."StateVar"."1.1.1.1".revisions.default;
32+ "contravariant".revision = hackage."contravariant"."1.4.1".revisions.default;
33+ "text".revision = hackage."text"."1.2.3.1".revisions.default;
34+ "unordered-containers".revision = hackage."unordered-containers"."0.2.9.0".revisions.default;
35+ "base".revision = hackage."base"."4.11.1.0".revisions.default;
36+ "comonad".revision = hackage."comonad"."5.0.4".revisions.default;
37+ "transformers".revision = hackage."transformers"."0.5.5.0".revisions.default;
38+ "hashable".revision = hackage."hashable"."1.2.7.0".revisions.default;
39+ "transformers-base".revision = hackage."transformers-base"."0.4.5.2".revisions.default;
40+ "filepath".revision = hackage."filepath"."1.4.2".revisions.default;
41+ "kan-extensions".revision = hackage."kan-extensions"."5.2".revisions.default;
42+ "pretty".revision = hackage."pretty"."1.1.3.6".revisions.default;
43+ "ghc-boot-th".revision = hackage."ghc-boot-th"."8.4.4".revisions.default;
44+ "base-orphans".revision = hackage."base-orphans"."0.7".revisions.default;
45+ "th-abstraction".revision = hackage."th-abstraction"."0.2.8.0".revisions.default;
46+ "array".revision = hackage."array"."0.5.2.0".revisions.default;
47+ "integer-gmp".revision = hackage."integer-gmp"."1.0.2.0".revisions.default;
48+ };
49+ compiler = {
50+ version = "8.4.4";
51+ nix-name = "ghc844";
52+ packages = {
53+ "void" = "0.7.2";
54+ "semigroupoids" = "5.2.2";
55+ "free" = "5.0.2";
56+ "exceptions" = "0.10.0";
57+ "binary" = "0.8.5.1";
58+ "ghc-prim" = "0.5.2.0";
59+ "bifunctors" = "5.5.3";
60+ "stm" = "2.4.5.1";
61+ "mtl" = "2.2.2";
62+ "rts" = "1.0";
63+ "adjunctions" = "4.4";
64+ "invariant" = "0.5.1";
65+ "distributive" = "0.5.3";
66+ "parallel" = "3.2.2.0";
67+ "deepseq" = "1.4.3.0";
68+ "semigroups" = "0.18.5";
69+ "transformers-compat" = "0.6.2";
70+ "template-haskell" = "2.13.0.0";
71+ "vector" = "0.12.0.1";
72+ "call-stack" = "0.1.0";
73+ "primitive" = "0.6.3.0";
74+ "profunctors" = "5.2.2";
75+ "tagged" = "0.8.5";
76+ "lens" = "4.16.1";
77+ "containers" = "0.5.11.0";
78+ "reflection" = "2.1.4";
79+ "bytestring" = "0.10.8.2";
80+ "StateVar" = "1.1.1.1";
81+ "contravariant" = "1.4.1";
82+ "text" = "1.2.3.1";
83+ "unordered-containers" = "0.2.9.0";
84+ "base" = "4.11.1.0";
85+ "comonad" = "5.0.4";
86+ "transformers" = "0.5.5.0";
87+ "hashable" = "1.2.7.0";
88+ "transformers-base" = "0.4.5.2";
89+ "filepath" = "1.4.2";
90+ "kan-extensions" = "5.2";
91+ "pretty" = "1.1.3.6";
92+ "ghc-boot-th" = "8.4.4";
93+ "base-orphans" = "0.7";
94+ "th-abstraction" = "0.2.8.0";
95+ "array" = "0.5.2.0";
96+ "integer-gmp" = "1.0.2.0";
97+ };
98+ };
99+ }
test/with-packages/test-with-packages.cabalnew file+15
@@ -0,0 +1,15 @@
1+cabal-version: 2.2
2+name: test-with-packages
3+version: 0.1.0.0
4+license: NONE
5+author: Rodney Lorrimar
6+maintainer: rodney.lorrimar@iohk.io
7+
8+library
9+ exposed-modules: TestWithPackages
10+ -- other-modules:
11+ -- other-extensions:
12+ build-depends: base ^>=4.11.1.0
13+ , lens
14+ -- hs-source-dirs:
15+ default-language: Haskell2010
test/with-packages/test-with-packages.nixnew file+36
@@ -0,0 +1,36 @@
1+{ system
2+, compiler
3+, flags
4+, pkgs
5+, hsPkgs
6+, pkgconfPkgs
7+, ... }:
8+ {
9+ flags = {};
10+ package = {
11+ specVersion = "2.2";
12+ identifier = {
13+ name = "test-with-packages";
14+ version = "0.1.0.0";
15+ };
16+ license = "NONE";
17+ copyright = "";
18+ maintainer = "rodney.lorrimar@iohk.io";
19+ author = "Rodney Lorrimar";
20+ homepage = "";
21+ url = "";
22+ synopsis = "";
23+ description = "";
24+ buildType = "Simple";
25+ };
26+ components = {
27+ "library" = {
28+ depends = [
29+ (hsPkgs.base)
30+ (hsPkgs.lens)
31+ ];
32+ };
33+ };
34+ } // rec {
35+ src = pkgs.lib.mkDefault ./.;
36+ }