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'},
|
'autoload': {'$ref': '#/definitions/dependency_selection'},
|
||||||
'prerequisites': {'$ref': '#/definitions/dependency_selection'},
|
'prerequisites': {'$ref': '#/definitions/dependency_selection'},
|
||||||
'conflict': {'type': 'string'},
|
'conflict': {'$ref': '#/definitions/array_of_strings'},
|
||||||
'environment': {
|
'environment': {
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
'default': {},
|
'default': {},
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import string
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
import spack
|
import spack
|
||||||
@ -499,15 +500,20 @@ def header(self):
|
|||||||
def module_specific_content(self, configuration):
|
def module_specific_content(self, configuration):
|
||||||
naming_tokens = self.tokens
|
naming_tokens = self.tokens
|
||||||
# Conflict
|
# Conflict
|
||||||
conflict_format = configuration.get('conflict', '')
|
conflict_format = configuration.get('conflict', [])
|
||||||
if conflict_format:
|
f = string.Formatter()
|
||||||
for naming_dir, conflict_dir in zip(self.naming_scheme.split('/'), conflict_format.split('/')):
|
for item in conflict_format:
|
||||||
if naming_dir != conflict_dir:
|
line = 'conflict ' + item + '\n'
|
||||||
message = 'Conflict scheme does not match naming scheme [{spec}]\n\n'
|
if len([x for x in f.parse(line)]) > 1: # We do have placeholder to substitute
|
||||||
message += 'naming scheme : "{nformat}"\n'
|
for naming_dir, conflict_dir in zip(self.naming_scheme.split('/'), item.split('/')):
|
||||||
message += 'conflict scheme : "{cformat}"\n'
|
if naming_dir != conflict_dir:
|
||||||
raise tty.error(
|
message = 'conflict scheme does not match naming scheme [{spec}]\n\n'
|
||||||
message.format(spec=self.spec, nformat=self.naming_scheme, cformat=conflict_format)
|
message += 'naming scheme : "{nformat}"\n'
|
||||||
)
|
message += 'conflict scheme : "{cformat}"\n\n'
|
||||||
conflict_format = 'conflict ' + conflict_format
|
message += '** You may want to check your `modules.yaml` configuration file **\n'
|
||||||
yield conflict_format.format(**naming_tokens)
|
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
|
from spack.test.mock_packages_test import MockPackagesTest
|
||||||
|
|
||||||
|
|
||||||
@ -124,3 +134,11 @@ def test_blacklist(self):
|
|||||||
content = self.get_modulefile_content(spec)
|
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 'is-loaded' in x]), 1)
|
||||||
self.assertEqual(len([x for x in content if 'module load ' 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