okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
e39a52e33
main
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 ): 12def test_current_pages_agree_with_the_manifest (self ): 13problems = rm .check (rm .load ()) 14self .assertEqual (problems , [],"\n" .join (problems )) 15 16def test_old_installer_names_are_found_and_rewritten (self ): 17m = rm .load () 18old = "run `Strata-0.2.9-windows-x64-setup.exe` or Strata-0.2.9-linux-x86_64.AppImage.sig" 19self .assertEqual (len (rm .INSTALLER_RE .findall (old )),2 ) 20fixed = rm .INSTALLER_RE .sub (lambda x :x .group (0 ).replace (x .group (1 ),m ["product_version" ],1 ),old ) 21self .assertNotIn ("0.2.9" ,fixed ) 22self .assertIn ("Strata-%s-linux-x86_64.AppImage.sig" % m ["product_version" ],fixed ) 23 24def test_version_lines_are_rewritten_and_a_second_pass_changes_nothing (self ): 25m = rm .load () 26page ,regex ,keys = [r for r in rm .LINES if r [0 ]== "AGENTS.md" ][0 ] 27text = "Version 0.2.5, engine 0.1.50. The public model families" 28once = rm .rewrite (text ,regex ,keys ,m ) 29self .assertEqual (once ,"Version %s, engine %s. The public model families" % (m ["product_version" ],m ["engine_version" ])) 30self .assertEqual (rm .rewrite (once ,regex ,keys ,m ),once ) 31 32def test_a_drifting_manifest_is_reported (self ): 33m = copy .deepcopy (rm .load ()) 34m ["product_version" ]= "0.2.99" 35m ["tag" ]= "v0.2.99" 36m .pop ("terminal_version" ,None )# the Terminal then has to say the product version 37problems = "\n" .join (rm .check (m )) 38self .assertIn ("strata_cli/__init__.py says" ,problems ) 39self .assertIn ("asset list has no Strata-0.2.99-windows-x64-setup.exe" ,problems ) 40 41def 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. 43Written so it holds for a release with a hotfix part (0.2.13.1) and without one (0.2.14).""" 44m = rm .load () 45self .assertEqual (rm .check (m ), []) 46wrong = copy .deepcopy (m ) 47wrong ["control_version" ]= m ["engine_version" ]+ ".9" # the manifest names a Control hotfix the source does not have 48problems = "\n" .join (rm .check (wrong )) 49self .assertIn ("CMakeLists.txt (Control) says" ,problems ) 50wrong = copy .deepcopy (m ) 51wrong ["engine_version" ]= "0.1.58" # engines two builds behind Control: not a hotfix 52self .assertIn ("CMakeLists.txt (engine) says" ,"\n" .join (rm .check (wrong ))) 53wrong = copy .deepcopy (m ) 54wrong ["terminal_version" ]= m ["product_version" ]+ ".9" # the manifest names a Terminal the source does not say 55terminal = rm .code_versions ()["strata_cli/__init__.py" ][0 ] 56self .assertIn ("strata_cli/__init__.py says %s" % terminal ,"\n" .join (rm .check (wrong ))) 57 58def 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 60the engines; with it, the engines at engine_version must be packages the release offers.""" 61m = copy .deepcopy (rm .load ()) 62m ["engines_from" ]= "v0.2.14" 63m ["control_version" ],m ["engine_version" ]= "0.1.61" ,"0.1.60" 64cmake = {"CMakeLists.txt (engine)" : ("0.1.61" ,"engine_version" ),"CMakeLists.txt (Control)" : ("0.1.61" ,"control_version" )} 65real = rm .code_versions 66try : 67rm .code_versions = lambda : {** real (),** cmake } 68self .assertNotIn ("CMakeLists.txt (engine) says" ,"\n" .join (rm .check (m ))) 69no_from = copy .deepcopy (m ) 70no_from .pop ("engines_from" ) 71self .assertIn ("CMakeLists.txt (engine) says" ,"\n" .join (rm .check (no_from ))) 72gone = copy .deepcopy (m ) 73gone ["engine_version" ]= "0.1.58" # no 0.1.58 engine package in the asset list 74self .assertIn ("CMakeLists.txt (engine) says" ,"\n" .join (rm .check (gone ))) 75finally : 76rm .code_versions = real 77 78def test_installer_names_in_the_manifest_asset_list (self ): 79m = rm .load () 80for name in rm .expand (m ): 81self .assertIn (name ,m ["assets" ]) 82 83 84if __name__ == "__main__" : 85unittest .main ()