Update tests so /tmp/store can be accessed (#32003)

This commit is contained in:
Richarda Butler 2022-08-10 13:53:48 -07:00 committed by GitHub
parent 98a540c793
commit ef818339db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 13 deletions

View File

@ -2,7 +2,6 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details. # Spack Project Developers. See the top-level COPYRIGHT file for details.
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
import sys import sys
import pytest import pytest
@ -139,6 +138,7 @@ def test_custom_store_in_environment(mutable_config, tmpdir):
# Test that the custom store in an environment is taken into account # Test that the custom store in an environment is taken into account
# during bootstrapping # during bootstrapping
spack_yaml = tmpdir.join("spack.yaml") spack_yaml = tmpdir.join("spack.yaml")
install_root = tmpdir.join("store")
spack_yaml.write( spack_yaml.write(
""" """
spack: spack:
@ -146,16 +146,18 @@ def test_custom_store_in_environment(mutable_config, tmpdir):
- libelf - libelf
config: config:
install_tree: install_tree:
root: /tmp/store root: {0}
""" """.format(
install_root
)
) )
with spack.environment.Environment(str(tmpdir)): with spack.environment.Environment(str(tmpdir)):
assert spack.environment.active_environment() assert spack.environment.active_environment()
assert spack.config.get("config:install_tree:root") == "/tmp/store" assert spack.config.get("config:install_tree:root") == install_root
# Don't trigger evaluation here # Don't trigger evaluation here
with spack.bootstrap.ensure_bootstrap_configuration(): with spack.bootstrap.ensure_bootstrap_configuration():
pass pass
assert str(spack.store.root) == os.sep + os.path.join("tmp", "store") assert str(spack.store.root) == install_root
def test_nested_use_of_context_manager(mutable_config): def test_nested_use_of_context_manager(mutable_config):

View File

@ -2729,6 +2729,7 @@ def test_activation_and_deactiviation_ambiguities(method, env, no_env, env_dir,
@pytest.mark.regression("26548") @pytest.mark.regression("26548")
def test_custom_store_in_environment(mutable_config, tmpdir): def test_custom_store_in_environment(mutable_config, tmpdir):
spack_yaml = tmpdir.join("spack.yaml") spack_yaml = tmpdir.join("spack.yaml")
install_root = tmpdir.join("store")
spack_yaml.write( spack_yaml.write(
""" """
spack: spack:
@ -2736,17 +2737,15 @@ def test_custom_store_in_environment(mutable_config, tmpdir):
- libelf - libelf
config: config:
install_tree: install_tree:
root: /tmp/store root: {0}
""" """.format(
install_root
)
) )
if sys.platform == "win32":
sep = "\\"
else:
sep = "/"
current_store_root = str(spack.store.root) current_store_root = str(spack.store.root)
assert str(current_store_root) != sep + os.path.join("tmp", "store") assert str(current_store_root) != install_root
with spack.environment.Environment(str(tmpdir)): with spack.environment.Environment(str(tmpdir)):
assert str(spack.store.root) == sep + os.path.join("tmp", "store") assert str(spack.store.root) == install_root
assert str(spack.store.root) == current_store_root assert str(spack.store.root) == current_store_root