diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2016-08-07 18:36:11 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2016-08-08 21:04:23 -0700 |
commit | 2042e9a6d85d02adc9424ce6f973e17341ebb292 (patch) | |
tree | 0d2ee81b7bac6b679cc55e56cbd10dbfcc9129cb /lib | |
parent | 1339714eecc927e46a1336241512483dd8d11eab (diff) | |
download | spack-2042e9a6d85d02adc9424ce6f973e17341ebb292.tar.gz spack-2042e9a6d85d02adc9424ce6f973e17341ebb292.tar.bz2 spack-2042e9a6d85d02adc9424ce6f973e17341ebb292.tar.xz spack-2042e9a6d85d02adc9424ce6f973e17341ebb292.zip |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/architecture.py | 7 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 14 | ||||
-rw-r--r-- | lib/spack/spack/test/architecture.py | 23 |
3 files changed, 34 insertions, 10 deletions
diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py index 974505ee3a..886e170b1a 100644 --- a/lib/spack/spack/architecture.py +++ b/lib/spack/spack/architecture.py @@ -383,6 +383,13 @@ class Arch(object): def __contains__(self, string): 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): if isinstance(self.platform, Platform): platform = self.platform.name diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 8a47ec95ad..a37b39be67 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -915,10 +915,7 @@ class Spec(object): if params: d['parameters'] = params - if self.architecture is not None: - d['arch'] = self.architecture - - if self.dependencies: + if self.dependencies(): deps = self.dependencies_dict(deptype=('link', 'run')) d['dependencies'] = dict( (name, { @@ -926,17 +923,13 @@ class Spec(object): 'type': [str(s) for s in dspec.deptypes]}) for name, dspec in deps.items()) - # Older concrete specs do not have a namespace. Omit for - # consistent hashing. - if not self.concrete or self.namespace: + if self.namespace: d['namespace'] = self.namespace if self.architecture: # TODO: Fix the target.to_dict to account for the tuple # Want it to be a dict of dicts d['arch'] = self.architecture.to_dict() - else: - d['arch'] = None if self.compiler: d.update(self.compiler.to_dict()) @@ -967,7 +960,8 @@ class Spec(object): if 'version' in node or 'versions' in 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: spec.compiler = CompilerSpec.from_dict(node) diff --git a/lib/spack/spack/test/architecture.py b/lib/spack/spack/test/architecture.py index 42dd9f4c04..b8441bdac4 100644 --- a/lib/spack/spack/test/architecture.py +++ b/lib/spack/spack/test/architecture.py @@ -86,6 +86,29 @@ class ArchitectureTest(MockPackagesTest): 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): """Test when user inputs just frontend that both the frontend target and frontend operating system match |