Skip to content

Commit 643b2b2

Browse files
authored
Merge pull request #236 from rafi/fix/symlinks
When loading, get the config canonical file path
2 parents 6eabe5e + 1dc1f49 commit 643b2b2

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

tests/test_cli.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def check_cmd(config_arg):
263263

264264
def test_load_workspace(server, monkeypatch):
265265
# this is an implementation test. Since this testsuite may be ran within
266-
# a tmux session by the developer themselv, delete the TMUX variable
266+
# a tmux session by the developer himself, delete the TMUX variable
267267
# temporarily.
268268
monkeypatch.delenv('TMUX', raising=False)
269269
session_file = curjoin("workspacebuilder/two_pane.yaml")
@@ -278,6 +278,37 @@ def test_load_workspace(server, monkeypatch):
278278
assert session.name == 'sampleconfig'
279279

280280

281+
def test_load_symlinked_workspace(server, tmpdir, monkeypatch):
282+
# this is an implementation test. Since this testsuite may be ran within
283+
# a tmux session by the developer himself, delete the TMUX variable
284+
# temporarily.
285+
monkeypatch.delenv('TMUX', raising=False)
286+
287+
realtemp = tmpdir.mkdir('myrealtemp')
288+
linktemp = tmpdir.join('symlinktemp')
289+
linktemp.mksymlinkto(realtemp)
290+
projfile = linktemp.join('simple.yaml')
291+
292+
projfile.write("""
293+
session_name: samplesimple
294+
start_directory: './'
295+
windows:
296+
- panes:
297+
- echo 'hey'""")
298+
299+
# open it detached
300+
session = load_workspace(
301+
projfile.strpath,
302+
socket_name=server.socket_name,
303+
detached=True
304+
)
305+
pane = session.attached_window.attached_pane
306+
307+
assert isinstance(session, libtmux.Session)
308+
assert session.name == 'samplesimple'
309+
assert pane.current_path == realtemp.strpath
310+
311+
281312
def test_regression_00132_session_name_with_dots(tmpdir, server, session):
282313
yaml_config = curjoin("workspacebuilder/regression_00132_dots.yaml")
283314
cli_args = [yaml_config]

tmuxp/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ def load_workspace(
218218
:param type: string
219219
220220
"""
221+
# get the canonical path, eliminating any symlinks
222+
config_file = os.path.realpath(config_file)
221223

222224
sconfig = kaptan.Kaptan()
223225
sconfig = sconfig.import_config(config_file).get()

0 commit comments

Comments
 (0)