tests: test the tests

Adds a regression test for #2076. This test ensures that
`extraConfigLua` is used in `finalPackage` and that the test will fail
correctly when running `nvim` results in unexpected output.
This commit is contained in:
Matt Sturgeon 2024-08-25 16:46:52 +01:00
parent eac092c876
commit 60ea38d2c4
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 27 additions and 0 deletions

View file

@ -25,6 +25,11 @@
inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule;
};
failing-tests = import ../tests/failing-tests.nix {
inherit pkgs;
inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule;
};
no-flake = import ../tests/no-flake.nix {
inherit system;
inherit (self.lib.${system}.check) mkTestDerivationFromNvim;

22
tests/failing-tests.nix Normal file
View file

@ -0,0 +1,22 @@
{
pkgs,
mkTestDerivationFromNixvimModule,
}:
let
inherit (pkgs.testers) testBuildFailure;
failed = testBuildFailure (mkTestDerivationFromNixvimModule {
name = "prints-hello-world";
module = {
extraConfigLua = ''
print('Hello, world!')
'';
};
inherit pkgs;
});
in
pkgs.runCommand "failing-test" { inherit failed; } ''
grep -F 'Hello, world!' "$failed/testBuildFailure.log"
[[ 1 = $(cat "$failed/testBuildFailure.exit") ]]
touch $out
''