Skip to content

Commit ccab735

Browse files
committed
test: use safe environment in pipe cleanup fixture
1 parent 194c890 commit ccab735

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

‎ClaudeCodeSharpSDK.Tests/Unit/CliInstallationTests.cs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ public sealed class CliInstallationTests
3838
private const string HangMarkerName = "hang";
3939
private const string PipeHolderMarkerName = "pipe-holder";
4040
private const string PipeHolderPidFileName = "pipe-holder.pid";
41-
private const string SetsidPathEnvironmentName = "CLAUDE_TEST_SETSID_PATH";
42-
private const string PipeHolderPidFileEnvironmentName = "CLAUDE_TEST_PIPE_HOLDER_PID_FILE";
4341
private const string SetsidCommandName = "setsid";
4442
private const string CleanupMessage = "CLI installation process or output cleanup could not be confirmed within its configured timeout.";
4543
private const string SetsidRequiredMessage = "The detached pipe-holder cleanup fixture requires Linux setsid.";
@@ -87,9 +85,8 @@ public sealed class CliInstallationTests
8785
if (process.platform !== 'win32') fs.chmodSync(shimPath, 0o755);
8886
if (fs.existsSync(path.join(__dirname, 'pipe-holder'))) {
8987
const { spawnSync } = require('node:child_process');
90-
const shellCommand = '"$1" /bin/sh -c \'echo $$ > "$1"; exec /bin/sleep 60\' holder "$2" &';
91-
spawnSync('/bin/sh', ['-c', shellCommand, 'fixture', process.env.CLAUDE_TEST_SETSID_PATH,
92-
process.env.CLAUDE_TEST_PIPE_HOLDER_PID_FILE], { stdio: 'inherit' });
88+
const shellCommand = `setsid /bin/sh -c 'echo $$ > ${shellQuote(path.join(__dirname, 'pipe-holder.pid'))}; exec /bin/sleep 60' holder &`;
89+
spawnSync('/bin/sh', ['-c', shellCommand], { stdio: 'inherit' });
9390
}
9491
if (fs.existsSync(path.join(__dirname, 'hang'))) {
9592
fs.writeFileSync(path.join(__dirname, 'child.pid'), String(process.pid));
@@ -267,8 +264,9 @@ public async Task CancellationWithDetachedPipeHolderSurfacesUnconfirmedCleanup()
267264
await File.WriteAllTextAsync(Path.Combine(fixture.NpmRoot, BinDirectoryName, PipeHolderMarkerName), string.Empty);
268265
var environment = fixture.Options.EnvironmentVariables.ToDictionary(
269266
static pair => pair.Key, static pair => pair.Value, StringComparer.OrdinalIgnoreCase);
270-
environment[SetsidPathEnvironmentName] = FindExecutablePath(SetsidCommandName);
271-
environment[PipeHolderPidFileEnvironmentName] = holderPidFile;
267+
var setsidPath = FindExecutablePath(SetsidCommandName);
268+
environment[PathName] = string.Join(Path.PathSeparator, environment[PathName],
269+
Path.GetDirectoryName(setsidPath)!);
272270
var options = fixture.Options with
273271
{
274272
EnvironmentVariables = environment,

0 commit comments

Comments
 (0)