Replace the `package-options` test with a stricter implementation.
When evaluating modules for use in the docs, provide them with a stubbed
`pkgs` instance that throws an error whenever a package is evaluated.
This ensures we don't accidentally use any packages in defaults or
examples.
This should be separate from `test-sources` because we want to re-use a
common instance of nixpkgs throughout those tests.
Also, moved the existing nixpkgs module test from `test-sources`.
This partially reverts commit c4ad4d0b2e.
This should help to maintain uniformity and hopefully make contributions
easier.
Kept regression tests local to the derivation, however these are also
added to the flake checks.
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