mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 19:58:36 +00:00
test_tool_stdout_encoding: run the programs with -X utf8=0
Python 3.15 turns UTF-8 mode on by default, even under -I, so there a redirected stdout is UTF-8 and the subprocess cases pass with or without the guard. -X utf8=0 keeps the code page they are about (review of #2399 by nonverifiedperson). On 3.12 the flag changes nothing: 4 OK with the guard, 2 failures with viewer/serve.py's taken out. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs
This commit is contained in:
@ -26,6 +26,9 @@ NOT_YET_GUARDED = {
|
||||
"scripts/run_wine_tests.py", # open Wine runner pull requests change this file
|
||||
}
|
||||
MARK = ""
|
||||
# Python 3.15 turns UTF-8 mode on by default, even under -I, and then a redirected stdout cannot fail this way.
|
||||
# -X utf8=0 keeps the code page these tests are about, so they still catch a missing guard there.
|
||||
PYTHON = [sys.executable, "-I", "-X", "utf8=0"]
|
||||
|
||||
|
||||
class EveryToolGuardsStdout(unittest.TestCase):
|
||||
@ -61,7 +64,7 @@ class MeasuredCrashes(unittest.TestCase):
|
||||
for tool, with_out in self.CASES:
|
||||
with self.subTest(tool=tool):
|
||||
argv = [src] + (["--out", out] if with_out else [])
|
||||
r = subprocess.run([sys.executable, "-I", os.path.join(TOOLS, tool)] + argv,
|
||||
r = subprocess.run(PYTHON + [os.path.join(TOOLS, tool)] + argv,
|
||||
capture_output=True, cwd=ROOT, timeout=300)
|
||||
err = r.stderr.decode("utf-8", "replace")
|
||||
self.assertNotIn("UnicodeEncodeError", err)
|
||||
@ -75,8 +78,9 @@ class ScriptsAndViewer(unittest.TestCase):
|
||||
disasm = os.path.join(tmp, "disasm-" + MARK)
|
||||
os.makedirs(disasm)
|
||||
report = os.path.join(tmp, "rep-" + MARK + ".json")
|
||||
r = subprocess.run([sys.executable, "-I", os.path.join(ROOT, "scripts", "audit_shader4_regs.py"),
|
||||
disasm, "--json", report], capture_output=True, cwd=ROOT, timeout=300)
|
||||
audit = os.path.join(ROOT, "scripts", "audit_shader4_regs.py")
|
||||
r = subprocess.run(PYTHON + [audit, disasm, "--json", report],
|
||||
capture_output=True, cwd=ROOT, timeout=300)
|
||||
err = r.stderr.decode("utf-8", "replace")
|
||||
self.assertNotIn("Traceback", err)
|
||||
self.assertEqual(r.returncode, 0, err)
|
||||
@ -87,8 +91,8 @@ class ScriptsAndViewer(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
world = os.path.join(tmp, "world-" + MARK)
|
||||
os.makedirs(world)
|
||||
proc = subprocess.Popen([sys.executable, "-I", os.path.join(ROOT, "viewer", "serve.py"),
|
||||
"--world", world, "--port", "0"],
|
||||
serve = os.path.join(ROOT, "viewer", "serve.py")
|
||||
proc = subprocess.Popen(PYTHON + [serve, "--world", world, "--port", "0"],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=ROOT)
|
||||
try:
|
||||
line = proc.stdout.readline() # the viewer prints this line once it is listening
|
||||
|
||||
Reference in New Issue
Block a user