okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
538acd098
main
1"""docs/TROUBLESHOOTING.md keeps every entry the 0.2.5 rewrite lost (restored for 0.2.7), and every pointer to it resolves. 2 3setup.py and the server print "see docs/TROUBLESHOOTING.md" with an entry's name, DETAILS.md sends readers there for environment variables, and other 4pages link to its headings. An entry that disappears turns those pointers into dead ends (the "Windows AMD: the driver resets" entry did, and setup's own 5test failed on it). 6""" 7from __future__import annotations 8 9import re 10import unittest 11from pathlib import Path 12 13ROOT = Path (__file__ ).resolve ().parents [2 ] 14PAGE = ROOT / "docs" / "TROUBLESHOOTING.md" 15 16# One distinctive phrase from the title of each entry the v0.2.4.2 page had (the page may reword the rest). 17ENTRIES = [ 18"couldn't find an engine for this computer" ,"needs a newer engine" ,"damaged and can't be opened" ,"strata doctor" ,"Sending logs for a bug report" , 19"froze, or got very slow" ,"app keeps more graphics memory free" ,"A download stopped" ,"driver is too old" ,"Port 8080 is already in use" , 20"Smart App Control" ,"new engine misbehaves" ,"git pull did not succeed" ,"build tools could not be installed" ,"does not compile" , 21"Startup takes a long time" ,"does not match GitHub's checksum" ,"It is slow and the disk light" ,"engine stopped unexpectedly" ,"exit code -9" , 22"exceeds the context" ,"slower than the tables" ,"came back empty" ,"Turing card" ,"--expert-cache N" ,"--resident-budget-gib N" , 23"page-locked expert copy" ,"0x141" ,"RTX 50 card" ,"Pictures are refused" ,"KFD topology is empty" ,"build's list" ,"0xC0000005" , 24"the driver resets" ,"Large pinned host allocations" ,"verify: timed out at layer N" , 25] 26 27 28def slug (heading :str )-> str : 29return re .sub (r"[^\w\- ]" ,"" ,heading .strip ().lower ()).replace (" " ,"-" ) 30 31 32def anchors (path :Path )-> set [str ]: 33return {slug (h )for h in re .findall (r"^#+\s+(.*)$" ,path .read_text (encoding = "utf-8" ),re .M )} 34 35 36class TroubleshootingPage (unittest .TestCase ): 37def setUp (self ): 38self .text = PAGE .read_text (encoding = "utf-8" ) 39self .flat = re .sub (r"\s+" ," " ,self .text .replace ("*" ,"" )) 40 41def test_every_entry_of_v0_2_4_2_is_on_the_page (self ): 42for phrase in ENTRIES : 43self .assertIn (re .sub (r"\s+" ," " ,phrase ),self .flat ,f"the entry about { phrase !r } is missing" ) 44 45def test_what_setup_and_the_server_point_to_is_there (self ): 46setup = (ROOT / "setup.py" ).read_text (encoding = "utf-8" ) 47for name in re .findall (r'docs/TROUBLESHOOTING\.md, \\"([^"\\]+)\\"' ,setup ): 48self .assertIn (name ,self .text ,f"setup.py points to the entry { name !r } " ) 49server = (ROOT / "serve" / "server.py" ).read_text (encoding = "utf-8" ) 50self .assertIn ("docs/TROUBLESHOOTING.md" ,server ) 51self .assertIn ("Smart App Control" ,self .text )# that pointer is the blocked-executable message 52self .assertIn ("--vision no" ,self .text )# which names the way out for a source checkout 53 54def test_the_variables_that_other_pages_send_here_are_explained (self ): 55details = (ROOT / "docs" / "DETAILS.md" ).read_text (encoding = "utf-8" ) 56for line in details .splitlines (): 57if "TROUBLESHOOTING.md" in line : 58for name in re .findall (r"STRATA_[A-Z0-9_]+" ,line ): 59self .assertIn (name ,self .text ,f"DETAILS.md sends readers here for { name } " ) 60 61def test_links_into_the_page_and_out_of_it_resolve (self ): 62own = anchors (PAGE ) 63for md in sorted ((ROOT / "docs" ).glob ("*.md" ))+ [ROOT / "README.md" ,ROOT / "SECURITY.md" ]: 64for target in re .findall (r"\(((?:\.\./)?(?:docs/)?TROUBLESHOOTING\.md#[^)\s]+)\)" ,md .read_text (encoding = "utf-8" )): 65self .assertIn (target .split ("#" ,1 )[1 ],own ,f" { md . name } links to { target } " ) 66for match in re .finditer (r"\]\(([^)#\s]+)?(#[^)\s]*)?\)" ,self .text ): 67name ,anchor = match .group (1 ),match .group (2 ) 68if name and name .startswith ("http" ): 69continue 70target = (PAGE .parent / name ).resolve ()if name else PAGE 71self .assertTrue (target .exists (),f"the page links to { name } , which is not there" ) 72if anchor and target .suffix == ".md" : 73self .assertIn (anchor [1 :],anchors (target ),f"the page links to { name or '' } { anchor } " ) 74 75 76if __name__ == "__main__" : 77unittest .main ()