[SCM] Samba Shared Repository - branch master updated

Jelmer Vernooij jelmer at samba.org
Sun Feb 12 12:18:03 MST 2012


The branch, master has been updated
       via  2d66d16 wafsamba: Add tests for dict_concat.
       via  a0fb721 wafsamba: Add tests for unique_list, subst_vars_error.
       via  c3a9d1e waf: Add initial unit test for samba_utils.
      from  8de129d gitignore: Ignore waf cache files.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 2d66d16af09239d285d572b9e3749b0132b69f99
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Feb 12 18:42:17 2012 +0100

    wafsamba: Add tests for dict_concat.
    
    Autobuild-User: Jelmer Vernooij <jelmer at samba.org>
    Autobuild-Date: Sun Feb 12 20:17:54 CET 2012 on sn-devel-104

commit a0fb7211cde25748e76f615b8fd8254dec947e2c
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Feb 12 17:48:01 2012 +0100

    wafsamba: Add tests for unique_list, subst_vars_error.

commit c3a9d1eb15100f3b46bcb9f67303c5729f6fa4ff
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Feb 12 17:35:20 2012 +0100

    waf: Add initial unit test for samba_utils.

-----------------------------------------------------------------------

Summary of changes:
 {source3/build => buildtools/wafsamba}/__init__.py |    0
 buildtools/wafsamba/samba_utils.py                 |    3 +-
 buildtools/wafsamba/tests/__init__.py              |   33 +++++++++
 buildtools/wafsamba/tests/test_utils.py            |   76 ++++++++++++++++++++
 source4/selftest/tests.py                          |    1 +
 5 files changed, 111 insertions(+), 2 deletions(-)
 copy {source3/build => buildtools/wafsamba}/__init__.py (100%)
 create mode 100644 buildtools/wafsamba/tests/__init__.py
 create mode 100644 buildtools/wafsamba/tests/test_utils.py


Changeset truncated at 500 lines:

diff --git a/source3/build/__init__.py b/buildtools/wafsamba/__init__.py
similarity index 100%
copy from source3/build/__init__.py
copy to buildtools/wafsamba/__init__.py
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index 71cfbc5..519b77b 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -233,8 +233,7 @@ def subst_vars_error(string, env):
         if re.match('\$\{\w+\}', v):
             vname = v[2:-1]
             if not vname in env:
-                Logs.error("Failed to find variable %s in %s" % (vname, string))
-                sys.exit(1)
+                raise KeyError("Failed to find variable %s in %s" % (vname, string))
             v = env[vname]
         out.append(v)
     return ''.join(out)
diff --git a/buildtools/wafsamba/tests/__init__.py b/buildtools/wafsamba/tests/__init__.py
new file mode 100644
index 0000000..7678880
--- /dev/null
+++ b/buildtools/wafsamba/tests/__init__.py
@@ -0,0 +1,33 @@
+# Copyright (C) 2012 Jelmer Vernooij <jelmer at samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for wafsamba."""
+
+from unittest import (
+    TestCase,
+    TestLoader,
+    )
+
+def test_suite():
+    names = [
+        'utils',
+        ]
+    module_names = ['wafsamba.tests.test_' + name for name in names]
+    loader = TestLoader()
+    result = loader.suiteClass()
+    suite = loader.loadTestsFromNames(module_names)
+    result.addTests(suite)
+    return result
diff --git a/buildtools/wafsamba/tests/test_utils.py b/buildtools/wafsamba/tests/test_utils.py
new file mode 100644
index 0000000..a9578e2
--- /dev/null
+++ b/buildtools/wafsamba/tests/test_utils.py
@@ -0,0 +1,76 @@
+# Copyright (C) 2012 Jelmer Vernooij <jelmer at samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+from wafsamba.tests import TestCase
+
+from wafsamba.samba_utils import (
+    TO_LIST,
+    dict_concat,
+    subst_vars_error,
+    unique_list,
+    )
+
+class ToListTests(TestCase):
+
+    def test_none(self):
+        self.assertEquals([], TO_LIST(None))
+
+    def test_already_list(self):
+        self.assertEquals(["foo", "bar", 1], TO_LIST(["foo", "bar", 1]))
+
+    def test_default_delimiter(self):
+        self.assertEquals(["foo", "bar"], TO_LIST("foo bar"))
+        self.assertEquals(["foo", "bar"], TO_LIST("  foo bar  "))
+        self.assertEquals(["foo ", "bar"], TO_LIST("  \"foo \" bar  "))
+
+    def test_delimiter(self):
+        self.assertEquals(["foo", "bar"], TO_LIST("foo,bar", ","))
+        self.assertEquals(["  foo", "bar  "], TO_LIST("  foo,bar  ", ","))
+        self.assertEquals(["  \" foo\"", " bar  "], TO_LIST("  \" foo\", bar  ", ","))
+
+
+class UniqueListTests(TestCase):
+
+    def test_unique_list(self):
+        self.assertEquals(["foo", "bar"], unique_list(["foo", "bar", "foo"]))
+
+
+class SubstVarsErrorTests(TestCase):
+
+    def test_valid(self):
+        self.assertEquals("", subst_vars_error("", {}))
+        self.assertEquals("FOO bar", subst_vars_error("${F} bar", {"F": "FOO"}))
+
+    def test_invalid(self):
+        self.assertRaises(KeyError, subst_vars_error, "${F}", {})
+
+
+class DictConcatTests(TestCase):
+
+    def test_empty(self):
+        ret = {}
+        dict_concat(ret, {})
+        self.assertEquals({}, ret)
+
+    def test_same(self):
+        ret = {"foo": "bar"}
+        dict_concat(ret, {"foo": "bla"})
+        self.assertEquals({"foo": "bar"}, ret)
+
+    def test_simple(self):
+        ret = {"foo": "bar"}
+        dict_concat(ret, {"blie": "bla"})
+        self.assertEquals({"foo": "bar", "blie": "bla"}, ret)
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index ccc899b..b1b7871 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -442,6 +442,7 @@ planpythontestsuite("dc:local", "samba.tests.samba_tool.user")
 
 planpythontestsuite("none", "subunit")
 planpythontestsuite("dc:local", "samba.tests.dcerpc.rpcecho")
+planpythontestsuite("none", "wafsamba.tests.test_utils", extra_path=[os.path.join(samba4srcdir, "..", "buildtools"), os.path.join(samba4srcdir, "..", "buildtools", "wafadmin")])
 planoldpythontestsuite("dc:local", "samba.tests.dcerpc.registry", extra_args=['-U"$USERNAME%$PASSWORD"'])
 planoldpythontestsuite("dc", "samba.tests.dcerpc.dnsserver", extra_args=['-U"$USERNAME%$PASSWORD"'])
 plantestsuite("samba4.ldap.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/ldap.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN'])


-- 
Samba Shared Repository


More information about the samba-cvs mailing list