mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-31 16:14:46 +02:00
tests: add regression test for warnings + assertions
Ensure `mkTestDerivationFromNixvimModule` correctly test warnings & assertions. Also did some minor cleanup: - Call `failing-tests.nix` using `pkgs.callPackage` - Replace repetive use of `testBuildFailure` with a wrapper `mkFailingNixvimTest`
This commit is contained in:
parent
4814147442
commit
1c879ec3aa
2 changed files with 62 additions and 18 deletions
|
@ -1,22 +1,67 @@
|
|||
{
|
||||
pkgs,
|
||||
linkFarmFromDrvs,
|
||||
runCommandNoCCLocal,
|
||||
mkTestDerivationFromNixvimModule,
|
||||
}:
|
||||
let
|
||||
inherit (pkgs.testers) testBuildFailure;
|
||||
|
||||
failed = testBuildFailure (mkTestDerivationFromNixvimModule {
|
||||
name = "prints-hello-world";
|
||||
module = {
|
||||
extraConfigLua = ''
|
||||
print('Hello, world!')
|
||||
'';
|
||||
};
|
||||
inherit pkgs;
|
||||
});
|
||||
# Wraps a call to mkTestDerivationFromNixvimModule with testers.testBuildFailure
|
||||
mkFailingNixvimTest =
|
||||
args: pkgs.testers.testBuildFailure (mkTestDerivationFromNixvimModule ({ inherit pkgs; } // args));
|
||||
in
|
||||
pkgs.runCommand "failing-test" { inherit failed; } ''
|
||||
grep -F 'Hello, world!' "$failed/testBuildFailure.log"
|
||||
[[ 1 = $(cat "$failed/testBuildFailure.exit") ]]
|
||||
touch $out
|
||||
''
|
||||
linkFarmFromDrvs "failing-tests" [
|
||||
(runCommandNoCCLocal "fail-running-nvim"
|
||||
{
|
||||
failed = mkFailingNixvimTest {
|
||||
name = "prints-hello-world";
|
||||
module = {
|
||||
extraConfigLua = ''
|
||||
print('Hello, world!')
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
''
|
||||
[[ 1 = $(cat "$failed/testBuildFailure.exit") ]]
|
||||
grep -F 'ERROR: Hello, world!' "$failed/testBuildFailure.log"
|
||||
touch $out
|
||||
''
|
||||
)
|
||||
(runCommandNoCCLocal "fail-on-warnings"
|
||||
{
|
||||
failed = mkFailingNixvimTest {
|
||||
name = "warns-hello-world";
|
||||
module = {
|
||||
warnings = [ "Hello, world!" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
''
|
||||
[[ 1 = $(cat "$failed/testBuildFailure.exit") ]]
|
||||
grep -F 'Unexpected warnings:' "$failed/testBuildFailure.log"
|
||||
grep -F 'Hello, world!' "$failed/testBuildFailure.log"
|
||||
touch $out
|
||||
''
|
||||
)
|
||||
(runCommandNoCCLocal "fail-on-assertions"
|
||||
{
|
||||
failed = mkFailingNixvimTest {
|
||||
name = "asserts-hello-world";
|
||||
module = {
|
||||
assertions = [
|
||||
{
|
||||
assertion = false;
|
||||
message = "Hello, world!";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
''
|
||||
[[ 1 = $(cat "$failed/testBuildFailure.exit") ]]
|
||||
grep -F 'Unexpected assertions:' "$failed/testBuildFailure.log"
|
||||
grep -F 'Hello, world!' "$failed/testBuildFailure.log"
|
||||
touch $out
|
||||
''
|
||||
)
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue