summary refs log tree commit diff
path: root/pkgs/lib/debug.nix
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2009-11-22 21:28:38 +0000
committerMarc Weber <marco-oweber@gmx.de>2009-11-22 21:28:38 +0000
commit02972b92d54f887fc7e9033bb973affd450be1d9 (patch)
tree7466586c158cf2b937cf59a6dcfe3e99b7e766f3 /pkgs/lib/debug.nix
parent715d09d836fe9a3d4b7b87300499113c18c710af (diff)
downloadnixpkgs-02972b92d54f887fc7e9033bb973affd450be1d9.tar
nixpkgs-02972b92d54f887fc7e9033bb973affd450be1d9.tar.gz
nixpkgs-02972b92d54f887fc7e9033bb973affd450be1d9.tar.bz2
nixpkgs-02972b92d54f887fc7e9033bb973affd450be1d9.tar.lz
nixpkgs-02972b92d54f887fc7e9033bb973affd450be1d9.tar.xz
nixpkgs-02972b92d54f887fc7e9033bb973affd450be1d9.tar.zst
nixpkgs-02972b92d54f887fc7e9033bb973affd450be1d9.zip
nix lang runTests: ignore tests which are not prefixed by "test"
svn path=/nixpkgs/trunk/; revision=18537
Diffstat (limited to 'pkgs/lib/debug.nix')
-rw-r--r--pkgs/lib/debug.nix10
1 files changed, 8 insertions, 2 deletions
diff --git a/pkgs/lib/debug.nix b/pkgs/lib/debug.nix
index e0f8b414a0d..25ca733951a 100644
--- a/pkgs/lib/debug.nix
+++ b/pkgs/lib/debug.nix
@@ -3,7 +3,7 @@ let lib = import ./default.nix;
 inherit (builtins) trace attrNamesToStr isAttrs isFunction isList isInt
         isString isBool head substring attrNames;
 
-inherit (lib) all id mapAttrsFlatten;
+inherit (lib) all id mapAttrsFlatten elem;
 
 in
 
@@ -59,9 +59,15 @@ rec {
      expected, actual}, denoting the attribute name of the failing
      test and its expected and actual results.  Used for regression
      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:
-    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; } ]
       else [] ) tests));