@@ -288,10 +288,10 @@ switch (args[1]) { |
288 | 288 | ); |
289 | 289 | yield* fs.writeFileString( |
290 | 290 | path.join(directory, "ps"), |
291 | | - '#!/bin/sh\nif [ "$T3_FIXTURE_ZOMBIE" = "1" ]; then printf Z; else exec /bin/ps "$@"; fi\n', |
| 291 | + '#!/bin/sh\nfor arg do pid="$arg"; done\nif [ -n "$T3_FIXTURE_ZOMBIE_PID" ] && [ "$pid" = "$T3_FIXTURE_ZOMBIE_PID" ]; then printf Z; else exec /bin/ps "$@"; fi\n', |
292 | 292 | { mode: 0o700 }, |
293 | 293 | ); |
294 | | - let zombie = "0"; |
| 294 | + let zombiePid = ""; |
295 | 295 | let readyPort = "41773"; |
296 | 296 | const localSsh = ChildProcessSpawner.make((command) => { |
297 | 297 | assert.strictEqual(command._tag, "StandardCommand"); |
@@ -302,7 +302,7 @@ switch (args[1]) { |
302 | 302 | env: { |
303 | 303 | HOME: directory, |
304 | 304 | PATH: `${directory}:/usr/bin:/bin`, |
305 | | - T3_FIXTURE_ZOMBIE: zombie, |
| 305 | + T3_FIXTURE_ZOMBIE_PID: zombiePid, |
306 | 306 | T3CODE_HOME: customHome, |
307 | 307 | T3_FIXTURE_READY_PORT: readyPort, |
308 | 308 | T3_FIXTURE_STATE_DIR: stateDir, |
@@ -343,14 +343,37 @@ switch (args[1]) { |
343 | 343 | yield* fs.readFileString(path.join(stateDir, "run-t3.sh")), |
344 | 344 | "old runner stays intact", |
345 | 345 | ); |
346 | | - zombie = "1"; |
| 346 | + zombiePid = String(external.pid); |
347 | 347 | readyPort = "41774"; |
348 | 348 | assert.deepEqual(yield* launch, { remotePort: 41774, remoteServerKind: "managed" }); |
349 | 349 | assert.strictEqual( |
350 | 350 | (yield* fs.readFileString(path.join(stateDir, "server-home"))).trim(), |
351 | 351 | customHome, |
352 | 352 | ); |
353 | 353 | assert.isTrue(yield* external.isRunning); |
| 354 | + |
| 355 | + // A rejected runtime PID must not hide a live sibling on the selected home. |
| 356 | + const sibling = yield* realSpawner.spawn( |
| 357 | + ChildProcess.make(process.execPath, [ |
| 358 | + "-e", |
| 359 | + "process.stdin.resume()", |
| 360 | + "--", |
| 361 | + "serve", |
| 362 | + "--host", |
| 363 | + "127.0.0.1", |
| 364 | + "--port", |
| 365 | + "41775", |
| 366 | + ]), |
| 367 | + ); |
| 368 | + const siblingDir = path.join(directory, ".t3/ssh-launch", "sibling"); |
| 369 | + yield* fs.makeDirectory(siblingDir, { recursive: true }); |
| 370 | + yield* fs.writeFileString(path.join(siblingDir, "managed"), "managed"); |
| 371 | + yield* fs.writeFileString(path.join(siblingDir, "pid"), String(sibling.pid)); |
| 372 | + yield* fs.writeFileString(path.join(siblingDir, "port"), "41775"); |
| 373 | + yield* fs.writeFileString(path.join(siblingDir, "server-home"), customHome); |
| 374 | + readyPort = "41775"; |
| 375 | + assert.deepEqual(yield* launch, { remotePort: 41775, remoteServerKind: "external" }); |
| 376 | + assert.isTrue(yield* sibling.isRunning); |
354 | 377 | }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))), |
355 | 378 | ); |
356 | 379 |
|
|