spack env create: generate a view when newly created env has concrete specs (#37799)
This commit is contained in:
parent
475ce955e7
commit
bf45a2b6d3
@ -302,7 +302,7 @@ def env_create(args):
|
|||||||
# the environment should not include a view.
|
# the environment should not include a view.
|
||||||
with_view = None
|
with_view = None
|
||||||
|
|
||||||
_env_create(
|
env = _env_create(
|
||||||
args.create_env,
|
args.create_env,
|
||||||
init_file=args.envfile,
|
init_file=args.envfile,
|
||||||
dir=args.dir,
|
dir=args.dir,
|
||||||
@ -310,6 +310,9 @@ def env_create(args):
|
|||||||
keep_relative=args.keep_relative,
|
keep_relative=args.keep_relative,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Generate views, only really useful for environments created from spack.lock files.
|
||||||
|
env.regenerate_views()
|
||||||
|
|
||||||
|
|
||||||
def _env_create(name_or_path, *, init_file=None, dir=False, with_view=None, keep_relative=False):
|
def _env_create(name_or_path, *, init_file=None, dir=False, with_view=None, keep_relative=False):
|
||||||
"""Create a new environment, with an optional yaml description.
|
"""Create a new environment, with an optional yaml description.
|
||||||
|
@ -3299,3 +3299,22 @@ def test_environment_created_in_users_location(mutable_config, tmpdir):
|
|||||||
assert dir_name in out
|
assert dir_name in out
|
||||||
assert env_dir in ev.root(dir_name)
|
assert env_dir in ev.root(dir_name)
|
||||||
assert os.path.isdir(os.path.join(env_dir, dir_name))
|
assert os.path.isdir(os.path.join(env_dir, dir_name))
|
||||||
|
|
||||||
|
|
||||||
|
def test_environment_created_from_lockfile_has_view(mock_packages, tmpdir):
|
||||||
|
"""When an env is created from a lockfile, a view should be generated for it"""
|
||||||
|
env_a = str(tmpdir.join("a"))
|
||||||
|
env_b = str(tmpdir.join("b"))
|
||||||
|
|
||||||
|
# Create an environment and install a package in it
|
||||||
|
env("create", "-d", env_a)
|
||||||
|
with ev.Environment(env_a):
|
||||||
|
add("libelf")
|
||||||
|
install("--fake")
|
||||||
|
|
||||||
|
# Create another environment from the lockfile of the first environment
|
||||||
|
env("create", "-d", env_b, os.path.join(env_a, "spack.lock"))
|
||||||
|
|
||||||
|
# Make sure the view was created
|
||||||
|
with ev.Environment(env_b) as e:
|
||||||
|
assert os.path.isdir(e.view_path_default)
|
||||||
|
Loading…
Reference in New Issue
Block a user