mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2025-12-12 02:00:18 +01:00
chore(lib): add assertion for script to not be null when type=="script"
This commit is contained in:
parent
25de5061ad
commit
c2ca17dfc5
1 changed files with 22 additions and 21 deletions
|
|
@ -24,27 +24,28 @@
|
|||
if format == "json"
|
||||
then expected
|
||||
else lib.generators.toPretty {} expected;
|
||||
in {
|
||||
inherit type name description;
|
||||
actual = actual';
|
||||
expected = expected';
|
||||
# discard string context, otherwise it's being built instantly which we don't want
|
||||
actualDrv = builtins.unsafeDiscardStringContext (actualDrv.drvPath or "");
|
||||
script =
|
||||
if script != null
|
||||
then
|
||||
builtins.unsafeDiscardStringContext
|
||||
(pkgs.writeShellScript "nixtest-${name}" ''
|
||||
# show which line failed the test
|
||||
set -x
|
||||
${script}
|
||||
'').drvPath
|
||||
else null;
|
||||
pos =
|
||||
if pos == null
|
||||
then ""
|
||||
else "${fileRelative}:${toString pos.line}";
|
||||
};
|
||||
in
|
||||
assert lib.assertMsg (!(type == "script" && script == null)) "test ${name} has type 'script' but no script was passed"; {
|
||||
inherit type name description;
|
||||
actual = actual';
|
||||
expected = expected';
|
||||
# discard string context, otherwise it's being built instantly which we don't want
|
||||
actualDrv = builtins.unsafeDiscardStringContext (actualDrv.drvPath or "");
|
||||
script =
|
||||
if script != null
|
||||
then
|
||||
builtins.unsafeDiscardStringContext
|
||||
(pkgs.writeShellScript "nixtest-${name}" ''
|
||||
# show which line failed the test
|
||||
set -x
|
||||
${script}
|
||||
'').drvPath
|
||||
else null;
|
||||
pos =
|
||||
if pos == null
|
||||
then ""
|
||||
else "${fileRelative}:${toString pos.line}";
|
||||
};
|
||||
mkSuite = name: tests: {
|
||||
inherit name tests;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue