upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/test_first_light_harness_paths.py
diff options
context:
space:
mode:
authorYash Dubey <yash.dubey803at@gmail.com>2026-11-24 07:35:50 +0530
committerYash Dubey <yash.dubey803at@gmail.com>2026-11-24 07:35:50 +0530
commitdfd239266fd62e1fbbfcf264e9bb4e5c8e8dc801 (patch)
tree0fb3fbb22dda6a8b3af3b30b0fc3bcc1a23480f6 /tests/test_first_light_harness_paths.py
parent9ec34cdff41b19d7671bc260e5f40dc69790d905 (diff)
make_game, first_light: a vk_pipeline_check or vk_harness older than its sources is rebuilt or reported, not reused silently
Diffstat (limited to 'tests/test_first_light_harness_paths.py')
-rw-r--r--tests/test_first_light_harness_paths.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test_first_light_harness_paths.py b/tests/test_first_light_harness_paths.py
index 58ab34800..438dce472 100644
--- a/tests/test_first_light_harness_paths.py
+++ b/tests/test_first_light_harness_paths.py
@@ -1,5 +1,7 @@
1"""CPU-only checks for the first-light harness lookup.""" 1"""CPU-only checks for the first-light harness lookup."""
2 2
3import contextlib
4import io
3import os 5import os
4from pathlib import Path 6from pathlib import Path
5import sys 7import sys
@@ -49,6 +51,50 @@ class FirstLightHarnessPathsTests(unittest.TestCase):
49 environment.unlink() 51 environment.unlink()
50 self.assertEqual(first_light.find_harness(None), str(configured)) 52 self.assertEqual(first_light.find_harness(None), str(configured))
51 53
54 def put_sources(self) -> Path:
55 test = self.root / "runtime" / "test"
56 test.mkdir(parents=True, exist_ok=True)
57 (test / "vk_harness.cpp").write_text('#include "../src/table.h"\n', encoding="utf-8")
58 (self.root / "runtime" / "src").mkdir(exist_ok=True)
59 (self.root / "runtime" / "src" / "table.h").write_text("", encoding="utf-8")
60 return test
61
62 def find_with_stderr(self) -> tuple[str, str]:
63 err = io.StringIO()
64 with contextlib.redirect_stderr(err):
65 found = first_light.find_harness(None)
66 return found, err.getvalue()
67
68 def test_a_harness_older_than_its_sources_is_reported(self) -> None:
69 # Old #7148: a harness built before a pull drew with the old program and said nothing.
70 harness = self.put_harness("runtime", "build", "linux")
71 self.put_sources()
72 os.utime(harness, (1_000_000, 1_000_000))
73 found, err = self.find_with_stderr()
74 self.assertEqual(found, str(harness))
75 self.assertIn("WARNING", err)
76 self.assertIn("runtime/test/vk_harness.cpp", err)
77 self.assertIn("runtime/src/table.h", err)
78 self.assertIn("--target vk_harness", err)
79
80 def test_a_current_harness_is_used_quietly(self) -> None:
81 self.put_sources()
82 harness = self.put_harness("runtime", "build", "linux")
83 future = os.path.getmtime(self.root / "runtime" / "src" / "table.h") + 60
84 os.utime(harness, (future, future))
85 found, err = self.find_with_stderr()
86 self.assertEqual(found, str(harness))
87 self.assertEqual(err, "")
88
89 def test_a_harness_outside_the_build_folder_is_not_compared(self) -> None:
90 self.put_sources()
91 explicit = self.put_harness("explicit")
92 os.utime(explicit, (1_000_000, 1_000_000))
93 err = io.StringIO()
94 with contextlib.redirect_stderr(err):
95 self.assertEqual(first_light.find_harness(str(explicit)), str(explicit))
96 self.assertEqual(err.getvalue(), "")
97
52 98
53if __name__ == "__main__": 99if __name__ == "__main__":
54 unittest.main() 100 unittest.main()