Allows using the `callPackage(s)` pattern on tests.
Rather than using `pkgs.callPackage`, we implement our own variant using
`lib.callPackageWith`.
Our variant (`callTest`) includes additional nixvim-specific stuff
commonly used by our tests.
Move the previous `default.nix` to `main.nix` so that `default.nix` can
be used for defining the set of all test derivations.
`main.nix` is imported by `default.nix`, but is only responsible for the
tests built from `tests/test-sources/`.
Since the module system is importing an anonymous fnOrAttr module,
instead of a `path` type module, it doesn't have enough context to
figure out the module's file automatically.
Simplify by reducing the number of transformations done to the
test-files' test-case modules attr.
Since `pkgs.linkFarm` can accept _either_ a list or an attrset, we don't
need to transform the attrset into a list.
Introduces the `test.runNvim` module option.
Deprecates the historic `dontRun` argument passed to the test-derivation
helpers.
Soft-deprecates the `tests.dontRun` attr used in tests currently.
`def.module or lib.removeAttrs def [ "tests" ]` is actually equivalent to
`(def.module or lib.removeAttrs) def [ "tests" ]`.
This meant whenever `def` had a `module` attribute, it was invoked as
`def.module def [ "tests" ]`!
Use `mkTestDerivationFromNixvimModule` instead of `mkTestDerivation`,
allowing "proper" modules to be used instead of plain attr configs.
This is useful for more complex tests that wish to use `config` or
`options` arguments, e.g:
```nix
{config, options, ...}: {
/* some cool test */
}
```
To allow `tests.dontRun` to be defined on such a test, the module is
allowed to be nested as `module`, e.g:
```nix
{
tests.dontRun = true;
module = {config, options, ...}: {
/* a disabled test */
};
}
```
Also ended up doing some general cleanup, removing an unused function,
etc.
In our basic template we used to provide a check based on
`mkTestDerivationFromNvim`. The issue with this check (that is handled
correctly internally) is that some plugins _can't_ be used in the test
environment, for example image.nvim like in #1085.
This commit introduces a new function to generate such checks,
`mkTestDerivationFromNixvimModule`, that wraps a nixvim configuration
instead of a built nvim instance.
Then a configuration can rely on the newly added
`helpers.enableExceptInTests` attribute to disable parts of the
configuration depending if it is evaluated in tests or in a real final
configuration.
Resolves#1085