From a7ad344c2a4c248ed5d00c4ef3f63efa02c28e34 Mon Sep 17 00:00:00 2001 From: Carson Woods Date: Thu, 18 Jul 2019 11:28:23 -0600 Subject: [PATCH] Add upstreams.yaml testing file so calls to upstreams['global] doesn't cause tests to fail --- lib/spack/spack/database.py | 5 ++--- lib/spack/spack/test/conftest.py | 2 ++ lib/spack/spack/test/data/upstreams.yaml | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 lib/spack/spack/test/data/upstreams.yaml diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py index a2e5c72e386..78e24534387 100644 --- a/lib/spack/spack/database.py +++ b/lib/spack/spack/database.py @@ -199,15 +199,14 @@ def __init__(self, root, db_dir=None, upstream_dbs=None, self.is_upstream = is_upstream - # Create global - index_path = self._index_path + # Create .spack-db/index.json for global upstream it doesn't exist global_install_tree = spack.config.get( 'upstreams')['global']['install_tree'] global_install_tree = global_install_tree.replace( '$spack', spack.paths.prefix) if self.is_upstream: if global_install_tree in self._db_dir: - if not os.path.isfile(index_path): + if not os.path.isfile(self._index_path): f = open(self._index_path, "w+") database = { 'database': { diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 51ba0966931..de61f1c1fe4 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -290,6 +290,7 @@ def configuration_dir(tmpdir_factory, linux_os): packages_yaml = test_path.join('data', 'packages.yaml') config_yaml = test_path.join('data', 'config.yaml') repos_yaml = test_path.join('data', 'repos.yaml') + upstreams_yaml = test_path.join('data', 'upstreams.yaml') # Create temporary 'site' and 'user' folders tmpdir.ensure('site', dir=True) @@ -299,6 +300,7 @@ def configuration_dir(tmpdir_factory, linux_os): packages_yaml.copy(tmpdir.join('site', 'packages.yaml')) config_yaml.copy(tmpdir.join('site', 'config.yaml')) repos_yaml.copy(tmpdir.join('site', 'repos.yaml')) + upstreams_yaml.copy(tmpdir.join('site', 'upstreams.yaml')) # Write the one that needs modifications content = ''.join(compilers_yaml.read()).format(linux_os) diff --git a/lib/spack/spack/test/data/upstreams.yaml b/lib/spack/spack/test/data/upstreams.yaml new file mode 100644 index 00000000000..0efae97ce19 --- /dev/null +++ b/lib/spack/spack/test/data/upstreams.yaml @@ -0,0 +1,7 @@ +upstreams: + global: + install_tree: $spack/opt/spack + modules: + tcl: $spack/share/spack/modules + lmod: $spack/share/spack/lmod + dotkit: $spack/share/spack/dotkit \ No newline at end of file