mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2026-02-02 03:15:12 +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"
|
if format == "json"
|
||||||
then expected
|
then expected
|
||||||
else lib.generators.toPretty {} expected;
|
else lib.generators.toPretty {} expected;
|
||||||
in {
|
in
|
||||||
inherit type name description;
|
assert lib.assertMsg (!(type == "script" && script == null)) "test ${name} has type 'script' but no script was passed"; {
|
||||||
actual = actual';
|
inherit type name description;
|
||||||
expected = expected';
|
actual = actual';
|
||||||
# discard string context, otherwise it's being built instantly which we don't want
|
expected = expected';
|
||||||
actualDrv = builtins.unsafeDiscardStringContext (actualDrv.drvPath or "");
|
# discard string context, otherwise it's being built instantly which we don't want
|
||||||
script =
|
actualDrv = builtins.unsafeDiscardStringContext (actualDrv.drvPath or "");
|
||||||
if script != null
|
script =
|
||||||
then
|
if script != null
|
||||||
builtins.unsafeDiscardStringContext
|
then
|
||||||
(pkgs.writeShellScript "nixtest-${name}" ''
|
builtins.unsafeDiscardStringContext
|
||||||
# show which line failed the test
|
(pkgs.writeShellScript "nixtest-${name}" ''
|
||||||
set -x
|
# show which line failed the test
|
||||||
${script}
|
set -x
|
||||||
'').drvPath
|
${script}
|
||||||
else null;
|
'').drvPath
|
||||||
pos =
|
else null;
|
||||||
if pos == null
|
pos =
|
||||||
then ""
|
if pos == null
|
||||||
else "${fileRelative}:${toString pos.line}";
|
then ""
|
||||||
};
|
else "${fileRelative}:${toString pos.line}";
|
||||||
|
};
|
||||||
mkSuite = name: tests: {
|
mkSuite = name: tests: {
|
||||||
inherit name tests;
|
inherit name tests;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue