tcl : extended conflict to be an array of strings
This commit is contained in:
parent
5deaaa278c
commit
67a01ef2ee
@ -276,7 +276,7 @@
|
||||
},
|
||||
'autoload': {'$ref': '#/definitions/dependency_selection'},
|
||||
'prerequisites': {'$ref': '#/definitions/dependency_selection'},
|
||||
'conflict': {'type': 'string'},
|
||||
'conflict': {'$ref': '#/definitions/array_of_strings'},
|
||||
'environment': {
|
||||
'type': 'object',
|
||||
'default': {},
|
||||
|
@ -46,6 +46,7 @@
|
||||
import os.path
|
||||
import re
|
||||
import textwrap
|
||||
import string
|
||||
|
||||
import llnl.util.tty as tty
|
||||
import spack
|
||||
@ -499,15 +500,20 @@ def header(self):
|
||||
def module_specific_content(self, configuration):
|
||||
naming_tokens = self.tokens
|
||||
# Conflict
|
||||
conflict_format = configuration.get('conflict', '')
|
||||
if conflict_format:
|
||||
for naming_dir, conflict_dir in zip(self.naming_scheme.split('/'), conflict_format.split('/')):
|
||||
if naming_dir != conflict_dir:
|
||||
message = 'Conflict scheme does not match naming scheme [{spec}]\n\n'
|
||||
message += 'naming scheme : "{nformat}"\n'
|
||||
message += 'conflict scheme : "{cformat}"\n'
|
||||
raise tty.error(
|
||||
message.format(spec=self.spec, nformat=self.naming_scheme, cformat=conflict_format)
|
||||
)
|
||||
conflict_format = 'conflict ' + conflict_format
|
||||
yield conflict_format.format(**naming_tokens)
|
||||
conflict_format = configuration.get('conflict', [])
|
||||
f = string.Formatter()
|
||||
for item in conflict_format:
|
||||
line = 'conflict ' + item + '\n'
|
||||
if len([x for x in f.parse(line)]) > 1: # We do have placeholder to substitute
|
||||
for naming_dir, conflict_dir in zip(self.naming_scheme.split('/'), item.split('/')):
|
||||
if naming_dir != conflict_dir:
|
||||
message = 'conflict scheme does not match naming scheme [{spec}]\n\n'
|
||||
message += 'naming scheme : "{nformat}"\n'
|
||||
message += 'conflict scheme : "{cformat}"\n\n'
|
||||
message += '** You may want to check your `modules.yaml` configuration file **\n'
|
||||
tty.error(
|
||||
message.format(spec=self.spec, nformat=self.naming_scheme, cformat=item)
|
||||
)
|
||||
raise SystemExit('Module generation aborted.')
|
||||
line = line.format(**naming_tokens)
|
||||
yield line
|
||||
|
@ -62,6 +62,16 @@ def mock_open(filename, mode):
|
||||
}
|
||||
}
|
||||
|
||||
configuration_conflicts = {
|
||||
'enable': ['tcl'],
|
||||
'tcl': {
|
||||
'naming_scheme': '{name}/{version}-{compiler.name}',
|
||||
'all': {
|
||||
'conflict': ['{name}', 'intel/14.0.1']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
from spack.test.mock_packages_test import MockPackagesTest
|
||||
|
||||
|
||||
@ -124,3 +134,11 @@ def test_blacklist(self):
|
||||
content = self.get_modulefile_content(spec)
|
||||
self.assertEqual(len([x for x in content if 'is-loaded' in x]), 1)
|
||||
self.assertEqual(len([x for x in content if 'module load ' in x]), 1)
|
||||
|
||||
def test_conflicts(self):
|
||||
spack.modules.CONFIGURATION = configuration_conflicts
|
||||
spec = spack.spec.Spec('mpileaks=x86-linux')
|
||||
content = self.get_modulefile_content(spec)
|
||||
self.assertEqual(len([x for x in content if x.startswith('conflict')]), 2)
|
||||
self.assertEqual(len([x for x in content if x == 'conflict mpileaks']), 1)
|
||||
self.assertEqual(len([x for x in content if x == 'conflict intel/14.0.1']), 1)
|
||||
|
Loading…
Reference in New Issue
Block a user