Commit 00f5ae06 authored by Jörg Thalheim's avatar Jörg Thalheim
Browse files

nixos/testing: fix testScript eval for functions without `...`

The nspawn container support (23f1e637) added a `containers`
argument to the testScript caller. This breaks tests whose testScript
uses strict pattern matching without ellipsis, e.g. `{ nodes }:`,
since Nix rejects unexpected arguments.

Use `builtins.intersectAttrs` to only pass arguments the function
actually expects, making the caller forward-compatible with future
argument additions.

Fixes: 23f1e637 ("nixos/test-driver: add support for nspawn containers")
parent d2e37478
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -14,6 +14,13 @@ in
  options = {
    testScript = mkOption {
      type = either str (functionTo str);
      apply =
        v:
        if lib.isFunction v then
          # Only pass args the testScript function expects.
          args: v (builtins.intersectAttrs (lib.functionArgs v) args)
        else
          v;
      description = ''
        A series of python declarations and statements that you write to perform
        the test.