Skip to content

Commit 0b44f81

Browse files
committed
Extract cancellation fixture string constants
1 parent 7076a11 commit 0b44f81

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

‎CodexSharpSDK.Tests/Unit/CodexExecTests.cs‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ public class CodexExecTests
1515
private const string LongRunningCliScript = "#!/bin/sh\necho $$\nexec /bin/sleep 30\n";
1616
private const string DescendantHoldingStderrScript = "/usr/bin/setsid /bin/sleep 30 >&2 & echo $!; exit 0";
1717
private const string PosixFixtureSkipReason = "The public CLI yield-boundary fixture currently uses a POSIX executable script.";
18+
private const string LinuxFixtureSkipReason = "The detached stderr-retention fixture requires Linux setsid.";
1819
private const string StderrClosureFailure = "stderr stream closed";
20+
private const string TestInput = "test";
21+
private const string CancellationScriptFileName = "codex-cancel.sh";
22+
private const string MissingExecutableNamePrefix = "missing-codex-cli-";
23+
private const string PosixShellPath = "/bin/sh";
24+
private const string PosixShellCommandFlag = "-c";
1925

2026
[Test]
2127
public async Task PublicExec_CancellationBetweenYieldedLinesIsNotReportedAsSuccess()
@@ -27,7 +33,7 @@ public async Task PublicExec_CancellationBetweenYieldedLinesIsNotReportedAsSucce
2733
}
2834

2935
var sandboxDirectory = CreateSandboxDirectory();
30-
var scriptPath = Path.Combine(sandboxDirectory, "codex-cancel.sh");
36+
var scriptPath = Path.Combine(sandboxDirectory, CancellationScriptFileName);
3137
File.WriteAllText(scriptPath, LongRunningCliScript);
3238
File.SetUnixFileMode(scriptPath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);
3339
using var cancellation = new CancellationTokenSource();
@@ -37,7 +43,7 @@ public async Task PublicExec_CancellationBetweenYieldedLinesIsNotReportedAsSucce
3743
{
3844
await using var enumerator = exec.RunAsync(new CodexExecArgs
3945
{
40-
Input = "test",
46+
Input = TestInput,
4147
CancellationToken = cancellation.Token,
4248
}).GetAsyncEnumerator(cancellation.Token);
4349

@@ -62,7 +68,7 @@ public async Task PublicExec_CancellationBetweenYieldedLinesIsNotReportedAsSucce
6268
public async Task PublicExec_PreCanceledTokenDoesNotStartCliProcess()
6369
{
6470
var sandboxDirectory = CreateSandboxDirectory();
65-
var executablePath = Path.Combine(sandboxDirectory, $"missing-codex-cli-{Guid.NewGuid():N}");
71+
var executablePath = Path.Combine(sandboxDirectory, $"{MissingExecutableNamePrefix}{Guid.NewGuid():N}");
6672
using var cancellation = new CancellationTokenSource();
6773
cancellation.Cancel();
6874
using var exec = new CodexExec(TimeSpan.FromSeconds(5), executablePath, CreateProcessEnvironment());
@@ -71,7 +77,7 @@ public async Task PublicExec_PreCanceledTokenDoesNotStartCliProcess()
7177
{
7278
await using var enumerator = exec.RunAsync(new CodexExecArgs
7379
{
74-
Input = "test",
80+
Input = TestInput,
7581
CancellationToken = cancellation.Token,
7682
}).GetAsyncEnumerator(cancellation.Token);
7783

@@ -92,13 +98,13 @@ public async Task DefaultProcessRunner_RootExitWithDescendantHoldingStderr_Fails
9298
{
9399
if (!OperatingSystem.IsLinux())
94100
{
95-
Skip.Test("The detached stderr-retention fixture requires Linux setsid.");
101+
Skip.Test(LinuxFixtureSkipReason);
96102
return;
97103
}
98104

99105
var invocation = new CodexProcessInvocation(
100-
"/bin/sh",
101-
["-c", DescendantHoldingStderrScript],
106+
PosixShellPath,
107+
[PosixShellCommandFlag, DescendantHoldingStderrScript],
102108
CreateProcessEnvironment(),
103109
string.Empty)
104110
{

0 commit comments

Comments
 (0)