summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRicharda Butler <39577672+RikkiButler20@users.noreply.github.com>2020-09-11 16:45:36 -0700
committerGitHub <noreply@github.com>2020-09-11 16:45:36 -0700
commit8116153f2a0f09f64d498d83534adab3ef6419b3 (patch)
tree7ae4d87c7c62ad9ec87767cb59630f6c1ef21965 /lib
parentafb0883762571a364c9b401334133417a779e484 (diff)
downloadspack-8116153f2a0f09f64d498d83534adab3ef6419b3.tar.gz
spack-8116153f2a0f09f64d498d83534adab3ef6419b3.tar.bz2
spack-8116153f2a0f09f64d498d83534adab3ef6419b3.tar.xz
spack-8116153f2a0f09f64d498d83534adab3ef6419b3.zip
bugfix: include configuration ignoring files with the same basename (#18487)
* Use the config path instead of the basename * Removing unused variables Co-authored-by: Greg Becker <becker33@llnl.gov> * Test Making sure if there are 2 include config files with the same basename they are both implemented * Edit test assert Co-authored-by: Greg Becker <becker33@llnl.gov>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/environment.py3
-rw-r--r--lib/spack/spack/test/cmd/env.py42
2 files changed, 43 insertions, 2 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index 04880d073f..9b9f8c7d17 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -829,8 +829,7 @@ class Environment(object):
scope = spack.config.ConfigScope(config_name, config_path)
elif os.path.exists(config_path):
# files are assumed to be SingleFileScopes
- base, ext = os.path.splitext(os.path.basename(config_path))
- config_name = 'env:%s:%s' % (self.name, base)
+ config_name = 'env:%s:%s' % (self.name, config_path)
scope = spack.config.SingleFileScope(
config_name, config_path, spack.schema.merged.schema)
else:
diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py
index a1c7e8bf01..998dd5d876 100644
--- a/lib/spack/spack/test/cmd/env.py
+++ b/lib/spack/spack/test/cmd/env.py
@@ -547,6 +547,48 @@ spack:
assert 'no/such/file.yaml' in err
+def test_env_with_include_config_files_same_basename():
+ test_config = """\
+ env:
+ include:
+ - ./path/to/included-config.yaml
+ - ./second/path/to/include-config.yaml
+ specs:
+ [libelf, mpileaks]
+ """
+
+ _env_create('test', StringIO(test_config))
+ e = ev.read('test')
+
+ fs.mkdirp(os.path.join(e.path, 'path', 'to'))
+ with open(os.path.join(
+ e.path,
+ './path/to/included-config.yaml'), 'w') as f:
+ f.write("""\
+ packages:
+ libelf:
+ version: [0.8.10]
+ """)
+
+ fs.mkdirp(os.path.join(e.path, 'second', 'path', 'to'))
+ with open(os.path.join(
+ e.path,
+ './second/path/to/include-config.yaml'), 'w') as f:
+ f.write("""\
+ packages:
+ mpileaks:
+ version: [2.2]
+ """)
+
+ with e:
+ e.concretize()
+
+ environment_specs = e._get_environment_specs(False)
+
+ assert(environment_specs[0].satisfies('libelf@0.8.10'))
+ assert(environment_specs[1].satisfies('mpileaks@2.2'))
+
+
def test_env_with_included_config_file():
test_config = """\
env: