summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@googlemail.com>2017-08-22 23:20:19 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2017-08-22 14:20:19 -0700
commit4600d106e27caa87b8206e9db7af825f16c93fc0 (patch)
treec853f63c2349566db0c0635ad66327cc86a19ba8 /lib
parent79df4db8e553afcfd00b97bbf0ff4b9f1ae77a40 (diff)
downloadspack-4600d106e27caa87b8206e9db7af825f16c93fc0.tar.gz
spack-4600d106e27caa87b8206e9db7af825f16c93fc0.tar.bz2
spack-4600d106e27caa87b8206e9db7af825f16c93fc0.tar.xz
spack-4600d106e27caa87b8206e9db7af825f16c93fc0.zip
Config scopes are now returning OrderedDicts instead of dicts. (#5183)
It seems 8f21332fec4c8adb5349ff90e30bb0e4f75e090e introduced a bug in that normal dictionaries are returned from ConfigScope objects instead of OrderedDicts. This is fixed here.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/config.py6
-rw-r--r--lib/spack/spack/test/config.py28
-rw-r--r--lib/spack/spack/test/data/config/modules.yaml42
3 files changed, 73 insertions, 3 deletions
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index d3a385ea80..8b7fcf334c 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -162,7 +162,7 @@ class ConfigScope(object):
def __init__(self, name, path):
self.name = name # scope name.
self.path = path # path to directory containing configs.
- self.sections = {} # sections read from config files.
+ self.sections = syaml.syaml_dict() # sections read from config files.
# Register in a dict of all ConfigScopes
# TODO: make this cleaner. Mocking up for testing is brittle.
@@ -197,7 +197,7 @@ class ConfigScope(object):
def clear(self):
"""Empty cached config information."""
- self.sections = {}
+ self.sections = syaml.syaml_dict()
def __repr__(self):
return '<ConfigScope: %s: %s>' % (self.name, self.path)
@@ -314,7 +314,7 @@ def _mark_overrides(data):
return [_mark_overrides(elt) for elt in data]
elif isinstance(data, dict):
- marked = {}
+ marked = syaml.syaml_dict()
for key, val in iteritems(data):
if isinstance(key, string_types) and key.endswith(':'):
key = syaml.syaml_str(key[:-1])
diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py
index 2363754a00..d00dc64bb3 100644
--- a/lib/spack/spack/test/config.py
+++ b/lib/spack/spack/test/config.py
@@ -369,3 +369,31 @@ class TestConfig(object):
'install_tree': 'install_tree_path',
'build_stage': ['patha', 'pathb']
}
+
+
+def test_keys_are_ordered():
+
+ expected_order = (
+ 'bin',
+ 'man',
+ 'share/man',
+ 'share/aclocal',
+ 'lib',
+ 'lib64',
+ 'include',
+ 'lib/pkgconfig',
+ 'lib64/pkgconfig',
+ ''
+ )
+
+ config_scope = spack.config.ConfigScope(
+ 'modules',
+ os.path.join(spack.test_path, 'data', 'config')
+ )
+
+ data = config_scope.get_section('modules')
+
+ prefix_inspections = data['modules']['prefix_inspections']
+
+ for actual, expected in zip(prefix_inspections, expected_order):
+ assert actual == expected
diff --git a/lib/spack/spack/test/data/config/modules.yaml b/lib/spack/spack/test/data/config/modules.yaml
new file mode 100644
index 0000000000..25fe2088e7
--- /dev/null
+++ b/lib/spack/spack/test/data/config/modules.yaml
@@ -0,0 +1,42 @@
+# -------------------------------------------------------------------------
+# This is the default configuration for Spack's module file generation.
+#
+# Settings here are versioned with Spack and are intended to provide
+# sensible defaults out of the box. Spack maintainers should edit this
+# file to keep it current.
+#
+# Users can override these settings by editing the following files.
+#
+# Per-spack-instance settings (overrides defaults):
+# $SPACK_ROOT/etc/spack/modules.yaml
+#
+# Per-user settings (overrides default and site settings):
+# ~/.spack/modules.yaml
+# -------------------------------------------------------------------------
+modules:
+ enable:
+ - tcl
+ - dotkit
+ prefix_inspections:
+ bin:
+ - PATH
+ man:
+ - MANPATH
+ share/man:
+ - MANPATH
+ share/aclocal:
+ - ACLOCAL_PATH
+ lib:
+ - LIBRARY_PATH
+ - LD_LIBRARY_PATH
+ lib64:
+ - LIBRARY_PATH
+ - LD_LIBRARY_PATH
+ include:
+ - CPATH
+ lib/pkgconfig:
+ - PKG_CONFIG_PATH
+ lib64/pkgconfig:
+ - PKG_CONFIG_PATH
+ '':
+ - CMAKE_PREFIX_PATH