okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
8ea7fef82
main
1"""The Terminal tells people the app's version (0.2.3), and its README no longer contradicts itself.""" 2 3from __future__import annotations 4 5import re 6import subprocess 7import sys 8import unittest 9from pathlib import Path 10 11import strata_cli 12 13ROOT = Path (__file__ ).resolve ().parents [2 ] 14sys .path .insert (0 ,str (ROOT / "packaging" )) 15import package_terminal # noqa: E402 16 17 18class ProductVersion (unittest .TestCase ): 19def test_it_is_the_apps_own_version_or_a_terminal_only_release_after_it (self ): 20cargo = ROOT / "apps" / "desktop" / "src-tauri" / "Cargo.toml" 21if not cargo .is_file (): 22self .skipTest ("no app source in this tree" ) 23m = re .search (r'^version\s*=\s*"([^"]+)"' ,cargo .read_text (encoding = "utf-8" ),re .MULTILINE ) 24# 0.2.3.1 is a Control-only hotfix: the Terminal says 0.2.3.1 while the app (and its updater entry) stay 0.2.3 25# 0.2.4 is a Terminal release: the app stays 0.2.3 (the Terminal is never older than the app) 26as_tuple = lambda v :tuple (int (p )for p in v .split ("." )) 27self .assertGreaterEqual (as_tuple (strata_cli .PRODUCT_VERSION ),as_tuple (m .group (1 ))) 28self .assertEqual (as_tuple (strata_cli .PRODUCT_VERSION )[:2 ],as_tuple (m .group (1 ))[:2 ]) 29 30def test_dash_dash_version_leads_with_it_and_keeps_the_build_number (self ): 31out = subprocess .run ([sys .executable ,str (ROOT / "strata.py" ),"--version" ],capture_output = True ,text = True ,check = True ).stdout 32self .assertTrue (out .startswith (f"strata { strata_cli . PRODUCT_VERSION } (build { strata_cli . version () } ;" ),out ) 33self .assertIn (sys .executable ,out )# the packaging smoke test reads the interpreter back from this line 34 35def test_the_build_number_stays_numeric_for_the_engine_compatibility_checks (self ): 36self .assertRegex (strata_cli .version (),r"^[0-9]+(\.[0-9]+)+$" ) 37 38 39class Readme (unittest .TestCase ): 40def readme (self ,target :str )-> str : 41return package_terminal ._readme ("0.2.3" ,target ) 42 43def test_it_does_not_say_nothing_downloads_and_then_that_launch_fetches (self ): 44text = " " .join (self .readme ("windows-x86_64" ).split ()) 45self .assertNotIn ("Starting and serving never install or download anything" ,text ) 46self .assertIn ("Serving and watching" ,text ) 47self .assertIn ("Only two commands fetch files" ,text ) 48self .assertIn ("`strata launch`" ,text ) 49 50def test_the_launch_doc_it_points_at_is_in_the_archive (self ): 51self .assertIn ("docs/TERMINAL_LAUNCH.md" ,self .readme ("linux-x86_64" )) 52self .assertIn ("docs/TERMINAL_LAUNCH.md" ,package_terminal .PAYLOAD ) 53self .assertTrue ((ROOT / "docs" / "TERMINAL_LAUNCH.md" ).is_file ()) 54 55def test_free_memory_guidance_fits_the_system (self ): 56win ,lin ,mac = (self .readme (t )for t in ("windows-x86_64" ,"linux-x86_64" ,"darwin-arm64" )) 57self .assertNotIn ("free -g" ,win ) 58self .assertIn ("FreePhysicalMemory" ,win ) 59self .assertIn ("Task Manager" ,win ) 60self .assertIn ("free -g" ,lin ) 61self .assertNotIn ("free -g" ,mac ) 62 63 64if __name__ == "__main__" : 65unittest .main ()