mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-25 18:48:51 -04:00
Triforce v0.8.0
Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
This commit is contained in:
77
tests/test_kept_depfiles.py
Normal file
77
tests/test_kept_depfiles.py
Normal file
@@ -0,0 +1,77 @@
|
||||
"""The renderer's and the runtime's depfiles kept beside the object cache (nx2/build.py kept_depfile, keep_depfile): a player's
|
||||
build lets the build folder go once the game folder is ready, and the object cache keeps only the depfile keys the last build's
|
||||
stamps name. Without a kept depfile the next update named those objects by the folders' blob, which the cache no longer held, and
|
||||
compiled them all again. Game-free.
|
||||
|
||||
python -I -B tests/test_kept_depfiles.py
|
||||
"""
|
||||
import importlib.util
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
|
||||
def esc(p):
|
||||
"""a path as clang's depfile writes it: a space escaped"""
|
||||
return str(p).replace(" ", chr(92) + " ")
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path[:0] = [str(ROOT / "nx2"), str(ROOT / "third_party" / "a64-kit" / "tools")]
|
||||
spec = importlib.util.spec_from_file_location("build_kept_depfiles", ROOT / "nx2" / "build.py")
|
||||
build = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(build)
|
||||
|
||||
|
||||
class KeptDepfiles(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temporary = tempfile.TemporaryDirectory(prefix="triforce kept depfiles ")
|
||||
self.addCleanup(self.temporary.cleanup)
|
||||
d = Path(self.temporary.name)
|
||||
self.vk, self.obj_dir, self.cache = d / "gpu" / "vk", d / "sa" / "build" / "obj", d / "objcache"
|
||||
for p in (self.vk, self.obj_dir):
|
||||
p.mkdir(parents=True)
|
||||
(self.vk / "a.h").write_bytes(b"int a;\n")
|
||||
(self.vk / "b.h").write_bytes(b"int b;\n")
|
||||
self.obj = str(self.obj_dir / "vk_x.o")
|
||||
Path(build.depfile_of(self.obj)).write_text("%s: %s %s\n" % (esc(self.obj), esc(self.vk / "x.cpp"), esc(self.vk / "a.h")),
|
||||
encoding="utf-8")
|
||||
patch = mock.patch.object(build, "OBJ_CACHE", str(self.cache))
|
||||
patch.start()
|
||||
self.addCleanup(patch.stop)
|
||||
build._HEADER_DIGESTS.clear()
|
||||
|
||||
def test_the_kept_copy_names_the_object_when_the_build_folder_is_gone(self):
|
||||
key = build.renderer_deps(b"blob", (str(self.vk),), self.obj)
|
||||
self.assertTrue(key.startswith(build.DEPFILE_DEPS))
|
||||
build.keep_depfile(self.obj)
|
||||
self.assertTrue(os.path.isfile(build.kept_depfile(self.obj)))
|
||||
os.remove(build.depfile_of(self.obj)) # (the clean-up after a player's build)
|
||||
self.assertEqual(build.renderer_deps(b"blob", (str(self.vk),), self.obj), key)
|
||||
|
||||
def test_no_depfile_anywhere_is_the_blob(self):
|
||||
os.remove(build.depfile_of(self.obj))
|
||||
self.assertEqual(build.renderer_deps(b"blob", (str(self.vk),), self.obj), b"blob")
|
||||
|
||||
def test_the_one_beside_the_object_comes_first(self):
|
||||
build.keep_depfile(self.obj)
|
||||
Path(build.depfile_of(self.obj)).write_text("%s: %s %s\n" % (esc(self.obj), esc(self.vk / "x.cpp"), esc(self.vk / "b.h")),
|
||||
encoding="utf-8")
|
||||
build._HEADER_DIGESTS.clear()
|
||||
(self.vk / "a.h").write_bytes(b"int a2;\n") # (read by the kept copy alone: no change to the key)
|
||||
first = build.renderer_deps(b"blob", (str(self.vk),), self.obj)
|
||||
build._HEADER_DIGESTS.clear()
|
||||
(self.vk / "b.h").write_bytes(b"int b2;\n")
|
||||
self.assertNotEqual(build.renderer_deps(b"blob", (str(self.vk),), self.obj), first)
|
||||
|
||||
def test_rekey_keeps_it(self):
|
||||
src = (ROOT / "nx2" / "build.py").read_text(encoding="utf-8")
|
||||
rekey = src[src.index("\ndef rekey_depfiles("):src.index("\ndef keep_depfile(")]
|
||||
self.assertIn("keep_depfile(obj)", rekey)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(unittest.main(verbosity=1))
|
||||
Reference in New Issue
Block a user