Skip to content

Fix failing windows tests#5574

Merged
stefanhaller merged 3 commits into
masterfrom
fix-failing-windows-tests
May 2, 2026
Merged

Fix failing windows tests#5574
stefanhaller merged 3 commits into
masterfrom
fix-failing-windows-tests

Conversation

@stefanhaller
Copy link
Copy Markdown
Collaborator

See commit messages for details.

stk added 3 commits May 2, 2026 17:59
The "custom time format" test case of TestGetCommitListDisplayStrings failed on
Windows. Root cause: UnixToDateSmart used time.Unix(timestamp, 0), which formats
in process-local time. In tests we pass an explicit 'now' (often UTC), but the
timestamp was rendered in Local, causing one-hour drift on non-UTC machines.

The test tried to work around this by doing os.Setenv("TZ", "UTC"); however,
this only worked on Mac and Linux. On Windows, it has no effect because Windows
uses registry-based timezone configuration, not TZ environment variables.

Change: convert the timestamp into now.Location() before both the same-day
comparison and formatting.

Why this is safe: callers already define the presentation timezone via the 'now'
argument (typically time.Now() in app code, controlled time in tests). This
aligns timestamp rendering with that caller intent and removes dependence on
global TZ state or OS-specific environment variable behavior.

Added regression tests for UTC and UTC+1 to ensure deterministic behavior across
all platforms.
The call was meant to guarantee a UTC time zone to make the tests deterministic,
but as the previous commit explained, this only worked on Mac and Linux, not on
Windows. Since we now have a better fix, this workaround is no longer needed.
Windows cannot remove files while handles are still open. In
TestOSCommandFileType we created files and immediately called RemoveAll without
closing handles, which left untracked artifacts (e.g. "testFile" and "file with
spaces") in the working tree. Close the handles and assert RemoveAll succeeds so
cleanup failures are visible.
@stefanhaller stefanhaller added the maintenance For refactorings, CI changes, tests, version bumping, etc label May 2, 2026
@stefanhaller stefanhaller merged commit f2ff1eb into master May 2, 2026
14 checks passed
@stefanhaller stefanhaller deleted the fix-failing-windows-tests branch May 2, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance For refactorings, CI changes, tests, version bumping, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant