@@ -3,6 +3,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite
33import {
44 expectRealExitWinsOverSigkillFallback ,
55 expectWaitStaysPendingUntilSigkillFallback ,
6+ mockLinuxOomWrapperShell ,
67} from "./test-support.js" ;
78
89const { spawnMock, ptyKillMock, signalProcessTreeMock } = vi . hoisted ( ( ) => ( {
@@ -157,7 +158,7 @@ describe("createPtyAdapter", () => {
157158
158159 it ( "forwards non-SIGTERM explicit signals to node-pty kill on non-Windows" , async ( ) => {
159160 const originalPlatform = Object . getOwnPropertyDescriptor ( process , "platform" ) ;
160- Object . defineProperty ( process , "platform" , { value : "linux " , configurable : true } ) ;
161+ Object . defineProperty ( process , "platform" , { value : "darwin " , configurable : true } ) ;
161162 try {
162163 spawnMock . mockReturnValue ( createStubPty ( ) ) ;
163164
@@ -316,17 +317,21 @@ describe("createPtyAdapter", () => {
316317 it ( "wraps Linux PTY spawns so shell children inherit higher OOM score" , async ( ) => {
317318 const originalPlatform = Object . getOwnPropertyDescriptor ( process , "platform" ) ;
318319 Object . defineProperty ( process , "platform" , { value : "linux" , configurable : true } ) ;
320+ const restoreLinuxShell = mockLinuxOomWrapperShell ( ) ;
321+ vi . resetModules ( ) ;
319322 try {
323+ const { createPtyAdapter : createLinuxPtyAdapter } = await import ( "./pty.js" ) ;
320324 const stub = createStubPty ( ) ;
321325 spawnMock . mockReturnValue ( stub ) ;
322326
323- const adapter = await createPtyAdapter ( {
327+ const adapter = await createLinuxPtyAdapter ( {
324328 shell : "bash" ,
325329 args : [ "-lc" , "env" ] ,
326330 env : { PATH : "/usr/bin" , BASH_ENV : "/tmp/bashenv" , TERM : "dumb" } ,
327331 } ) ;
328332 expect ( adapter . oomScoreWrapperSelected ) . toBe ( true ) ;
329333 } finally {
334+ restoreLinuxShell ( ) ;
330335 if ( originalPlatform ) {
331336 Object . defineProperty ( process , "platform" , originalPlatform ) ;
332337 }
0 commit comments