Commit graph

30 commits

Author SHA1 Message Date
Matt Sturgeon
4a508ceee2
tests: use callTest pattern
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.
2024-10-18 20:52:02 +01:00
Matt Sturgeon
990ef039f7
tests: move test derivations to tests/default.nix
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/`.
2024-10-18 20:51:30 +01:00
Matt Sturgeon
af650ba940
tests/lsp-servers: de-couple from grouped tests
Follow up to cab6b0c9fe
2024-10-10 21:50:23 +01:00
Quentin Boyer
cab6b0c9fe tests: Split off in a single derivation the lsp server test
This test is quite resource intensive, so let's split it to avoid
issues
2024-10-08 21:28:44 +02:00
Matt Sturgeon
810eacf516
tests: set _file to avoid <unknown-file> messages
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.
2024-09-07 22:29:43 +01:00
Matt Sturgeon
ce4c3a72c1
tests/fetch-test: tweak signature 2024-09-07 22:29:43 +01:00
Matt Sturgeon
975af6a498
tests: simplify fetch-tests slightly
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.
2024-08-28 05:45:01 +01:00
Matt Sturgeon
fe12a092f6
tests: general cleanup
- Refactor much of `tests/fetch-tests.nix`
- Move `mkTest` up to let-block in `tests/default.nix`
2024-08-22 15:27:56 +01:00
Matt Sturgeon
19d5f4b134
lib/test: move from tests/test-derivation 2024-08-21 02:48:06 +01:00
Matt Sturgeon
cbd1003d9d
modules/test: move test derivation to an option
Introduced the `test.derivation` read-only option.
2024-08-21 02:48:00 +01:00
Matt Sturgeon
123a55ed6f
tests: remove special treatment of module
Since we no longer need to extract `tests.dontRun` from an attrset, we
no longer need the "special" `module` attr.
2024-08-20 01:07:21 +01:00
Matt Sturgeon
7b2a6cd9e6
tests: tests.dontRun -> test.runNvim
Convert all test-cases to use the new `test.runNvim` module option.
2024-08-20 00:46:30 +01:00
Matt Sturgeon
f47374fd26
modules/test: init, replacing dontRun arg
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.
2024-08-20 00:34:12 +01:00
Matt Sturgeon
69c2fa866e
tests: group tests by 10
Attempt to find a middle ground between having a single link-farm and
one test per file.

This groups up to ten tests per (roughly) 28 link-farms.
2024-08-19 01:11:10 +01:00
Matt Sturgeon
c52ba67856
Revert "tests: Allow to test multiple derivations in a single test derivation"
This reverts commit 71126bfebe.
2024-08-18 20:42:56 +01:00
Matt Sturgeon
9688ef723f
tests: use a link-farm again, but only per-file 2024-08-18 20:42:55 +01:00
traxys
7908729711 dev: Make the tests command able to select which test to launch
The `tests` command can either launch all tests (without any arguments),
a specific test with `-t/--test` or choose a test with `-i/--interactive`
2024-07-21 15:17:17 +02:00
traxys
b1576362a7 tests: Remove the test link farm
Fixes #1878
2024-07-21 15:17:17 +02:00
traxys
50d865275d tests: Reduce the number of calls to mkTestDerivationFromNixvimModule 2024-07-19 11:11:17 +02:00
traxys
71126bfebe tests: Allow to test multiple derivations in a single test derivation 2024-07-19 11:11:17 +02:00
Matt Sturgeon
78275321f8
tests/test-derivation: don't invoke test modules
`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" ]`!
2024-06-30 18:22:58 +01:00
Matt Sturgeon
10f64e6c96
tests/test-derivation: allow tests to be modules
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.
2024-06-29 22:02:44 +01:00
traxys
62f32bfc71 treewide: Reformat with nixfmt 2024-05-05 22:00:40 +02:00
traxys
6d7e429537
tests: Introduce a way to disable options when running in tests (#1095)
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
2024-02-15 14:27:45 +01:00
Gaetan Lepage
a121d96091 tests: do not import helpers.nix directly 2024-02-11 11:50:35 +01:00
Gaetan Lepage
6c3f97ccc0 tests: aggregate all test derivations into one using a linkFarm 2024-01-05 00:05:28 +01:00
traxys
954706ca4d
tests: Check example.nix in nix flake check (#663) 2023-10-22 14:53:52 +02:00
Tanish2002
efdcbe225f perform some statix linting and fixes 2023-05-22 23:00:53 +02:00
Alexander Nortung
3600698aba
Added test for template and fixed check export for lib (#361) 2023-05-15 11:04:52 +02:00
Gaétan Lepage
db5061b4db
tests/plugins: refactor (#235) 2023-03-22 07:42:02 +01:00