env: remove all -e arguments on subcommands
- add and remove now require an active environment - update tests to use with <ENV> instead of -e
This commit is contained in:
parent
d483e6e17b
commit
08e4720ed9
@ -61,13 +61,16 @@ def get_env(args, cmd_name, fail_on_error=True):
|
|||||||
"""
|
"""
|
||||||
env = args.env
|
env = args.env
|
||||||
if not env:
|
if not env:
|
||||||
env = os.environ.get('SPACK_ENV')
|
if ev.active:
|
||||||
if not env:
|
return ev.active
|
||||||
if not fail_on_error:
|
elif not fail_on_error:
|
||||||
return None
|
return None
|
||||||
tty.die(
|
tty.die(
|
||||||
'spack env %s requires an active environment or an argument'
|
'`spack env %s` requires an environment' % cmd_name,
|
||||||
% cmd_name)
|
'activate an environment first:',
|
||||||
|
' spack env activate ENV',
|
||||||
|
'or use:',
|
||||||
|
' spack -e ENV %s ...' % cmd_name)
|
||||||
|
|
||||||
environment = ev.disambiguate(env)
|
environment = ev.disambiguate(env)
|
||||||
|
|
||||||
@ -308,8 +311,6 @@ def env_list(args):
|
|||||||
#
|
#
|
||||||
def env_add_setup_parser(subparser):
|
def env_add_setup_parser(subparser):
|
||||||
"""add a spec to an environment"""
|
"""add a spec to an environment"""
|
||||||
subparser.add_argument(
|
|
||||||
'-e', '--env', help='add spec to this environment')
|
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'specs', nargs=argparse.REMAINDER, help="spec of the package to add")
|
'specs', nargs=argparse.REMAINDER, help="spec of the package to add")
|
||||||
|
|
||||||
@ -331,8 +332,6 @@ def env_add(args):
|
|||||||
#
|
#
|
||||||
def env_remove_setup_parser(subparser):
|
def env_remove_setup_parser(subparser):
|
||||||
"""remove a spec from an environment"""
|
"""remove a spec from an environment"""
|
||||||
subparser.add_argument(
|
|
||||||
'-e', '--env', help='remove spec with this name from environment')
|
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'-a', '--all', action='store_true', dest='all',
|
'-a', '--all', action='store_true', dest='all',
|
||||||
help="Remove all specs from (clear) the environment")
|
help="Remove all specs from (clear) the environment")
|
||||||
|
@ -144,18 +144,23 @@ def test_remove_after_concretize():
|
|||||||
def test_remove_command():
|
def test_remove_command():
|
||||||
env('create', 'test')
|
env('create', 'test')
|
||||||
|
|
||||||
env('add', '-e', 'test', 'mpileaks')
|
with ev.read('test'):
|
||||||
|
env('add', 'mpileaks')
|
||||||
assert 'mpileaks' in env('status', 'test')
|
assert 'mpileaks' in env('status', 'test')
|
||||||
|
|
||||||
env('remove', '-e', 'test', 'mpileaks')
|
with ev.read('test'):
|
||||||
|
env('remove', 'mpileaks')
|
||||||
assert 'mpileaks' not in env('status', 'test')
|
assert 'mpileaks' not in env('status', 'test')
|
||||||
|
|
||||||
env('add', '-e', 'test', 'mpileaks')
|
with ev.read('test'):
|
||||||
|
env('add', 'mpileaks')
|
||||||
assert 'mpileaks' in env('status', 'test')
|
assert 'mpileaks' in env('status', 'test')
|
||||||
|
|
||||||
env('concretize', 'test')
|
env('concretize', 'test')
|
||||||
assert 'mpileaks' in env('status', 'test')
|
assert 'mpileaks' in env('status', 'test')
|
||||||
|
|
||||||
env('remove', '-e', 'test', 'mpileaks')
|
with ev.read('test'):
|
||||||
|
env('remove', 'mpileaks')
|
||||||
assert 'mpileaks' not in env('status', 'test')
|
assert 'mpileaks' not in env('status', 'test')
|
||||||
|
|
||||||
|
|
||||||
@ -478,7 +483,9 @@ def test_bad_env_yaml_format(tmpdir):
|
|||||||
|
|
||||||
def test_env_loads(install_mockery, mock_fetch):
|
def test_env_loads(install_mockery, mock_fetch):
|
||||||
env('create', 'test')
|
env('create', 'test')
|
||||||
env('add', '-e', 'test', 'mpileaks')
|
|
||||||
|
with ev.read('test'):
|
||||||
|
env('add', 'mpileaks')
|
||||||
env('concretize', 'test')
|
env('concretize', 'test')
|
||||||
env('install', '--fake', 'test')
|
env('install', '--fake', 'test')
|
||||||
env('loads', 'test')
|
env('loads', 'test')
|
||||||
@ -496,8 +503,9 @@ def test_env_loads(install_mockery, mock_fetch):
|
|||||||
@pytest.mark.disable_clean_stage_check
|
@pytest.mark.disable_clean_stage_check
|
||||||
def test_env_stage(mock_stage, mock_fetch, install_mockery):
|
def test_env_stage(mock_stage, mock_fetch, install_mockery):
|
||||||
env('create', 'test')
|
env('create', 'test')
|
||||||
env('add', '-e', 'test', 'mpileaks')
|
with ev.read('test'):
|
||||||
env('add', '-e', 'test', 'zmpi')
|
print env('add', 'mpileaks')
|
||||||
|
print env('add', 'zmpi')
|
||||||
env('concretize', 'test')
|
env('concretize', 'test')
|
||||||
env('stage', 'test')
|
env('stage', 'test')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user