Testing: Update the packaging tar bz2 and xz tests on windows - #4741
Conversation
…z/liblzma handling. Changes: * Remove searching for and prepending xz.exe to the environment path for windows. * tar.exe in Windows 10 and GH windows-2022 don't appear to support xz even if on the system path. * tar.exe in Windows 11 and GH windows-2025 appears to support xz without additions to the system path. * If the candidate tar.exe is the windows tar.exe, check the version string for liblzma support. * Remove test/packaging/tar/xz_packaging.py from thw windows test skip file.
…bz2/bz2lib handling. Changes: * Remove searching for and prepending bzip2.exe to the environment path for windows. * tar.exe in Windows 10 and GH windows-2022 don't appear to support bzip2 even if on the system path. * tar.exe in Windows 11 and GH windows-2025 appears to support bzip2 without additions to the system path. * If the candidate tar.exe is the windows tar.exe, check the version string for bz2lib support. * Strip the tar versions strings before processing.
… xz tests updates and GitHub workflow changes on Windows.
| bz2 = test.where_is('bzip2') | ||
|
|
||
| if sys.platform == 'win32': | ||
| # windows 10 causes fresh problems by supplying a tar, not bzip2 |
There was a problem hiding this comment.
Are you ignoring the git tar? Which could be used in the case where the windows tar doesn't support bz2?
There was a problem hiding this comment.
It shouldn't.
When either os.environ["SystemRoot"] or os.environ["windir"] is defined:
- The test is performed if the tar.exe is not
%SystemRoot%/system32/tar.exe. - The test may be performed if the tar.exe is
%SystemRoot%/system32/tar.exesubject to the version string check.
One of these two environment variables should be defined.
If neither variables are defined, then the "--version" string is inspected for bsdtar, - libarchive and other fields. If there is not a match for the known fields, then the test is performed.
It should be unlikely that a bsdtar executable is used when the two Windows system environment variables are undefined.
There was a problem hiding this comment.
Which could be used in the case where the windows tar doesn't support bz2?
The test, as written prior to changes, only checks the first tar executable found on the path.
There was a problem hiding this comment.
Locally annotated change (not pushed yet)
windir = os.environ.get("SystemRoot")
if not windir:
windir = os.environ.get("windir")
if not windir: # <== ADDED
windir = os.path.join(os.environ.get("SystemDrive", "C:") + os.path.sep, "Windows") # <== ADDED
expected = os.path.normcase(os.path.abspath(os.path.join(windir, "System32", "tar.exe")))
if tar != expected:
return False
Additional clause added to always test the target executable path against what should be the windows system32 path.
There was a problem hiding this comment.
Isn't windir always defined on windows?
There was a problem hiding this comment.
It should be.
Depends on your level of paranoia:
(3.12.9) S:\SCons\Test-WinSkip>type test-env.bat
@setlocal
@python -c "import os; print([os.environ.get(var) for var in ['SystemDrive', 'SystemRoot', 'windir']])"
@set SystemDrive=
@set SystemRoot=
@set windir=
@python -c "import os; print([os.environ.get(var) for var in ['SystemDrive', 'SystemRoot', 'windir']])"
@endlocal
(3.12.9) S:\SCons\Test-WinSkip>test-env
['C:', 'C:\\Windows', 'C:\\Windows']
[None, None, None]
|
|
||
| xz_path = os.path.dirname(xz) | ||
| # Windows 10 and later supplies windows/system32/tar.exe (bsdtar). | ||
| # Not all versions support xz compression. Check the version string |
There was a problem hiding this comment.
Probable makes sense to move this logic into TestSCons?
There was a problem hiding this comment.
After copy/pasting/modifying from the xz source code it seemed like it would be a good idea to have only one parameterized implementation.
Wasn't sure where or what name to use.
There was a problem hiding this comment.
Updated to move common windows system tar code in bz2 and xz scripts to a private common module in the packaging/tar folder.
It should be easier now to move somewhere else if desired. At present, only used in two places.
There was a problem hiding this comment.
Well that didn't work as I had hoped. The source file test/packaging/tar/_windows_tar.py was "run" as a test (which passes) which is undesirable.
Seems unfortunate to have to add to TestSCons for two tests.
There was a problem hiding this comment.
You can exclude _windows_tar.py , see: https://github.com/SCons/scons/wiki/DevGuide-TestingMethodology#selecting-tests
…tSConsTar.py and simplify packaging tar tests.
|
Good enough. Merging. |
|
@bdbaddog Did you see the last commit about a minute before the merge? |
The TestSConsTar.py.. Yes. At this point, enough CPU cycles spent for this issue. Seems good enough and merged. |
Rework the windows system tar executable handling in the packaging tar tests for bz2 and xz. Remove test
test/packaging/tar/xz_packaging.pyfrom the windows runner skip file.Changes:
test/packaging/tar/bz2_packaging.py:bzip2.exeto the environment path for windows.test/packaging/tar/xz_packaging.py:xz.exeto the environment path for windows.test/packaging/tar/xz_packaging.pyfrom the windows ci test skip file.As of 06-Jul-2025:
Contributor Checklist:
CHANGES.txtandRELEASE.txt(and read theREADME.rst).