From 0b7c673205049565a95707fd55d2c086dd601b35 Mon Sep 17 00:00:00 2001
From: alalazo <massimiliano.culpo@googlemail.com>
Date: Tue, 10 May 2016 15:48:37 +0200
Subject: [PATCH] modules : changed syntax for environment modifications

---
 lib/spack/spack/config.py       | 14 +++++++++++---
 lib/spack/spack/modules.py      | 22 +++++++++++++++++-----
 lib/spack/spack/test/modules.py |  3 +--
 3 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index d008a513e7..6ddf07776b 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -251,6 +251,14 @@
                     'type': 'string'
                 }
             },
+            'dictionary_of_strings': {
+                'type': 'object',
+                'patternProperties': {
+                    r'\w[\w-]*': {  # key
+                        'type': 'string'
+                    }
+                }
+            },
             'dependency_selection': {
                 'type': 'string',
                 'enum': ['none', 'direct', 'all']
@@ -282,10 +290,10 @@
                         'default': {},
                         'additionalProperties': False,
                         'properties': {
-                            'set': {'$ref': '#/definitions/array_of_strings'},
+                            'set': {'$ref': '#/definitions/dictionary_of_strings'},
                             'unset': {'$ref': '#/definitions/array_of_strings'},
-                            'prepend_path': {'$ref': '#/definitions/array_of_strings'},
-                            'append_path': {'$ref': '#/definitions/array_of_strings'}
+                            'prepend_path': {'$ref': '#/definitions/dictionary_of_strings'},
+                            'append_path': {'$ref': '#/definitions/dictionary_of_strings'}
                         }
                     }
                 }
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index f1c0bd87de..19bd1993a7 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -185,14 +185,26 @@ def parse_config_options(module_generator):
     # Environment modifications
     environment_actions = module_file_actions.pop('environment', {})
     env = EnvironmentModifications()
+
+    def process_arglist(arglist):
+        if method == 'unset':
+            for x in arglist:
+                yield (x,)
+        else:
+            for x in arglist.iteritems():
+                yield x
+
     for method, arglist in environment_actions.items():
-        for item in arglist:
-            if method == 'unset':
-                args = [item]
-            else:
-                args = item.split(',')
+        for args in process_arglist(arglist):
             getattr(env, method)(*args)
 
+        # for item in arglist:
+        #     if method == 'unset':
+        #         args = [item]
+        #     else:
+        #         args = item.split(',')
+        #     getattr(env, method)(*args)
+
     return module_file_actions, env
 
 
diff --git a/lib/spack/spack/test/modules.py b/lib/spack/spack/test/modules.py
index 704700417b..b8b0d6fc6a 100644
--- a/lib/spack/spack/test/modules.py
+++ b/lib/spack/spack/test/modules.py
@@ -47,7 +47,7 @@ def mock_open(filename, mode):
             'filter': {'environment_blacklist': ['CMAKE_PREFIX_PATH']}
         },
         '=x86-linux': {
-            'environment': {'set': ['FOO,foo'], 'unset': ['BAR']}
+            'environment': {'set': {'FOO': 'foo'}, 'unset': ['BAR']}
         }
     }
 }
@@ -99,7 +99,6 @@ def test_simple_case(self):
         spec = spack.spec.Spec('mpich@3.0.4=x86-linux')
         content = self.get_modulefile_content(spec)
         self.assertTrue('module-whatis "mpich @3.0.4"' in content )
-        self.assertEqual(len([x for x in content if x.startswith('prepend-path CMAKE_PREFIX_PATH')]), 1)
 
     def test_autoload(self):
         spack.modules.CONFIGURATION = configuration_autoload_direct
-- 
GitLab