test: nest sample tests as fixtures in real tests

also use new test helpers
This commit is contained in:
technofab 2025-06-13 15:46:52 +02:00
parent bed029f4a9
commit 006537e6ab
No known key found for this signature in database
4 changed files with 186 additions and 142 deletions

View file

@ -1,44 +0,0 @@
{
pkgs,
lib,
...
}: let
ntlib = import ./. {inherit pkgs lib;};
in {
suites."Lib Tests".tests = [
{
name = "autodiscovery";
type = "script";
script = let
actual = builtins.toFile "actual" (builtins.toJSON (ntlib.autodiscover {
dir = ./.;
}));
in
# sh
''
export PATH="${pkgs.gnugrep}/bin"
grep -q lib_test.nix ${actual}
grep -q "\"base\":\"/nix/store/.*-source/lib/" ${actual}
'';
}
{
name = "binary";
type = "script";
script = let
binary =
(ntlib.mkBinary {
nixtests = "stub";
extraParams = "--pure";
})
+ "/bin/nixtests:run";
in
# sh
''
export PATH="${pkgs.gnugrep}/bin"
grep -q nixtest ${binary}
grep -q -- "--pure" ${binary}
grep -q -- "--tests=stub" ${binary}
'';
}
];
}