summary refs log tree commit diff stats
path: root/tests.nix
blob: d91a9c92f532fc8172ed47c2946d04a213970ff5 (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
{
  pkgs,
  lib,
  specialArgs,
}: let
  # for `nix eval --file` (as it does not support args) use:
  # ```
  # specialArgs = {};
  # pkgs = (builtins.getFlake "nixpkgs").legacyPackages."x86_64-linux";
  # inherit (pkgs) lib;
  # ```
  # instead of the function arguments above.
  importTests' = test: let
    basename = builtins.baseNameOf test;
    testName = builtins.baseNameOf (lib.strings.removeSuffix "/${basename}" "${builtins.toString test}");
  in {
    name = "${testName}";
    value = pkgs.callPackage test specialArgs;
  };

  importTests = dir:
    builtins.listToAttrs (builtins.map importTests' (
      lib.fileset.toList (lib.fileset.fileFilter (file: file.name == "test.nix") dir)
    ));

  tests = importTests ./tests;
in
  tests