about summary refs log tree commit diff
path: root/nix/dependency-analyzer/tests/default.nix
blob: 79ac127e922f6d5e9e08177c9b2ac58aad0f27bf (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
{ depot, lib, ... }:

let
  inherit (depot.nix.runTestsuite)
    runTestsuite
    assertEq
    it
    ;

  inherit (depot.nix.dependency-analyzer)
    plainDrvDepMap
    drvsToPaths
    ;

  knownDrvs = drvsToPaths (
    builtins.filter lib.isDerivation (builtins.attrValues depot.third_party.lisp)
  );
  exampleMap = plainDrvDepMap knownDrvs;

  # These will be needed to index into the attribute set which can't have context
  # in the attribute names.
  knownDrvsNoContext = builtins.map builtins.unsafeDiscardStringContext knownDrvs;
in

runTestsuite "dependency-analyzer" [
  (it "checks plainDrvDepMap properties" [
    (assertEq "all known drvs are marked known"
      (builtins.all (drv: exampleMap.${drv}.known) knownDrvsNoContext)
      true)
    (assertEq "no unknown drv is marked known"
      (builtins.all (entry: !entry.known) (
        builtins.attrValues (builtins.removeAttrs exampleMap knownDrvsNoContext)
      ))
      true)
  ])
]