okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Version 0.2.15 / Control 0.1.61: app and Terminal 0.2.15, Control 0.1.61; every engine package stays 0.1.60 (the v0.2.14 files, carried by absolute url)e39a52e33

main
4.4 KiB85 linesraw
1"""The release manifest (docs/data/release.json) and the pages that quote it."""
2import copy
3import os
4import sys
5import unittest
6
7sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
8import release_manifest as rm  # noqa: E402
9
10
11class ReleaseManifest(unittest.TestCase):
12    def test_current_pages_agree_with_the_manifest(self):
13        problems = rm.check(rm.load())
14        self.assertEqual(problems, [], "\n".join(problems))
15
16    def test_old_installer_names_are_found_and_rewritten(self):
17        m = rm.load()
18        old = "run `Strata-0.2.9-windows-x64-setup.exe` or Strata-0.2.9-linux-x86_64.AppImage.sig"
19        self.assertEqual(len(rm.INSTALLER_RE.findall(old)), 2)
20        fixed = rm.INSTALLER_RE.sub(lambda x: x.group(0).replace(x.group(1), m["product_version"], 1), old)
21        self.assertNotIn("0.2.9", fixed)
22        self.assertIn("Strata-%s-linux-x86_64.AppImage.sig" % m["product_version"], fixed)
23
24    def test_version_lines_are_rewritten_and_a_second_pass_changes_nothing(self):
25        m = rm.load()
26        page, regex, keys = [r for r in rm.LINES if r[0] == "AGENTS.md"][0]
27        text = "Version 0.2.5, engine 0.1.50. The public model families"
28        once = rm.rewrite(text, regex, keys, m)
29        self.assertEqual(once, "Version %s, engine %s. The public model families" % (m["product_version"], m["engine_version"]))
30        self.assertEqual(rm.rewrite(once, regex, keys, m), once)
31
32    def test_a_drifting_manifest_is_reported(self):
33        m = copy.deepcopy(rm.load())
34        m["product_version"] = "0.2.99"
35        m["tag"] = "v0.2.99"
36        m.pop("terminal_version", None)                             # the Terminal then has to say the product version
37        problems = "\n".join(rm.check(m))
38        self.assertIn("strata_cli/__init__.py says", problems)
39        self.assertIn("asset list has no Strata-0.2.99-windows-x64-setup.exe", problems)
40
41    def test_a_control_only_hotfix_is_allowed_and_a_drifting_control_is_not(self):
42        """0.2.13.1: the Terminal and Control are one hotfix part ahead of the app and the engines; nothing else may differ.
43        Written so it holds for a release with a hotfix part (0.2.13.1) and without one (0.2.14)."""
44        m = rm.load()
45        self.assertEqual(rm.check(m), [])
46        wrong = copy.deepcopy(m)
47        wrong["control_version"] = m["engine_version"] + ".9"       # the manifest names a Control hotfix the source does not have
48        problems = "\n".join(rm.check(wrong))
49        self.assertIn("CMakeLists.txt (Control) says", problems)
50        wrong = copy.deepcopy(m)
51        wrong["engine_version"] = "0.1.58"                          # engines two builds behind Control: not a hotfix
52        self.assertIn("CMakeLists.txt (engine) says", "\n".join(rm.check(wrong)))
53        wrong = copy.deepcopy(m)
54        wrong["terminal_version"] = m["product_version"] + ".9"     # the manifest names a Terminal the source does not say
55        terminal = rm.code_versions()["strata_cli/__init__.py"][0]
56        self.assertIn("strata_cli/__init__.py says %s" % terminal, "\n".join(rm.check(wrong)))
57
58    def test_a_release_that_carries_its_engines_names_where_they_come_from(self):
59        """0.2.15: Control 0.1.61 and the 0.1.60 engines of v0.2.14 (no engine built). Without "engines_from" Control may not be ahead of
60        the engines; with it, the engines at engine_version must be packages the release offers."""
61        m = copy.deepcopy(rm.load())
62        m["engines_from"] = "v0.2.14"
63        m["control_version"], m["engine_version"] = "0.1.61", "0.1.60"
64        cmake = {"CMakeLists.txt (engine)": ("0.1.61", "engine_version"), "CMakeLists.txt (Control)": ("0.1.61", "control_version")}
65        real = rm.code_versions
66        try:
67            rm.code_versions = lambda: {**real(), **cmake}
68            self.assertNotIn("CMakeLists.txt (engine) says", "\n".join(rm.check(m)))
69            no_from = copy.deepcopy(m)
70            no_from.pop("engines_from")
71            self.assertIn("CMakeLists.txt (engine) says", "\n".join(rm.check(no_from)))
72            gone = copy.deepcopy(m)
73            gone["engine_version"] = "0.1.58"                       # no 0.1.58 engine package in the asset list
74            self.assertIn("CMakeLists.txt (engine) says", "\n".join(rm.check(gone)))
75        finally:
76            rm.code_versions = real
77
78    def test_installer_names_in_the_manifest_asset_list(self):
79        m = rm.load()
80        for name in rm.expand(m):
81            self.assertIn(name, m["assets"])
82
83
84if __name__ == "__main__":
85    unittest.main()