Fix bugs with sparse spec printing.
- Make namespace, arch, and dependnecies show up in spec yaml only if they're set. - Lost some of this functionality with deptypes
This commit is contained in:
parent
1339714eec
commit
2042e9a6d8
@ -383,6 +383,13 @@ def __str__(self):
|
|||||||
def __contains__(self, string):
|
def __contains__(self, string):
|
||||||
return string in str(self)
|
return string in str(self)
|
||||||
|
|
||||||
|
# TODO: make this unnecessary: don't include an empty arch on *every* spec.
|
||||||
|
def __nonzero__(self):
|
||||||
|
return (self.platform is not None or
|
||||||
|
self.platform_os is not None or
|
||||||
|
self.target is not None)
|
||||||
|
__bool__ = __nonzero__
|
||||||
|
|
||||||
def _cmp_key(self):
|
def _cmp_key(self):
|
||||||
if isinstance(self.platform, Platform):
|
if isinstance(self.platform, Platform):
|
||||||
platform = self.platform.name
|
platform = self.platform.name
|
||||||
|
@ -915,10 +915,7 @@ def to_node_dict(self):
|
|||||||
if params:
|
if params:
|
||||||
d['parameters'] = params
|
d['parameters'] = params
|
||||||
|
|
||||||
if self.architecture is not None:
|
if self.dependencies():
|
||||||
d['arch'] = self.architecture
|
|
||||||
|
|
||||||
if self.dependencies:
|
|
||||||
deps = self.dependencies_dict(deptype=('link', 'run'))
|
deps = self.dependencies_dict(deptype=('link', 'run'))
|
||||||
d['dependencies'] = dict(
|
d['dependencies'] = dict(
|
||||||
(name, {
|
(name, {
|
||||||
@ -926,17 +923,13 @@ def to_node_dict(self):
|
|||||||
'type': [str(s) for s in dspec.deptypes]})
|
'type': [str(s) for s in dspec.deptypes]})
|
||||||
for name, dspec in deps.items())
|
for name, dspec in deps.items())
|
||||||
|
|
||||||
# Older concrete specs do not have a namespace. Omit for
|
if self.namespace:
|
||||||
# consistent hashing.
|
|
||||||
if not self.concrete or self.namespace:
|
|
||||||
d['namespace'] = self.namespace
|
d['namespace'] = self.namespace
|
||||||
|
|
||||||
if self.architecture:
|
if self.architecture:
|
||||||
# TODO: Fix the target.to_dict to account for the tuple
|
# TODO: Fix the target.to_dict to account for the tuple
|
||||||
# Want it to be a dict of dicts
|
# Want it to be a dict of dicts
|
||||||
d['arch'] = self.architecture.to_dict()
|
d['arch'] = self.architecture.to_dict()
|
||||||
else:
|
|
||||||
d['arch'] = None
|
|
||||||
|
|
||||||
if self.compiler:
|
if self.compiler:
|
||||||
d.update(self.compiler.to_dict())
|
d.update(self.compiler.to_dict())
|
||||||
@ -967,7 +960,8 @@ def from_node_dict(node):
|
|||||||
if 'version' in node or 'versions' in node:
|
if 'version' in node or 'versions' in node:
|
||||||
spec.versions = VersionList.from_dict(node)
|
spec.versions = VersionList.from_dict(node)
|
||||||
|
|
||||||
spec.architecture = spack.architecture.arch_from_dict(node['arch'])
|
if 'arch' in node:
|
||||||
|
spec.architecture = spack.architecture.arch_from_dict(node['arch'])
|
||||||
|
|
||||||
if 'compiler' in node:
|
if 'compiler' in node:
|
||||||
spec.compiler = CompilerSpec.from_dict(node)
|
spec.compiler = CompilerSpec.from_dict(node)
|
||||||
|
@ -86,6 +86,29 @@ def test_platform(self):
|
|||||||
|
|
||||||
self.assertEqual(str(output_platform_class), str(my_platform_class))
|
self.assertEqual(str(output_platform_class), str(my_platform_class))
|
||||||
|
|
||||||
|
def test_boolness(self):
|
||||||
|
# Make sure architecture reports that it's False when nothing's set.
|
||||||
|
arch = spack.architecture.Arch()
|
||||||
|
self.assertFalse(arch)
|
||||||
|
|
||||||
|
# Dummy architecture parts
|
||||||
|
plat = spack.architecture.platform()
|
||||||
|
plat_os = plat.operating_system('default_os')
|
||||||
|
plat_target = plat.target('default_target')
|
||||||
|
|
||||||
|
# Make sure architecture reports that it's True when anything is set.
|
||||||
|
arch = spack.architecture.Arch()
|
||||||
|
arch.platform = plat
|
||||||
|
self.assertTrue(arch)
|
||||||
|
|
||||||
|
arch = spack.architecture.Arch()
|
||||||
|
arch.platform_os = plat_os
|
||||||
|
self.assertTrue(arch)
|
||||||
|
|
||||||
|
arch = spack.architecture.Arch()
|
||||||
|
arch.target = plat_target
|
||||||
|
self.assertTrue(arch)
|
||||||
|
|
||||||
def test_user_front_end_input(self):
|
def test_user_front_end_input(self):
|
||||||
"""Test when user inputs just frontend that both the frontend target
|
"""Test when user inputs just frontend that both the frontend target
|
||||||
and frontend operating system match
|
and frontend operating system match
|
||||||
|
Loading…
Reference in New Issue
Block a user