added option to add test suites not in a file
This commit is contained in:
parent
5007770e88
commit
bfa12db1db
|
@ -18,6 +18,9 @@
|
||||||
./test/test.test.nix
|
./test/test.test.nix
|
||||||
./test/describe.test.nix
|
./test/describe.test.nix
|
||||||
./test/watch.test.nix
|
./test/watch.test.nix
|
||||||
|
({describe, it, ...}: [(describe "suite" [
|
||||||
|
(it "runs this test" {actual = true; expected = true;})
|
||||||
|
])])
|
||||||
];
|
];
|
||||||
|
|
||||||
packages.x86_64-linux.example = tix.run [
|
packages.x86_64-linux.example = tix.run [
|
||||||
|
|
|
@ -8,7 +8,7 @@ in [
|
||||||
(describe "the test function" [
|
(describe "the test function" [
|
||||||
(it "get's test results" {
|
(it "get's test results" {
|
||||||
expected = {
|
expected = {
|
||||||
name = toString ./example.test.nix;
|
name = builtins.baseNameOf ./example.test.nix;
|
||||||
value = {
|
value = {
|
||||||
"an example" = {
|
"an example" = {
|
||||||
succeeds = {
|
succeeds = {
|
||||||
|
@ -23,5 +23,9 @@ in [
|
||||||
actual = test ./bad/string.nix;
|
actual = test ./bad/string.nix;
|
||||||
throws = true;
|
throws = true;
|
||||||
})
|
})
|
||||||
|
(it "tests suite that is not a file" {
|
||||||
|
actual = test ({...}: []);
|
||||||
|
expected = {name = "anonymous"; value = {};};
|
||||||
|
})
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
pkgs: files: let
|
pkgs: suite: let
|
||||||
test = import ./test.nix;
|
test = import ./test.nix;
|
||||||
res = builtins.listToAttrs (map test files);
|
res = builtins.listToAttrs (map test suite);
|
||||||
resFile = builtins.toFile "results" (builtins.toJSON res);
|
resFile = builtins.toFile "results" (builtins.toJSON res);
|
||||||
filters = import ./filters.nix;
|
filters = import ./filters.nix;
|
||||||
getNix = "import ${./eval.nix} ${resFile}";
|
getNix = "import ${./eval.nix} ${resFile}";
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
path: let
|
path: let
|
||||||
it = import ./it.nix;
|
it = import ./it.nix;
|
||||||
describe = import ./describe.nix;
|
describe = import ./describe.nix;
|
||||||
suite = import path;
|
suite = if builtins.typeOf path == "path" then import path
|
||||||
|
else path;
|
||||||
|
name = if builtins.typeOf path == "path" then builtins.baseNameOf path
|
||||||
|
else "anonymous";
|
||||||
in
|
in
|
||||||
builtins.trace ("tix: " + builtins.baseNameOf path)
|
builtins.trace "tix: ${name}"
|
||||||
(
|
(
|
||||||
if !builtins.isFunction suite
|
if !builtins.isFunction suite
|
||||||
then throw "A test suite should be in the form { it }: [ <tests> ]."
|
then throw "A test suite should be in the form { it }: [ <tests> ]."
|
||||||
else {
|
else {
|
||||||
name = toString path;
|
inherit name;
|
||||||
value = builtins.listToAttrs (suite {inherit it describe;});
|
value = builtins.listToAttrs (suite {inherit it describe;});
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue