summary refs log tree commit diff
path: root/pkgs/test/haskell/setBuildTarget/default.nix
blob: 161cecd9ec37fd9d464ec42dc37b31c2df68a270 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{ pkgs, haskellPackages }: with pkgs.haskell.lib;


let
  drv     = haskellPackages.callCabal2nix "haskell-setBuildTarget" ./. {};
  test    = target: excluded:

    let only = setBuildTarget drv target;
    in ''
         if [[ ! -f "${only}/bin/${target}" ]]; then
           echo "${target} was not built"
           exit 1
         fi

         if [[ -f "${only}/bin/${excluded}" ]]; then
           echo "${excluded} was built, when it should not have been"
           exit 1
         fi
     '';

in pkgs.runCommand "test haskell.lib.setBuildTarget" {} ''
  ${test "foo" "bar"}
  ${test "bar" "foo"}
  touch "$out"
''