Skip to content

Commit

Permalink
tests: test the tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MattSturgeon committed Aug 27, 2024
1 parent eac092c commit 60ea38d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions flake-modules/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 22 additions & 0 deletions tests/failing-tests.nix
Original file line number Diff line number Diff line change
@@ -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
''

0 comments on commit 60ea38d

Please sign in to comment.