Config scopes are now returning OrderedDicts instead of dicts. (#5183)
It seems 8f21332fec
introduced a bug
in that normal dictionaries are returned from ConfigScope objects
instead of OrderedDicts. This is fixed here.
This commit is contained in:
parent
79df4db8e5
commit
4600d106e2
@ -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 @@ def write_section(self, section):
|
||||
|
||||
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])
|
||||
|
@ -369,3 +369,31 @@ def test_read_config_override_list(self, write_config_file):
|
||||
'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
|
||||
|
42
lib/spack/spack/test/data/config/modules.yaml
Normal file
42
lib/spack/spack/test/data/config/modules.yaml
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user