Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion launch/launch/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _renew_latest_log_dir(*, log_dir: str) -> bool:
if not os.path.islink(latest_dir):
return False
os.unlink(latest_dir)
os.symlink(log_dir, latest_dir, target_is_directory=True)
os.symlink(os.path.basename(log_dir), latest_dir, target_is_directory=True)
return True


Expand Down
14 changes: 14 additions & 0 deletions launch/test/launch/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ def mock_clean_env(monkeypatch):
monkeypatch.delenv('OVERRIDE_LAUNCH_LOG_FORMAT', raising=False)


def test_renew_latest_log_dir_uses_relative_target(tmp_path):
log_dir = tmp_path / 'run'
latest_dir = tmp_path / 'latest'

with mock.patch('launch.logging.os.symlink') as symlink_mock:
assert launch.logging._renew_latest_log_dir(log_dir=str(log_dir))

target = symlink_mock.call_args.args[0]
assert not os.path.isabs(target)
assert os.path.normpath(os.path.join(tmp_path, target)) == str(log_dir)
symlink_mock.assert_called_once_with(
log_dir.name, str(latest_dir), target_is_directory=True)


def test_bad_logging_launch_config(mock_clean_env):
"""Tests that setup throws at bad configuration."""
launch.logging.reset()
Expand Down