@@ -25,9 +25,31 @@ it("lints at the lowest CPU priority so it never competes with a Studio boot", a
2525 expect ( write ) . toHaveBeenCalledWith ( expect . stringContaining ( '{"ok":true}' ) ) ;
2626} ) ;
2727
28- it ( "still lints when a sandbox forbids lowering the priority" , async ( ) => {
28+ const nodeSystemErrorWithOsCodeInInfo = ( code : string ) =>
29+ Object . assign ( new Error ( `A system error occurred: uv_os_setpriority returned ${ code } ` ) , {
30+ code : "ERR_SYSTEM_ERROR" ,
31+ info : { code, syscall : "uv_os_setpriority" } ,
32+ } ) ;
33+
34+ it . each ( [ "EPERM" , "EACCES" ] ) (
35+ "still lints, saying nothing, when a sandbox refuses lowering the priority (%s)" ,
36+ async ( code ) => {
37+ os . setPriority . mockImplementation ( ( ) => {
38+ throw nodeSystemErrorWithOsCodeInInfo ( code ) ;
39+ } ) ;
40+ const write = vi . spyOn ( process . stdout , "write" ) . mockImplementation ( ( ) => true ) ;
41+ const warn = vi . spyOn ( process . stderr , "write" ) . mockImplementation ( ( ) => true ) ;
42+
43+ await import ( "./renderSetupWorker.js" ) ;
44+
45+ expect ( write ) . toHaveBeenCalledWith ( expect . stringContaining ( '{"ok":true}' ) ) ;
46+ expect ( warn ) . not . toHaveBeenCalled ( ) ;
47+ } ,
48+ ) ;
49+
50+ it ( "still names any other priority failure, and lints" , async ( ) => {
2951 os . setPriority . mockImplementation ( ( ) => {
30- throw new Error ( "uv_os_setpriority returned EPERM (operation not permitted) ") ;
52+ throw nodeSystemErrorWithOsCodeInInfo ( "ESRCH ") ;
3153 } ) ;
3254 const write = vi . spyOn ( process . stdout , "write" ) . mockImplementation ( ( ) => true ) ;
3355 const warn = vi . spyOn ( process . stderr , "write" ) . mockImplementation ( ( ) => true ) ;
@@ -36,5 +58,5 @@ it("still lints when a sandbox forbids lowering the priority", async () => {
3658
3759 expect ( write ) . toHaveBeenCalledWith ( expect . stringContaining ( '{"ok":true}' ) ) ;
3860 expect ( warn ) . toHaveBeenCalledTimes ( 1 ) ;
39- expect ( warn ) . toHaveBeenCalledWith ( expect . stringContaining ( "EPERM " ) ) ;
61+ expect ( warn ) . toHaveBeenCalledWith ( expect . stringContaining ( "ESRCH " ) ) ;
4062} ) ;
0 commit comments