File tree Expand file tree Collapse file tree 5 files changed +108
-2
lines changed Expand file tree Collapse file tree 5 files changed +108
-2
lines changed Original file line number Diff line number Diff line change 173
173
type = attrsOf ( componentType false ) ;
174
174
default = { } ;
175
175
} ;
176
+ # all = mkOption {
177
+ # type = componentType false;
178
+ # };
176
179
} ;
177
180
178
181
name = mkOption {
Original file line number Diff line number Diff line change 13
13
# The new Haskell infra applied to nix representation of Hackage
14
14
haskell = import ../. hackage ;
15
15
16
+ haskellLib = let hl = import ../lib { inherit lib ; haskellLib = hl ; } ; in hl ;
17
+
16
18
in {
17
19
cabal-simple = callPackage ./cabal-simple { inherit haskell ; } ;
18
20
cabal-22 = callPackage ./cabal-22 { inherit haskell ; } ;
19
21
with-packages = callPackage ./with-packages { inherit haskell ; } ;
22
+
23
+ # Run unit tests with: nix-instantiate --eval --strict -A unit
24
+ # An empty list means success.
25
+ unit = callPackage ./unit.nix { inherit haskellLib ; } ;
20
26
}
21
27
22
28
## possible test cases
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env nix-shell
2
+ #! nix-shell -i bash -p bash jq nix
3
+
4
+ set -euo pipefail
5
+
6
+ cd $( dirname $0 )
7
+
8
+ printf " *** Running the nix-build tests...\n" >& 2
9
+ nix-build --no-out-link --keep-going ./default.nix
10
+ echo >& 2
11
+
12
+ printf " *** Running the unit tests... " >& 2
13
+ res=$( nix-instantiate --eval --json --strict ./default.nix -A unit)
14
+ num_failed=$( jq length <<< " $res" )
15
+ if [ $num_failed -eq 0 ]; then
16
+ printf " PASSED\n" >& 2
17
+ else
18
+ printf " $num_failed FAILED\n" >& 2
19
+ jq . <<< " $res"
20
+ exit 1
21
+ fi
22
+
23
+ printf " *** Checking that a nix-shell works for cabal...\n" >& 2
24
+ nix-shell --pure ./default.nix \
25
+ -A with-packages.test-shell \
26
+ --run ' echo CABAL_CONFIG=$CABAL_CONFIG && cd with-packages && cabal new-build'
27
+
28
+ printf " \n*** Finished successfully\n" >& 2
Original file line number Diff line number Diff line change
1
+ { lib , haskellLib } :
2
+
3
+ let
4
+ emptyConfig = {
5
+ components = {
6
+ benchmarks = { } ;
7
+ exes = { } ;
8
+ foreignlibs = { } ;
9
+ library = "library" ;
10
+ sublibs = { } ;
11
+ tests = { } ;
12
+ } ;
13
+ package . identifier . name = "empty" ;
14
+ } ;
15
+
16
+ componentsConfig = {
17
+ components = {
18
+ benchmarks = { bbb = "bbb" ; } ;
19
+ exes = { eee = "eee" ; } ;
20
+ foreignlibs = { fff = "fff" ; } ;
21
+ library = "library" ;
22
+ sublibs = { } ;
23
+ tests = { ttt = "ttt" ; } ;
24
+ } ;
25
+ package . identifier . name = "nnn" ;
26
+ } ;
27
+
28
+ in
29
+ lib . runTests {
30
+ test-applyComponents-id = {
31
+ expr = haskellLib . applyComponents ( componentId : component : component ) emptyConfig ;
32
+ expected = emptyConfig . components ;
33
+ } ;
34
+
35
+ test-applyComponents-library = {
36
+ expr = haskellLib . applyComponents ( componentId : component : componentId . cname ) emptyConfig ;
37
+ expected = emptyConfig . components // { library = "empty" ; } ;
38
+ } ;
39
+
40
+ test-applyComponents-components = {
41
+ expr = haskellLib . applyComponents ( componentId : component : component ) componentsConfig ;
42
+ expected = componentsConfig . components ;
43
+ } ;
44
+
45
+ # testing that the tests work
46
+ testId = {
47
+ expr = lib . id 1 ;
48
+ expected = 1 ;
49
+ } ;
50
+ }
Original file line number Diff line number Diff line change 32
32
33
33
buildCommand = let
34
34
inherit ( packages . test-with-packages . components ) library ;
35
+ # inherit (packages.test-with-packages.components) all; # TODO
35
36
inherit ( packages . test-with-packages ) devEnv ;
36
37
in ''
37
38
########################################################################
38
39
# test with-packages
39
40
40
- printf "checking that package env has the dependencies... " >& 2
41
+ printf "checking that the package env has the dependencies... " >& 2
41
42
${ devEnv } /bin/runghc ${ ./Point.hs }
42
43
echo
43
44
45
+ # # fixme: probably don't want separate derivation for this -- just use all
46
+ # printf "checking that components.library.shell has the dependencies... " >& 2
47
+ # '' ${library.shell}/bin/runghc ${ ./Point.hs }
48
+ # echo
49
+
50
+ # printf "checking that components.all.shell has the dependencies... " >& 2
51
+ # '' ${all.shell}/bin/runghc ${ ./Point.hs }
52
+ # echo
53
+
44
54
touch $out
45
55
'' ;
46
56
47
57
meta . platforms = platforms . all ;
48
- } // { inherit packages pkgSet ; }
58
+ } // {
59
+ # Used for debugging with nix repl
60
+ inherit packages pkgSet ;
61
+
62
+ # Used for testing externally with nix-shell (../tests.sh).
63
+ # This just adds cabal-install to the existing shell.
64
+ test-shell = pkgSet . config . hsPkgs . test-with-packages . components . library . overrideAttrs ( oldAttrs : {
65
+ buildInputs = ( oldAttrs . buildInputs or [ ] ) ++ [ pkgs . cabal-install ] ;
66
+ } ) ;
67
+ }
You can’t perform that action at this time.
0 commit comments