Files
Triforce-Source/tests/test_prepare_cache_save.py
ruckus7382sfgsgdf 4fa4f9188b 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.
2026-11-25 10:21:32 -06:00

32 lines
1.7 KiB
Python

"""Execute the actual prepare-only completion branch with game-free call stubs."""
import argparse, subprocess, tempfile
from pathlib import Path
p=argparse.ArgumentParser();p.add_argument('--source',type=Path,default=Path(__file__).resolve().parents[1]);p.add_argument('--cxx',default='clang++');a=p.parse_args()
s=(a.source/'gpu/vk/vk_main.cpp').read_text();start=s.index('if (prepare_only()) {');at=s.index('{',start)+1;end=at;depth=1
while depth:
depth+=(s[end]=='{')-(s[end]=='}');end+=1
body=s[at:end-1]
cpp=r"""
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
using std::size_t;
std::vector<int> calls;
bool prepare_run(void(*)(size_t,size_t),bool background=false){if(background)std::exit(3);calls.push_back(1);return true;}
void predict_run(void(*)(size_t,size_t)){calls.push_back(5);}
void precompile_run(void(*)(size_t,size_t)){calls.push_back(2);}
void pipeline_cache_save(bool force){if(!force)std::exit(2);calls.push_back(3);}
std::string skipped_path(){return "sentinel";}
void fsr4_prepare_shaders(){}
int fake_remove(const char*){calls.push_back(4);return 0;}
#define remove fake_remove
bool run(){
"""+body+r"""
}
int main(){if(!run()||calls!=std::vector<int>{1,5,2,3,4}){std::fputs("FAIL: preparation must synchronously force cache save before clearing skipped marker\n",stderr);return 1;}std::puts("PASS: actual preparation branch forces save after precompile before marker cleanup");}
"""
with tempfile.TemporaryDirectory(prefix='prepare-cache-') as tmp:
src=Path(tmp)/'fixture.cpp';exe=Path(tmp)/'fixture.exe';src.write_text(cpp)
subprocess.run([a.cxx,'-std=c++20',str(src),'-o',str(exe)],check=True);subprocess.run([str(exe)],check=True)