mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1935] 8 tests in tools/test_setup_*.py depend on the host: unmocked HEAD to GitHub (2) and unmocked /proc/cpuinfo read (6) #767
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#767
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gputier on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1935
Context
On v0.1.42 (
61b3fb5d),pytest tools/test_setup_amd.py tools/test_setup_choices.py tools/test_setup_engine_hash.pyin a cleanpython:3.12-slimcontainer (pip install -r requirements.txt pytest jsonschema) gives 8 failed, 107 passed, with or without network. On a Windows machine with internet, the same tests are green. They lean on the host: theWINbranch ofcpu_info()never reads/proc/cpuinfo, and the published release only ships the Windows asset. Same family as #414 (host state leaking intotest_setup_choices).I checked this by replacing
setup.cpu_info(6 tests) andurllib.request.urlopen(2 tests) in a container with no network. All 8 turn green, so nothing else is missing (cmake and ninja come from requirements.txt, and the tests already mockcmake_buildandinstall_build_tools).The 2 tests that call the real network
tools/test_setup_engine_hash.py:309WhatARefusalDoesToTheCaller::test_updating_keeps_the_installed_engine_instead_of_stopping(fails at:316)tools/test_setup_engine_hash.py:325WhatARefusalDoesToTheCaller::test_a_first_install_stops_because_there_is_nothing_to_fall_back_to(SystemExitnot raised at:327)Cause: the tests mock
downloadandengine_digest, butget_prebuilt()first sends a realHEAD(setup.py:2997,urllib.request.urlopen(req, timeout=60)) toreleases/download/v<version>/, thenreleases/latest/download/. On any non-Windows host the asset isstrata-linux-x64.zip(setup.py:180), which no release publishes (404). Offline, it is a DNS error. Either way,setup.py:3003returnsNone("compiling instead") beforedownloadis reached, so the path under test (verify_engine_archive,engine_refused) never runs.Proposed fix: patch
urllib.request.urlopenin the test helper (:304) and in the:325test, for examplemock.patch.object(setup.urllib.request, "urlopen", return_value=mock.MagicMock()), next to the existing patches ofdownloadandengine_digest.The 6 that read the real /proc/cpuinfo
tools/test_setup_amd.py:156GpuLists::test_build_for_every_archtools/test_setup_choices.py:354HipVision::test_the_cpu_encoder_is_built_oncetools/test_setup_choices.py:365HipVision::test_without_images_nothing_changestools/test_setup_choices.py:527CudaVision::test_the_encoder_is_built_native(gpu and cpu subtests)tools/test_setup_choices.py:588HostCompilers::test_the_defs_reach_cmakeCause:
build_engine()(setup.py:3401) andbuild_engine_hip()(setup.py:2643) callcpu_floor(cpu_info()[1]), and none of these tests mockcpu_info. On Linux,cpu_info()runsre.search(r"^flags\s*:\s*(.*)$", txt, re.M).group(1)(setup.py:720). On aarch64, the file has aFeaturesline instead offlags, and some x86 containers under emulation have neither.re.searchthen returnsNone, and theAttributeErroris not caught: thetryonly catchesOSError(setup.py:725). Result:AttributeError: 'NoneType' object has no attribute 'group'.Proposed fix, two parts:
mock.patch.object(setup, "cpu_info", lambda: ("test CPU", True, False))in the shared setup of these classes, so the result does not depend on the machine.cpu_info()survive a/proc/cpuinfowithoutflags(catchAttributeErrortoo, or readFeatureson ARM). As it is,setup.pyraises on any Linux ARM host, which is not just a test problem.@gputier commented on GitHub (Oct 17, 2026):
Still present on v0.1.45: the same 8 tests fail.
git archive v0.1.45 | docker run -i python:3.12-slim(aarch64, Python 3.12.15),pip install -r requirements.txt pytest jsonschema, thenpytest tools/test_setup_amd.py tools/test_setup_choices.py tools/test_setup_engine_hash.py:(114 passed instead of 107 on v0.1.42: tests were added; the failing 8 are the same.)
Same two causes, new line numbers:
/proc/cpuinfo(6 tests):cpu_info()still doesre.search(r"^flags\s*:\s*(.*)$", txt, re.M).group(1)atsetup.py:883and only catchesOSError(setup.py:888). On aarch64:AttributeError: 'NoneType' object has no attribute 'group'atsetup.py:883. Callers:build_engine_hip()atsetup.py:3084andbuild_engine()atsetup.py:4046(cpu_floor(cpu_info()[1])). None of the three test files patchescpu_info(0 occurrences in v0.1.42 and in v0.1.45). The product side is unchanged too:setup.pystill raises on a Linux ARM host.HEADto GitHub (2 tests):get_prebuilt()still sendsurllib.request.urlopen(req, timeout=60)atsetup.py:3624-3625beforedownload, and returnsNoneatsetup.py:3631. The asset is stillstrata-linux-x64.zipoff Windows (setup.py:181). Captured stdout:no ready-made engine at https://github.com/Niko1221/Strata/releases/latest/download/ (HTTP Error 404: Not Found): compiling instead. The helper attools/test_setup_engine_hash.py:304and the test at:325still patch onlydownloadandengine_digest.The proposed fix in the issue still applies as written.
@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.