Skip to content

Commit 0221b98

Browse files
authored
Fix macOS CI failures (#172)
* Fix macOS CI failures 1. Change `cd path;pwd` to `cd path && pwd` so pwd only runs if cd succeeds. On macOS, the shell returns the current directory when cd fails, causing incorrect --link-dest paths. 2. Add encoding="utf-8", errors="surrogateescape" when reading rsync log files. Log files may contain non-UTF8 filenames which cause UnicodeDecodeError on macOS. * Re-fetch previous_dest after resume handler renames folder * Skip PID check when it matches current process (allows re-entrancy) * Add trailing newline to exclusion file in test (macOS rsync compatibility) * Remove unnecessary PID re-entrancy check * Remove re-fetch previous_dest (testing if needed) * Add Python 3.13 and 3.14 to CI matrix
1 parent 76363be commit 0221b98

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [ubuntu-latest, macos-latest]
11-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] # skip unsupported versions (3.7)
11+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1212

1313
steps:
1414
- uses: actions/checkout@v6

rsync_time_machine.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def find(path: str, ssh: SSH | None = None, maxdepth: int | None = None) -> str:
460460

461461
def get_absolute_path(path: str, ssh: SSH | None = None) -> str:
462462
"""Get the absolute path of the given path."""
463-
return run_cmd(f"cd '{path}';pwd", ssh).stdout
463+
return run_cmd(f"cd '{path}' && pwd", ssh).stdout
464464

465465

466466
def mkdir(path: str, ssh: SSH | None = None) -> None:
@@ -694,7 +694,7 @@ def deal_with_no_space_left(
694694
auto_expire: bool,
695695
) -> bool:
696696
"""Deal with no space left on device."""
697-
with open(log_file) as f:
697+
with open(log_file, encoding="utf-8", errors="surrogateescape") as f:
698698
log_data = f.read()
699699

700700
no_space_left = re.search(
@@ -727,7 +727,7 @@ def check_rsync_errors(
727727
auto_delete_log: bool, # noqa: FBT001
728728
) -> None:
729729
"""Check rsync errors."""
730-
with open(log_file) as f:
730+
with open(log_file, encoding="utf-8", errors="surrogateescape") as f:
731731
log_data = f.read()
732732
if "rsync error:" in log_data:
733733
log_error(

tests/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def test_backup(tmp_path: Path, capsys: pytest.CaptureFixture) -> None: # noqa:
435435
(src_folder / "file2.txt").write_text("Hello, World!")
436436
(src_folder / "file3.txt").write_text("Hello, World!")
437437
exclusion_file = tmp_path / "exclusion_file.txt"
438-
exclusion_file.write_text("file2.txt")
438+
exclusion_file.write_text("file2.txt\n")
439439
with patch_now_str(seconds=0):
440440
new_kw = dict(kw, exclusion_file=str(tmp_path / "exclusion_file.txt"))
441441
backup(**new_kw) # type: ignore[arg-type]

0 commit comments

Comments
 (0)