Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree (570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base = the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main). Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details, conflict table and left-out files are in docs/upstream.md. Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61), docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out. scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run"). Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR macros on. No GPU run, no quality gate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
114 lines
6.0 KiB
Python
114 lines
6.0 KiB
Python
r"""The Windows installer must never touch the user's data. The app lives in %LOCALAPPDATA%\Programs\Strata; %LOCALAPPDATA%\Strata
|
|
holds engines, model run configs, tuning. A build that installed the app into the data folder is migrated by removing only its app
|
|
files. Exercised with makensis on a temp layout (the template's own migration macro, extracted and run); skipped without NSIS."""
|
|
|
|
import os
|
|
import re
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
TEMPLATE = ROOT / "apps" / "desktop" / "src-tauri" / "nsis" / "installer.nsi"
|
|
MAKENSIS = Path(os.environ.get("LOCALAPPDATA", "")) / "tauri" / "NSIS" / "makensis.exe"
|
|
DATA = ["components/engine/0.1.45/strata.exe", "install/strata-iq3_s.json", "procs/p.json", "runtime/r.json", "time-skip/t.json",
|
|
"presets/p.json"]
|
|
APP = ["strata-desktop.exe", "uninstall.exe", "host/server/index.mjs", "node/node.exe", "control/python/python.exe"]
|
|
BS = "\\"
|
|
|
|
|
|
def touch(base: Path, names):
|
|
for name in names:
|
|
path = base / name
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text("x", encoding="utf-8")
|
|
|
|
|
|
class TemplateTests(unittest.TestCase):
|
|
text = TEMPLATE.read_text(encoding="utf-8")
|
|
|
|
def test_the_default_folder_is_programs_strata_and_the_data_folder_is_never_remembered_as_the_app(self):
|
|
self.assertIn(r'StrCpy $INSTDIR "$LOCALAPPDATA\Programs\${PRODUCTNAME}"', self.text)
|
|
self.assertIn(r'StrCmp $4 "$LOCALAPPDATA\${PRODUCTNAME}" restore_done 0', self.text)
|
|
self.assertIn("StrIsUnder", self.text) # a remembered folder under Temp is ignored too
|
|
|
|
def test_the_install_folder_page_is_shown_except_in_an_update(self):
|
|
# #3186 #3190: the person can put the app on another drive; the app's own updater (passive) and silent installs keep the folder
|
|
# the earlier install wrote to the registry, so an update never asks again and never moves the app
|
|
text = self.text.replace("\r\n", "\n")
|
|
match = re.search(r"!define MUI_PAGE_CUSTOMFUNCTION_PRE (\w+)\n!insertmacro MUI_PAGE_DIRECTORY", text)
|
|
self.assertIsNotNone(match)
|
|
self.assertEqual(match.group(1), "SkipIfPassive")
|
|
self.assertIn('WriteRegStr SHCTX "${MANUPRODUCTKEY}" "" $INSTDIR', text)
|
|
self.assertIn("Call RestorePreviousInstallLocation", text)
|
|
conf = (ROOT / "apps" / "desktop" / "src-tauri" / "tauri.conf.json").read_text(encoding="utf-8")
|
|
self.assertIn('"installMode": "currentUser"', conf)
|
|
|
|
def test_the_uninstaller_removes_files_one_by_one_and_only_empty_folders(self):
|
|
uninstall = self.text[self.text.index("Section Uninstall"):]
|
|
self.assertNotRegex(uninstall, r'RMDir /r "\$INSTDIR"')
|
|
self.assertNotIn(r'RmDir /r "$LOCALAPPDATA\${PRODUCTNAME}"', self.text)
|
|
self.assertIn(r'RmDir /r "$LOCALAPPDATA\${BUNDLEID}"', self.text)
|
|
|
|
|
|
@unittest.skipUnless(MAKENSIS.is_file(), "NSIS (the Tauri bundler's copy) is not installed here")
|
|
class MigrationTests(unittest.TestCase):
|
|
def run_nsis(self, body: str, work: Path):
|
|
block = re.search(r"; STRATA-MIGRATE-BEGIN.*?; STRATA-MIGRATE-END", TEMPLATE.read_text(encoding="utf-8"), re.S).group(0)
|
|
script = work / "t.nsi"
|
|
script.write_text('Unicode true\nOutFile "t.exe"\nRequestExecutionLevel user\nSilentInstall silent\n' + block + "\nSection\n" + body + "\nSectionEnd\n", encoding="utf-8")
|
|
done = subprocess.run([str(MAKENSIS), "/V1", str(script)], cwd=work, capture_output=True, text=True)
|
|
self.assertEqual(done.returncode, 0, done.stdout + done.stderr)
|
|
subprocess.run([str(work / "t.exe")], cwd=work, check=True, timeout=60)
|
|
|
|
def layout(self, base: Path) -> Path:
|
|
old = base / "Strata"
|
|
touch(old, DATA + APP)
|
|
return old
|
|
|
|
def test_migration_removes_only_the_old_app_files_and_keeps_every_bit_of_data(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
base = Path(tmp)
|
|
old = self.layout(base)
|
|
new = base / "Programs" / "Strata"
|
|
self.run_nsis(f'!insertmacro StrataMigrateOldInstall "{old}" "{new}"', base)
|
|
for name in DATA:
|
|
self.assertTrue((old / name).is_file(), f"data kept: {name}")
|
|
for name in APP:
|
|
self.assertFalse((old / name).exists(), f"app file removed: {name}")
|
|
for folder in ("host", "node", "control"):
|
|
self.assertFalse((old / folder).exists())
|
|
|
|
def test_migration_does_nothing_when_old_and_new_are_the_same_or_there_is_no_old_app(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
base = Path(tmp)
|
|
old = self.layout(base)
|
|
self.run_nsis(f'!insertmacro StrataMigrateOldInstall "{old}" "{old}"', base)
|
|
for name in DATA + APP:
|
|
self.assertTrue((old / name).is_file(), name)
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
base = Path(tmp)
|
|
touch(base / "Strata", DATA) # data only: no strata-desktop.exe
|
|
self.run_nsis(f'!insertmacro StrataMigrateOldInstall "{base / "Strata"}" "{base / "Programs" / "Strata"}"', base)
|
|
for name in DATA:
|
|
self.assertTrue((base / "Strata" / name).is_file(), name)
|
|
|
|
def test_an_uninstall_of_the_template_kind_leaves_data_in_a_shared_folder(self):
|
|
"""The uninstaller deletes named files and uses non-recursive RMDir: in a folder that also holds data (a legacy install) the
|
|
data and so the folder stay."""
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
base = Path(tmp)
|
|
old = self.layout(base)
|
|
lines = [f'Delete "{old}{BS}{n.replace("/", BS)}"' for n in APP]
|
|
lines += [f'RMDir "{old}{BS}{d}"' for d in ("host" + BS + "server", "host", "node", "control" + BS + "python", "control")]
|
|
lines += [f'RMDir "{old}"']
|
|
self.run_nsis("\n".join(lines), base)
|
|
for name in DATA:
|
|
self.assertTrue((old / name).is_file(), name)
|
|
self.assertFalse((old / "strata-desktop.exe").exists())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|