summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/namespace_trie.py
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2016-01-19 09:56:02 -0600
committerAdam J. Stewart <ajstewart426@gmail.com>2016-01-19 09:56:02 -0600
commitfe640d764acaf4c24fc04803797435287d211a8c (patch)
treef08f036d8c77d163b2a86a1787d3805d314ac2e8 /lib/spack/spack/test/namespace_trie.py
parentf9fbb57d3182bf0e9c39e4b7c0a958c6ba87a2fa (diff)
parent01c5b53ba16a95ab77918d30dfa3a63f2ef2707f (diff)
downloadspack-fe640d764acaf4c24fc04803797435287d211a8c.tar.gz
spack-fe640d764acaf4c24fc04803797435287d211a8c.tar.bz2
spack-fe640d764acaf4c24fc04803797435287d211a8c.tar.xz
spack-fe640d764acaf4c24fc04803797435287d211a8c.zip
Merge branch 'develop' into features/nag
* develop: (77 commits) Make libxcb compile with gcc 4.9. disable parallel install for glib (found races) disable cairo-trace, which is incompatible with older libiberty.h. Fix LaunchMon on newer gcc versions. Simplify output redirection in spack.util.executable Allow completely empty config files. Update cmake package to use http in all URLs. Fix create, diy, edit, and repo commands to use multiple repos. Add namespace option to find command. Temporary fix: Clang is the default compiler on Mac OS X. Netcdf requires cmake >=2.8.12 Mbedtls depends on cmake Update libtool to 2.4.6 Update Julia to 0.4.3 Make binutils build on OS X Add verbs and psm variants py-matplotlib: depend on freetype py-numpy: make blas/lapack optional dependencies qhull: apply patch to work with libc++'s standard library New package GNU tar ...
Diffstat (limited to 'lib/spack/spack/test/namespace_trie.py')
-rw-r--r--lib/spack/spack/test/namespace_trie.py114
1 files changed, 114 insertions, 0 deletions
diff --git a/lib/spack/spack/test/namespace_trie.py b/lib/spack/spack/test/namespace_trie.py
new file mode 100644
index 0000000000..d0d809004d
--- /dev/null
+++ b/lib/spack/spack/test/namespace_trie.py
@@ -0,0 +1,114 @@
+##############################################################################
+# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://llnl.github.io/spack
+# Please also see the LICENSE file for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License (as published by
+# the Free Software Foundation) version 2.1 dated February 1999.
+#
+# 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 terms and
+# conditions of the GNU 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
+##############################################################################
+import unittest
+from spack.util.naming import NamespaceTrie
+
+
+class NamespaceTrieTest(unittest.TestCase):
+
+ def setUp(self):
+ self.trie = NamespaceTrie()
+
+
+ def test_add_single(self):
+ self.trie['foo'] = 'bar'
+
+ self.assertTrue(self.trie.is_prefix('foo'))
+ self.assertTrue(self.trie.has_value('foo'))
+ self.assertEqual(self.trie['foo'], 'bar')
+
+
+ def test_add_multiple(self):
+ self.trie['foo.bar'] = 'baz'
+
+ self.assertFalse(self.trie.has_value('foo'))
+ self.assertTrue(self.trie.is_prefix('foo'))
+
+ self.assertTrue(self.trie.is_prefix('foo.bar'))
+ self.assertTrue(self.trie.has_value('foo.bar'))
+ self.assertEqual(self.trie['foo.bar'], 'baz')
+
+ self.assertFalse(self.trie.is_prefix('foo.bar.baz'))
+ self.assertFalse(self.trie.has_value('foo.bar.baz'))
+
+
+ def test_add_three(self):
+ # add a three-level namespace
+ self.trie['foo.bar.baz'] = 'quux'
+
+ self.assertTrue(self.trie.is_prefix('foo'))
+ self.assertFalse(self.trie.has_value('foo'))
+
+ self.assertTrue(self.trie.is_prefix('foo.bar'))
+ self.assertFalse(self.trie.has_value('foo.bar'))
+
+ self.assertTrue(self.trie.is_prefix('foo.bar.baz'))
+ self.assertTrue(self.trie.has_value('foo.bar.baz'))
+ self.assertEqual(self.trie['foo.bar.baz'], 'quux')
+
+ self.assertFalse(self.trie.is_prefix('foo.bar.baz.quux'))
+ self.assertFalse(self.trie.has_value('foo.bar.baz.quux'))
+
+ # Try to add a second element in a prefix namespace
+ self.trie['foo.bar'] = 'blah'
+
+ self.assertTrue(self.trie.is_prefix('foo'))
+ self.assertFalse(self.trie.has_value('foo'))
+
+ self.assertTrue(self.trie.is_prefix('foo.bar'))
+ self.assertTrue(self.trie.has_value('foo.bar'))
+ self.assertEqual(self.trie['foo.bar'], 'blah')
+
+ self.assertTrue(self.trie.is_prefix('foo.bar.baz'))
+ self.assertTrue(self.trie.has_value('foo.bar.baz'))
+ self.assertEqual(self.trie['foo.bar.baz'], 'quux')
+
+ self.assertFalse(self.trie.is_prefix('foo.bar.baz.quux'))
+ self.assertFalse(self.trie.has_value('foo.bar.baz.quux'))
+
+
+ def test_add_none_single(self):
+ self.trie['foo'] = None
+ self.assertTrue(self.trie.is_prefix('foo'))
+ self.assertTrue(self.trie.has_value('foo'))
+ self.assertEqual(self.trie['foo'], None)
+
+ self.assertFalse(self.trie.is_prefix('foo.bar'))
+ self.assertFalse(self.trie.has_value('foo.bar'))
+
+
+
+ def test_add_none_multiple(self):
+ self.trie['foo.bar'] = None
+
+ self.assertTrue(self.trie.is_prefix('foo'))
+ self.assertFalse(self.trie.has_value('foo'))
+
+ self.assertTrue(self.trie.is_prefix('foo.bar'))
+ self.assertTrue(self.trie.has_value('foo.bar'))
+ self.assertEqual(self.trie['foo.bar'], None)
+
+ self.assertFalse(self.trie.is_prefix('foo.bar.baz'))
+ self.assertFalse(self.trie.has_value('foo.bar.baz'))