mirror of
https://github.com/razzant/ouroboros.git
synced 2026-10-03 04:07:04 +00:00
test: bind Windows utility and patch byte fixtures
Select the intended PATH-resolved sort/find executables and make the byte-identity patch fixture independent of receiver newline conversion.
This commit is contained in:
parent
c306b40d88
commit
6b3d9147f5
3 changed files with 15 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||
import os
|
||||
import pathlib
|
||||
import shlex
|
||||
import shutil
|
||||
import sys
|
||||
import tarfile
|
||||
|
||||
|
|
@ -58,6 +59,11 @@ def test_light_direct_target_matches_resource_authority(resources, monkeypatch,
|
|||
"rm": ["rm", str(target)], "sort": ["sort", "-o", str(target), str(source)],
|
||||
"redirect": ["sh", "-c", f"printf x > {shlex.quote(str(target))}"],
|
||||
}
|
||||
if utility == "sort":
|
||||
# Windows searches System32 before PATH for a bare executable name.
|
||||
executable = shutil.which("sort")
|
||||
assert executable is not None
|
||||
commands[utility][0] = executable
|
||||
result = registry.execute_result("run_command", {"cmd": commands[utility], "cwd": str(workspace),
|
||||
"outputs": [str(target)] if utility != "rm" else []})
|
||||
if destination == "desktop":
|
||||
|
|
|
|||
|
|
@ -152,7 +152,9 @@ def test_workspace_patch_keeps_log_manifest_and_token_report(files, tmp_path):
|
|||
patch = (output / "workspace.patch").read_text()
|
||||
restored = tmp_path / "restored"
|
||||
restored.mkdir()
|
||||
subprocess.run(["git", "apply", str(output / "workspace.patch")], cwd=restored, check=True, capture_output=True)
|
||||
# Assert captured bytes independently of the receiver's newline preference.
|
||||
subprocess.run(["git", "-c", "core.autocrlf=false", "apply", str(output / "workspace.patch")],
|
||||
cwd=restored, check=True, capture_output=True)
|
||||
for name, content in payloads.items():
|
||||
assert f"b/{name}" in patch and content.strip() in patch
|
||||
assert (restored / name).read_bytes() == (work / name).read_bytes() == content.encode()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||
import os
|
||||
import pathlib
|
||||
import shlex
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
|
@ -55,6 +56,11 @@ def protected(tmp_path, monkeypatch):
|
|||
def test_search_patterns_and_programs_do_not_become_file_targets(protected, cmd):
|
||||
registry, _ctx, reference, _workspace = protected
|
||||
original = reference.read_bytes()
|
||||
if cmd[0] == "find":
|
||||
# Bind the PATH-selected utility instead of Windows' System32 FIND.
|
||||
executable = shutil.which("find")
|
||||
assert executable is not None
|
||||
cmd = [executable, *cmd[1:]]
|
||||
result = registry.execute_result("run_command", {"cmd": cmd})
|
||||
assert result.status == "ok", result.text
|
||||
assert reference.read_bytes() == original
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue