mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-06 06:52:20 +02:00
fix(tests): resolve temp paths consistently on macOS
Three of the six recorded failures were the same test bug: an unresolved /tmp path compared against a resolved /private/tmp one. macOS makes /tmp a symlink, so a fixture built with tempfile.mkdtemp(dir="/tmp") and a code path that resolves what it reports disagree about a file both found correctly. test_code_nav_tools builds its fixture unresolved and compares it against the reported path. One realpath fixes both of its failures. test_glob_confined_e2e is the same cause through a longer route: it mixed os.path.realpath(ws) with an unresolved secret directory, so relpath emitted "../../../../tmp/<absolute path>" and the assertion that the absolute path was absent from the output matched it as a substring. Resolving the secret directory puts both sides in one tree and the relative path stays short. macOS full suite goes from 6 failures to 3. The remaining three are an ffmpeg build without a WebP encoder, a socket test that needs a fast connection refusal, and the rich-text colour test that is still unexplained. The ledger is updated in the same change so it does not describe failures that no longer happen.
This commit is contained in:
@@ -17,7 +17,10 @@ def _run(tool, content):
|
||||
@pytest.fixture
|
||||
def repo():
|
||||
# Built under /tmp, which is on the default tool-path allowlist.
|
||||
root = tempfile.mkdtemp(dir="/tmp", prefix="codenav_")
|
||||
# realpath because the code under test resolves the path it reports, and on
|
||||
# macOS /tmp is a symlink to /private/tmp: comparing the unresolved path
|
||||
# against the resolved one fails on a file both sides found correctly.
|
||||
root = os.path.realpath(tempfile.mkdtemp(dir="/tmp", prefix="codenav_"))
|
||||
try:
|
||||
with open(os.path.join(root, "a.py"), "w") as f:
|
||||
f.write("import os\n# needle here\nprint('x')\n")
|
||||
|
||||
Reference in New Issue
Block a user