Fix Python test suite failures on Windows. - #801
Open
MohammedAlkindi wants to merge 4 commits into
Open
MohammedAlkindi wants to merge 4 commits into
MohammedAlkindi wants to merge 4 commits into
Conversation
Six test modules make POSIX-only assumptions. python_tests.yml runs on
ubuntu-latest only, so none of them are observable in CI. No product code
is changed.
cache_test: ntpath.join('C:', name) is drive-relative and inserts no
separator. Mirror the cache_path + os.sep construction _DestinationPath
itself uses.
installer_test: two assertions built '{}/build_info.yaml' by hand where
the source calls os.path.join, and test_exit_win_pe expected a POSIX
literal rather than the WINPE_TASK_LIST and SYS_TASK_LIST constants
ExitWinPE actually passes to CopyFile.
logs_test: reproduce zipfile's own arcname rule (strip the drive, then
normalize to '/') instead of lstrip('/'), which is a no-op on 'C:\...'.
powershell_test: _GetResPath ends in os.path.normpath, so the expected
value needs normalizing too.
download_test: absltest's create_tempfile opens str content in text mode,
so the '\n' in _TEST_INI reached disk as '\r\n' and the hardcoded SHA256
no longer matched. Passing bytes routes through write_bytes, which does
no newline translation on any platform.
ntp_test: time.tzset() does not exist on Windows, so the module raised
AttributeError before any assertion ran. Mocking time.localtime pins the
same effective timezone portably. The binary assertion also named
SYS_SYSTEM32, while ntp.py builds BINARY from WINPE_SYSTEM32.
SyncClockToNtp is reached only under autobuild.py's
if winpe.check_winpe() guard, so WINPE_SYSTEM32 is the correct root and
the assertion was wrong. The two constants collapse to one string under
posixpath, which is why this never surfaced.
Measured on Windows 11, Python 3.13.13: 56 passing / 3 failing before,
57 passing / 2 failing after. splice_test needs elevation to write
C:\Program Files\Splice; drivers_test is unrelated to these changes.
Author
|
The measurement note above now has a PR behind it: #802 makes That is why the counts here were taken with the substitution applied by hand. Unpatched, the runner reports The two touch disjoint files and can land in either order, though #802 first gives the cleaner story, since its own numbers are measured against unmodified tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Python test suite does not pass on Windows. Six modules assert POSIX-only behaviour, and
python_tests.ymlrunsubuntu-latestonly, so none of it is visible in CI. No product code is changed.Four are separator assumptions the diff makes obvious.
download_testis subtler: it hardcodes the SHA256 of LF text, butabsltest.create_tempfileopensstrcontent in text mode, so the file reaches disk as CRLF. Passing bytes skips the translation.ntp_testis two problems.time.tzset()does not exist on Windows, so the module raisedAttributeErrorbefore any assertion ran. It also assertedSYS_SYSTEM32whilentp.pybuildsBINARYfromWINPE_SYSTEM32.SyncClockToNtpruns only underautobuild.py'sif winpe.check_winpe()guard, soWINPE_SYSTEM32is correct and the assertion was wrong. The two constants collapse to one string underposixpath, which is why this never surfaced. Same root cause as #796.Windows 11, Python 3.13.13: 56 passing / 3 failing before, 57 / 2 after. Counts come from
testing/run_tests.pywithsys.executablesubstituted for its PATH lookup ofpython, which is a separate issue and not part of this change.splice_testanddrivers_teststill fail; the first needs elevation to writeC:\Program Files\Splice.