summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/environment.py8
-rw-r--r--lib/spack/spack/test/data/sourceme_parameters.sh7
-rw-r--r--lib/spack/spack/test/environment.py8
3 files changed, 20 insertions, 3 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index b0eadef7a6..de30a9c7be 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -271,8 +271,12 @@ class EnvironmentModifications(object):
env = EnvironmentModifications()
# Check if the files are actually there
- if not all(os.path.isfile(file) for file in args):
- raise RuntimeError('trying to source non-existing files')
+ files = [line.split(' ')[0] for line in args]
+ non_existing = [file for file in files if not os.path.isfile(file)]
+ if non_existing:
+ message = 'trying to source non-existing files\n'
+ message += '\n'.join(non_existing)
+ raise RuntimeError(message)
# Relevant kwd parameters and formats
info = dict(kwargs)
info.setdefault('shell', '/bin/bash')
diff --git a/lib/spack/spack/test/data/sourceme_parameters.sh b/lib/spack/spack/test/data/sourceme_parameters.sh
new file mode 100644
index 0000000000..3826eb092b
--- /dev/null
+++ b/lib/spack/spack/test/data/sourceme_parameters.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+if [[ "$1" == "intel64" ]] ; then
+ export FOO='intel64'
+else
+ export FOO='default'
+fi \ No newline at end of file
diff --git a/lib/spack/spack/test/environment.py b/lib/spack/spack/test/environment.py
index 9b5d75f273..c404433a56 100644
--- a/lib/spack/spack/test/environment.py
+++ b/lib/spack/spack/test/environment.py
@@ -119,7 +119,8 @@ class EnvironmentTest(unittest.TestCase):
'spack', 'test', 'data')
files = [
join_path(datadir, 'sourceme_first.sh'),
- join_path(datadir, 'sourceme_second.sh')
+ join_path(datadir, 'sourceme_second.sh'),
+ join_path(datadir, 'sourceme_parameters.sh intel64')
]
env = EnvironmentModifications.from_sourcing_files(*files)
modifications = env.group_by_name()
@@ -134,6 +135,11 @@ class EnvironmentTest(unittest.TestCase):
self.assertEqual(len(modifications['NEW_VAR']), 1)
self.assertTrue(isinstance(modifications['NEW_VAR'][0], SetEnv))
self.assertEqual(modifications['NEW_VAR'][0].value, 'new')
+
+ self.assertEqual(len(modifications['FOO']), 1)
+ self.assertTrue(isinstance(modifications['FOO'][0], SetEnv))
+ self.assertEqual(modifications['FOO'][0].value, 'intel64')
+
# Unset variables
self.assertEqual(len(modifications['EMPTY_PATH_LIST']), 1)
self.assertTrue(isinstance(