Skip to content

Commit 225f8b4

Browse files
Merge pull request #49 from dodecatheon/fix-PR-36
Fix bug introduced by PR #36
2 parents e2d36b3 + d0c9353 commit 225f8b4

File tree

5 files changed

+17
-34
lines changed

5 files changed

+17
-34
lines changed

lib/ramble/ramble/cmd/workspace.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,19 @@ def workspace_activate(args):
107107
# Temporary workspace
108108
if args.temp:
109109
workspace = create_temp_workspace_directory()
110-
wspath_dir = os.path.abspath(workspace)
111-
ramble.workspace.set_workspace_path(wspath_dir)
112-
short_name = os.path.basename(wspath_dir)
110+
workspace_path = os.path.abspath(workspace)
111+
short_name = os.path.basename(workspace_path)
113112
ramble.workspace.Workspace(workspace).write()
114113

115114
# Named workspace
116115
elif ramble.workspace.exists(workspace_name_or_dir) and not args.dir:
117-
wspath_dir = ramble.workspace.root(workspace_name_or_dir)
118-
ramble.workspace.set_workspace_path(wspath_dir)
116+
workspace_path = ramble.workspace.root(workspace_name_or_dir)
119117
short_name = workspace_name_or_dir
120118

121119
# Workspace directory
122120
elif ramble.workspace.is_workspace_dir(workspace_name_or_dir):
123-
workspace_path_dir = os.path.abspath(workspace_name_or_dir)
124-
ramble.workspace.set_workspace_path(workspace_path_dir)
125-
short_name = os.path.basename(workspace_path_dir)
121+
workspace_path = os.path.abspath(workspace_name_or_dir)
122+
short_name = os.path.basename(workspace_path)
126123

127124
else:
128125
tty.die("No such workspace: '%s'" % workspace_name_or_dir)
@@ -138,8 +135,7 @@ def workspace_activate(args):
138135
env_mods = ramble.workspace.shell.deactivate()
139136

140137
# Activate new workspace
141-
workspace_path_dir = ramble.workspace.get_workspace_path()
142-
active_workspace = ramble.workspace.Workspace(workspace_path_dir)
138+
active_workspace = ramble.workspace.Workspace(workspace_path)
143139
cmds += ramble.workspace.shell.activate_header(
144140
ws=active_workspace,
145141
shell=args.shell,

lib/ramble/ramble/test/cmd/workspace.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ def test_workspace_dirs(tmpdir, mutable_mock_workspace_path):
220220
# it would be expected
221221
wsdir1 = os.path.join(os.getcwd(), 'ws1')
222222
os.makedirs(wsdir1)
223-
ramble.workspace.set_workspace_path(wsdir1)
224-
workspace('create', 'test1')
225-
out = workspace('list')
223+
with ramble.config.override('config:workspace_dirs', wsdir1):
224+
workspace('create', 'test1')
225+
out = workspace('list')
226226
assert 'test1' in out
227227

228228
# Now make a second temp directory,
@@ -232,17 +232,12 @@ def test_workspace_dirs(tmpdir, mutable_mock_workspace_path):
232232
# second is
233233
wsdir2 = os.path.join(os.getcwd(), 'ws2')
234234
os.makedirs(wsdir2)
235-
ramble.workspace.set_workspace_path(wsdir2)
236-
workspace('create', 'test2')
237-
out = workspace('list')
235+
with ramble.config.override('config:workspace_dirs', wsdir2):
236+
workspace('create', 'test2')
237+
out = workspace('list')
238238
assert 'test2' in out
239239
assert 'test1' not in out
240240

241-
# Cleanup after test
242-
workspace('remove', '-y', 'test2')
243-
ramble.workspace.set_workspace_path(wsdir1)
244-
workspace('remove', '-y', 'test1')
245-
246241

247242
def test_remove_workspace(capfd):
248243
workspace('create', 'foo')

lib/ramble/ramble/test/conftest.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,9 @@ def _factory(name, output, subdir=('bin',)):
387387
@pytest.fixture(scope='function')
388388
def mutable_mock_workspace_path(tmpdir_factory, mutable_config):
389389
"""Fixture for mocking the internal ramble workspaces directory."""
390-
saved_path = ramble.workspace.get_workspace_path()
391390
mock_path = tmpdir_factory.mktemp('mock-workspace-path')
392-
ramble.workspace.set_workspace_path(str(mock_path))
393-
yield mock_path
394-
ramble.workspace.set_workspace_path(saved_path)
391+
with ramble.config.override('config:workspace_dirs', str(mock_path)):
392+
yield mock_path
395393

396394

397395
@pytest.fixture

lib/ramble/ramble/workspace/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
exists,
3030
is_workspace_dir,
3131
get_workspace_path,
32-
set_workspace_path,
3332
config_file,
3433
config_file_name,
3534
workspace_software_path,
@@ -61,7 +60,6 @@
6160
'exists',
6261
'is_workspace_dir',
6362
'get_workspace_path',
64-
'set_workspace_path',
6563
'config_file',
6664
'config_file_name',
6765
'workspace_software_path',

lib/ramble/ramble/workspace/workspace.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,13 @@ def get_workspace_path():
286286
"""Returns current directory of ramble-managed workspaces"""
287287
path_in_config = ramble.config.get('config:workspace_dirs')
288288
if not path_in_config:
289-
path_in_config = '$ramble/var/ramble/GET_WORKSPACE_ERROR/'
289+
# command above should have worked, so if it doesn't, error out:
290+
tty.die('No config:workspace_dirs setting found in configuration!')
290291

291-
wspath = ramble.util.path.canonicalize_path(path_in_config)
292+
wspath = ramble.util.path.canonicalize_path(str(path_in_config))
292293
return wspath
293294

294295

295-
def set_workspace_path(dirname):
296-
"""Sets the parent directory of ramble-managed workspaces"""
297-
ramble.config.set('config:workspace_dirs:', dirname)
298-
299-
300296
def _root(name):
301297
"""Non-validating version of root(), to be used internally."""
302298
wspath = get_workspace_path()

0 commit comments

Comments
 (0)