Skip to content

fix test failures on Windows with a non-UTC timezone / MSYS2 bash - #10535

Merged
ThomasWaldmann merged 3 commits into
borgbackup:masterfrom
ThomasWaldmann:fix-win-local-tests
Oct 18, 2026
Merged

ThomasWaldmann merged 3 commits into
borgbackup:masterfrom
ThomasWaldmann:fix-win-local-tests

Conversation

@ThomasWaldmann

@ThomasWaldmann ThomasWaldmann commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Running the test suite on Windows 11 (de-DE, CET, MSYS2 UCRT64, Python 3.14) gave 3 failures that CI (UTC, en-US, no bash >= 4) does not see:

  • recreate_cmd_test.py::test_recreate_with_given_timestamp (archiver and binary_archiver): --timestamp 1970-01-02T00:00:00 is converted to local time with datetime.astimezone(). In timezones east of UTC, CPython probes the local offset 24h earlier, which is before the epoch, and Windows' localtime() raises OSError: [Errno 22]. parse_local_timestamp let that escape, so borg crashed with a traceback. In the binary variant, the test harness then also hit a UnicodeDecodeError, because the German Windows error text is cp1252, not UTF-8.
    • parse_local_timestamp now turns that OSError into a ValueError. For --timestamp (create, recreate, prune), argparse then reports invalid timestamp value: '1970-01-02T00:00:00'.
    • The test now uses 1970-01-03, which converts fine.
  • completion_cmd_test.py::test_bash_repo_url_no_directories: created directories like ssh:, which is an invalid file name on Windows (WinError 123). The test now creates them from bash instead: MSYS2/Cygwin map the colon to a valid file name character, so the test checks the same thing on Windows. CI skips this test (no bash >= 4), but it runs on a dev box with MSYS2 bash 5. The zsh/fish/tcsh siblings do not create directories.

Also: scripts/msys2-install-deps now installs python-setuptools-scm. This is only needed for pip install --no-build-isolation, where pip does not install the build-system requirements from pyproject.toml. The script already installs the other ones via pacman. Without setuptools-scm, sdist dependencies such as borghash got built as version 0.0.0, and dependency resolution failed. With build isolation (the default, also used by CI), pip installs it into the build environment anyway.

…rror

On Windows, converting a naive timestamp shortly after the epoch to local
time raises OSError (Errno 22) in timezones east of UTC, e.g. 1970-01-02T00:00:00
in CET, because CPython probes the local offset 24h earlier. borg recreate/create/prune
--timestamp then crashed with a traceback. As ValueError, argparse reports it
as an invalid timestamp value.

test_recreate_with_given_timestamp now uses 1970-01-03T00:00:00, which converts
fine on Windows east of UTC.
@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.36%. Comparing base (3c95ce7) to head (5a78cf4).
⚠️ Report is 9 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10535      +/-   ##
==========================================
+ Coverage   89.32%   89.36%   +0.04%     
==========================================
  Files         104      104              
  Lines       20079    20082       +3     
  Branches     3152     3152              
==========================================
+ Hits        17936    17947      +11     
+ Misses       1484     1478       -6     
+ Partials      659      657       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

test_bash_repo_url_no_directories created directories like "rclone:" from
Python, which is an invalid file name on Windows (WinError 123). Creating them
from bash works everywhere: MSYS2/Cygwin map the colon to a valid file name
character, so the test still checks the same thing on Windows.

The test is skipped in CI because there is no bash >= 4 there, but runs on a
dev box with MSYS2 bash 5.
Only needed for pip install --no-build-isolation, where pip does not install
the build-system requirements from pyproject.toml. The script already installs
the other ones via pacman, but setuptools-scm was missing, so packages built
from sdist (e.g. borghash) got version 0.0.0 and dependency resolution failed.

With build isolation (the default, also used by CI), pip installs setuptools-scm
into the build environment anyway.
@ThomasWaldmann
ThomasWaldmann merged commit 7329135 into borgbackup:master Oct 18, 2026
25 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the fix-win-local-tests branch October 18, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant