Skip to content
Draft
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Unreleased

### Bug Fixes

- Expand `~` in configured log file paths.

### Internal

- Add a GitHub Actions workflow to run Codex review on pull requests.
Expand Down
1 change: 1 addition & 0 deletions litecli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def initialize_logging(self) -> None:
log_file = self.config["main"]["log_file"]
if log_file == "default":
log_file = config_location() + "log"
log_file = os.path.expanduser(log_file)
try:
ensure_dir_exists(log_file)
except OSError:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,23 @@ def test_startup_commands(executor):
# implement tests on executions of the startupcommands


def test_log_file_expands_user_path(tmp_path, monkeypatch, capsys):
home = tmp_path / "home"
config_file = tmp_path / "liteclirc"
with open(default_config_file, encoding="utf-8") as f:
config = f.read()
config_file.write_text(config.replace("log_file = default", "log_file = ~/.cache/litecli/log"), encoding="utf-8")

monkeypatch.setenv("HOME", str(home))
monkeypatch.setenv("USERPROFILE", str(home))

LiteCli(liteclirc=str(config_file))

captured = capsys.readouterr()
assert "Unable to open the log file" not in captured.err
assert (home / ".cache" / "litecli" / "log").exists()


@patch("litecli.main.datetime") # Adjust if your module path is different
def test_get_prompt(mock_datetime):
# We'll freeze time at 2025-01-20 13:37:42 for comedic effect.
Expand Down
Loading