From 4d35ac6a1632cbdd37b6f876b6963125a29bb776 Mon Sep 17 00:00:00 2001
From: Massimiliano Culpo <massimiliano.culpo@googlemail.com>
Date: Sun, 30 Oct 2016 20:30:51 +0100
Subject: [PATCH] configuration file for modules : fixed enable keyword (#2176)

- enable keyword works again
- test/modules.py : proper clean-up after tests
---
 lib/spack/spack/hooks/lmodmodule.py           | 35 -------------------
 .../{dotkit.py => module_file_generation.py}  | 10 +++---
 lib/spack/spack/hooks/tclmodule.py            | 35 -------------------
 lib/spack/spack/test/modules.py               |  4 +++
 4 files changed, 10 insertions(+), 74 deletions(-)
 delete mode 100644 lib/spack/spack/hooks/lmodmodule.py
 rename lib/spack/spack/hooks/{dotkit.py => module_file_generation.py} (84%)
 delete mode 100644 lib/spack/spack/hooks/tclmodule.py

diff --git a/lib/spack/spack/hooks/lmodmodule.py b/lib/spack/spack/hooks/lmodmodule.py
deleted file mode 100644
index 6b4318b1d0..0000000000
--- a/lib/spack/spack/hooks/lmodmodule.py
+++ /dev/null
@@ -1,35 +0,0 @@
-##############################################################################
-# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
-# Produced at the Lawrence Livermore National Laboratory.
-#
-# This file is part of Spack.
-# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
-# LLNL-CODE-647188
-#
-# For details, see https://scalability-llnl.github.io/spack
-# Please also see the LICENSE file for our notice and the LGPL.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License (as published by
-# the Free Software Foundation) version 2.1 dated February 1999.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
-# conditions of the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##############################################################################
-import spack.modules
-
-
-def post_install(pkg):
-    dk = spack.modules.LmodModule(pkg.spec)
-    dk.write()
-
-
-def post_uninstall(pkg):
-    dk = spack.modules.LmodModule(pkg.spec)
-    dk.remove()
diff --git a/lib/spack/spack/hooks/dotkit.py b/lib/spack/spack/hooks/module_file_generation.py
similarity index 84%
rename from lib/spack/spack/hooks/dotkit.py
rename to lib/spack/spack/hooks/module_file_generation.py
index a140646e04..445cea4e91 100644
--- a/lib/spack/spack/hooks/dotkit.py
+++ b/lib/spack/spack/hooks/module_file_generation.py
@@ -26,10 +26,12 @@
 
 
 def post_install(pkg):
-    dk = spack.modules.Dotkit(pkg.spec)
-    dk.write()
+    for item, cls in spack.modules.module_types.iteritems():
+        generator = cls(pkg.spec)
+        generator.write()
 
 
 def post_uninstall(pkg):
-    dk = spack.modules.Dotkit(pkg.spec)
-    dk.remove()
+    for item, cls in spack.modules.module_types.iteritems():
+        generator = cls(pkg.spec)
+        generator.remove()
diff --git a/lib/spack/spack/hooks/tclmodule.py b/lib/spack/spack/hooks/tclmodule.py
deleted file mode 100644
index 2c88810c97..0000000000
--- a/lib/spack/spack/hooks/tclmodule.py
+++ /dev/null
@@ -1,35 +0,0 @@
-##############################################################################
-# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
-# Produced at the Lawrence Livermore National Laboratory.
-#
-# This file is part of Spack.
-# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
-# LLNL-CODE-647188
-#
-# For details, see https://github.com/llnl/spack
-# Please also see the LICENSE file for our notice and the LGPL.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License (as
-# published by the Free Software Foundation) version 2.1, February 1999.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
-# conditions of the GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##############################################################################
-import spack.modules
-
-
-def post_install(pkg):
-    dk = spack.modules.TclModule(pkg.spec)
-    dk.write()
-
-
-def post_uninstall(pkg):
-    dk = spack.modules.TclModule(pkg.spec)
-    dk.remove()
diff --git a/lib/spack/spack/test/modules.py b/lib/spack/spack/test/modules.py
index 625f56b8b6..cdaeef3339 100644
--- a/lib/spack/spack/test/modules.py
+++ b/lib/spack/spack/test/modules.py
@@ -28,6 +28,7 @@
 import StringIO
 import spack.modules
 import spack.spec
+import llnl.util.filesystem
 from spack.test.mock_packages_test import MockPackagesTest
 
 FILE_REGISTRY = collections.defaultdict(StringIO.StringIO)
@@ -104,6 +105,7 @@ def setUp(self):
         self.configuration_instance = spack.modules.CONFIGURATION
         self.module_types_instance = spack.modules.module_types
         spack.modules.open = mock_open
+        spack.modules.mkdirp = lambda x: None
         # Make sure that a non-mocked configuration will trigger an error
         spack.modules.CONFIGURATION = None
         spack.modules.module_types = {self.factory.name: self.factory}
@@ -112,6 +114,7 @@ def tearDown(self):
         del spack.modules.open
         spack.modules.module_types = self.module_types_instance
         spack.modules.CONFIGURATION = self.configuration_instance
+        spack.modules.mkdirp = llnl.util.filesystem.mkdirp
         super(ModuleFileGeneratorTests, self).tearDown()
 
     def get_modulefile_content(self, spec):
@@ -119,6 +122,7 @@ def get_modulefile_content(self, spec):
         generator = self.factory(spec)
         generator.write()
         content = FILE_REGISTRY[generator.file_name].split('\n')
+        generator.remove()
         return content
 
 
-- 
GitLab