3
0
Fork 0
forked from mirrors/nixpkgs

nix lang runTests: ignore tests which are not prefixed by "test"

svn path=/nixpkgs/trunk/; revision=18537
This commit is contained in:
Marc Weber 2009-11-22 21:28:38 +00:00
parent 715d09d836
commit 02972b92d5

View file

@ -3,7 +3,7 @@ let lib = import ./default.nix;
inherit (builtins) trace attrNamesToStr isAttrs isFunction isList isInt inherit (builtins) trace attrNamesToStr isAttrs isFunction isList isInt
isString isBool head substring attrNames; isString isBool head substring attrNames;
inherit (lib) all id mapAttrsFlatten; inherit (lib) all id mapAttrsFlatten elem;
in in
@ -59,9 +59,15 @@ rec {
expected, actual}, denoting the attribute name of the failing expected, actual}, denoting the attribute name of the failing
test and its expected and actual results. Used for regression test and its expected and actual results. Used for regression
testing of the functions in lib; see tests.nix for an example. testing of the functions in lib; see tests.nix for an example.
Only tests having names starting with "test" are run.
Add attr { tests = ["testName"]; } to run these test only
*/ */
runTests = tests: lib.concatLists (lib.attrValues (lib.mapAttrs (name: test: runTests = tests: lib.concatLists (lib.attrValues (lib.mapAttrs (name: test:
if ! lib.eqStrict test.expr test.expected let testsToRun = if tests ? tests then tests.tests else [];
in if (substring 0 4 name == "test" || elem name testsToRun)
&& ((testsToRun == []) || elem name tests.tests)
&& (!lib.eqStrict test.expr test.expected)
then [ { inherit name; expected = test.expected; result = test.expr; } ] then [ { inherit name; expected = test.expected; result = test.expr; } ]
else [] ) tests)); else [] ) tests));