Files
mandy/tests/test_cfg_run_limit.py
ItsNotRexed 4c52ce27a6 Seven fixes from an outside contributor (sent as patches, applied without the author's name)
- rdna2spirv: declare each packed vertex input register once; a register whose elements disagree on the component
  type is refused (SHADER-644).
- runtime: a title's VirtualAlloc drops the console's MEM_GRAPHICS / MEM_TITLE type bits the host rejects (RT-217).
- runtime: XPersistentLocalStorageImpl is served from <overlay>\persistent with the package's 2048 MB quota
  (RT-219; layout from the public docs, not measured in a caller).
- runtime: G:\ names the package and T:\ a scratch folder in the overlay; paths under the configured folders and
  every path with no folders configured stay host paths (RT-218).
- winhttp_offline: header blocks and timeouts the host WinHTTP rejects are rejected the same way.
- cfg_structure.run: a limit of zero or less runs no blocks.
- shader_meta: an s_movk_i32 with a register operand and a float immediate beyond float32 are left unknown instead
  of raising.

Each comes with a test that fails on the old code. Conflicts with main resolved here (internal_dir() hides T:'s
folder; both file_system_test blocks kept).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:55:46 -05:00

42 lines
1.4 KiB
Python

"""tools/cfg_structure.run stops after `limit` blocks, and a limit of zero or less runs none (standard library only).
python -I tests/test_cfg_run_limit.py
"""
import os
import sys
import unittest
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(ROOT, "tools"))
import cfg_structure # noqa: E402
def straight_line(n):
"""A tree of n blocks, 0..n-1, where each block goes to the next one."""
return [("block", i) for i in range(n)], lambda b: b + 1
class RunLimitTest(unittest.TestCase):
def test_runs_everything_under_the_limit(self):
tree, choose = straight_line(3)
self.assertEqual(cfg_structure.run(tree, choose, 10), [0, 1, 2])
def test_stops_after_limit_blocks(self):
tree, choose = straight_line(5)
self.assertEqual(cfg_structure.run(tree, choose, 2), [0, 1])
self.assertEqual(cfg_structure.run(tree, choose, 1), [0])
def test_limit_equal_to_the_length_runs_everything(self):
tree, choose = straight_line(3)
self.assertEqual(cfg_structure.run(tree, choose, 3), [0, 1, 2])
def test_zero_or_negative_limit_runs_nothing(self):
tree, choose = straight_line(3)
self.assertEqual(cfg_structure.run(tree, choose, 0), [])
self.assertEqual(cfg_structure.run(tree, choose, -4), [])
if __name__ == "__main__":
unittest.main()