about summary refs log tree commit diff
path: root/tests/fixed.nix.in
blob: 47eff91e059f7cb922f1ae6779587e8fa91257d9 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
rec {

  f2 = dummy: builder: mode: algo: hash: derivation {
    name = "fixed";
    system = "@system@";
    builder = "@shell@";
    args = ["-e" "-x" builder];
    outputHashMode = mode;
    outputHashAlgo = algo;
    outputHash = hash;
    PATH = "@testPath@";
    inherit dummy;
  };

  f = f2 "";

  good = [
    (f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
    (f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b")
    (f ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
    (f ./fixed.builder2.sh "recursive" "sha1" "vw46m23bizj4n8afrc0fj19wrp7mj3c0")
    (f ./fixed.builder2.sh "recursive" "sha256" "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik")
  ];

  good2 = [
    # Yes, this looks fscked up: builder2 doesn't have that result.
    # But Nix sees that an output with the desired hash already
    # exists, and will refrain from building it.
    (f ./fixed.builder2.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
  ];

  bad = [
    (f ./fixed.builder1.sh "flat" "md5" "0ddd8be4b179a529afa5f2ffae4b9858")
  ];

  reallyBad = [
    # Hash too short, and not base-32 either.
    (f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
  ];

  # Test for building two derivations in parallel that produce the
  # same output path because they're fixed-output derivations.
  parallelSame = [
    (f2 "foo" ./fixed.builder2.sh "flat" "md5" "3670af73070fa14077ad74e0f5ea4e42")
    (f2 "bar" ./fixed.builder2.sh "flat" "md5" "3670af73070fa14077ad74e0f5ea4e42")
  ];

}