6464NORM = 1000
6565#: How long the probe records, and the frame rate it asks for.
6666RECORD_S = 2.0
67+ #: How many times a check whose effect a busy desk can miss is tried before it fails: a desk starved through a drag
68+ #: sees its motion as one event, and keys sent while the click that focuses a box waits go wherever focus was.
69+ BUSY_DESK_ATTEMPTS = 2
6770RECORD_FPS = 5
6871#: Prints a file's size and SHA-256 as JSON, run with ``python3 -c`` on the computer.
6972READ_DIGEST = ("import hashlib,json,sys;d=open(sys.argv[1],'rb').read();"
@@ -165,15 +168,22 @@ async def full(self) -> None:
165168
166169 # Recording
167170
168- async def check (self , check : str , name : str , test : Test , * extensions : str ) -> bool :
169- try :
170- problem = await test ()
171- except NotApplicable as e :
172- self ._record (check , name , "not_applicable" , str (e ), extensions )
173- return True
174- except Exception as e :
175- problem = f"{ type (e ).__name__ } : { e } "
176- self ._record (check , name , "failed" if problem else "passed" , problem or "" , extensions )
171+ async def check (self , check : str , name : str , test : Test , * extensions : str , attempts : int = 1 ) -> bool :
172+ """Run ``test`` up to ``attempts`` times until it passes; a pass after a failed try says what that try found."""
173+ tried : list [str ] = []
174+ while True :
175+ try :
176+ problem = await test ()
177+ except NotApplicable as e :
178+ self ._record (check , name , "not_applicable" , str (e ), extensions )
179+ return True
180+ except Exception as e :
181+ problem = f"{ type (e ).__name__ } : { e } "
182+ if problem is None or len (tried ) + 1 == attempts :
183+ break
184+ tried .append (problem )
185+ detail = problem or (f"passed on try { len (tried ) + 1 } of { attempts } ; before: { '; ' .join (tried )} " if tried else "" )
186+ self ._record (check , name , "failed" if problem else "passed" , detail , extensions )
177187 return problem is None
178188
179189 async def _guarded (self , check : str , section : Callable [[], Awaitable [None ]]) -> None :
@@ -837,7 +847,7 @@ async def held() -> str | None:
837847
838848 await self .check ("P6" , "Unicode and mixed-case text arrives whole" , unicode )
839849 await self .check ("P6" , "typed text arrives as key events" , events )
840- await self .check ("P6" , "a chord selects all, and Backspace clears it" , chord )
850+ await self .check ("P6" , "a chord selects all, and Backspace clears it" , chord , attempts = BUSY_DESK_ATTEMPTS )
841851 await self .check ("P6" , "a repeated key presses that many times" , repeat )
842852 await self .check ("P6" , "tabs and newlines arrive as typed" , whitespace )
843853 await self .check ("P6" , "typing leaves the clipboard as it was" , clipboard )
@@ -865,8 +875,9 @@ async def drag() -> str | None:
865875 start , end , waypoint = (50 , 50 ), (300 , 250 ), (200 , 100 )
866876 points = [start , waypoint , end ] if int (self .features .get ("max_drag_points" , 2 )) >= 3 else [start , end ]
867877 path = [list (self ._at ("pad" , scale , x , y )) for x , y in points ]
878+ before = (await self .state ())["drags" ]
868879 await self .act ("computer_drag" , {"path" : path , "duration_ms" : 400 , "frame_id" : frame })
869- ok , state = await self .until (lambda s : bool ( s ["drags" ]) )
880+ ok , state = await self .until (lambda s : s ["drags" ] != before )
870881 if not ok :
871882 return "no drag reached the pad"
872883 stroke = state ["drags" ][- 1 ]
@@ -878,7 +889,8 @@ async def drag() -> str | None:
878889
879890 await self .check ("P7" , "a scroll moves a list" , scroll_list )
880891 await self .check ("P7" , "scrolls up, down, left and right each arrive that many times" , directions )
881- await self .check ("P7" , "a drag starts and ends where it says, through its waypoints" , drag )
892+ await self .check ("P7" , "a drag starts and ends where it says, through its waypoints" , drag ,
893+ attempts = BUSY_DESK_ATTEMPTS )
882894
883895 async def _pointer_input (self ) -> None :
884896 if not self .driver .declares (COMPUTER_POINTER ):
0 commit comments