mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-21 17:59:41 +01:00
lib: move enableExceptInTests impl to build.test option
Simplify the `enableExceptInTests` attribute, removing the `_nixvimTests` argument. We now do a full re-eval of the nixvim configuration before building the test, giving us a central place to implement `enableExceptInTests` and its eventual replacement(s). This extends support for `enableExceptInTests` to all methods of getting a nixvim test derivation. Previously, it only worked when using `mkTestDerivationFromNixvimModule`. In `tests/main.nix`, we avoid the re-eval by doing the initial eval with a "test mode" lib from the start.
This commit is contained in:
parent
7754b4eb1b
commit
8d0ca9abc4
7 changed files with 57 additions and 31 deletions
|
|
@ -3,6 +3,8 @@
|
|||
config,
|
||||
options,
|
||||
lib,
|
||||
helpers,
|
||||
extendModules,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
|
@ -263,9 +265,36 @@ in
|
|||
|
||||
config =
|
||||
let
|
||||
# Reevaluate the nixvim configuration in "test mode"
|
||||
# This allows users to use `lib.nixvim.enableExceptInTests`
|
||||
testConfiguration =
|
||||
let
|
||||
# TODO: replace and deprecate enableExceptInTests
|
||||
# We shouldn't need to use another instance of `lib` when building a test drv
|
||||
# Maybe add a context option e.g. `config.isTest`?
|
||||
nixvimLibOverlay = final: prev: {
|
||||
utils = prev.utils // {
|
||||
enableExceptInTests = false;
|
||||
};
|
||||
};
|
||||
extendedConfiguration = extendModules {
|
||||
specialArgs = {
|
||||
lib = lib.extend (
|
||||
final: prev: {
|
||||
nixvim = prev.nixvim.extend nixvimLibOverlay;
|
||||
}
|
||||
);
|
||||
helpers = helpers.extend nixvimLibOverlay;
|
||||
};
|
||||
};
|
||||
in
|
||||
if lib.nixvim.enableExceptInTests then extendedConfiguration else { inherit config options; };
|
||||
|
||||
input = {
|
||||
inherit (config) warnings;
|
||||
assertions = builtins.concatMap (x: lib.optional (!x.assertion) x.message) config.assertions;
|
||||
inherit (testConfiguration.config) warnings;
|
||||
assertions = builtins.concatMap (
|
||||
x: lib.optional (!x.assertion) x.message
|
||||
) testConfiguration.config.assertions;
|
||||
};
|
||||
|
||||
expectationMessages =
|
||||
|
|
@ -323,7 +352,7 @@ in
|
|||
nativeBuildInputs =
|
||||
cfg.extraInputs
|
||||
++ lib.optionals cfg.buildNixvim [
|
||||
config.build.nvimPackage
|
||||
testConfiguration.config.build.nvimPackage
|
||||
];
|
||||
|
||||
inherit (failedExpectations) warnings assertions;
|
||||
|
|
@ -335,7 +364,8 @@ in
|
|||
#
|
||||
# Yes, three levels of `entries` is cursed.
|
||||
passthru = {
|
||||
inherit config options;
|
||||
inherit (testConfiguration) config options;
|
||||
configuration = testConfiguration;
|
||||
};
|
||||
}
|
||||
(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue