Skip to content

Commit 79c3e5a

Browse files
stephentoubCopilot
andcommitted
Stabilize .NET CLI startup error test
Use a deterministic failing JavaScript CLI fixture instead of relying on the bundled CLI to parse an invalid flag within the TCP startup timeout on loaded Windows runners. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 781f5380-c114-40eb-a599-378b3f15cbea
1 parent d126e9c commit 79c3e5a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

dotnet/test/E2E/ClientE2ETests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ namespace GitHub.Copilot.Test.E2E;
1111
// Other test classes should instead inherit from E2ETestBase
1212
public class ClientE2ETests(E2ETestFixture fixture) : IClassFixture<E2ETestFixture>
1313
{
14+
private const string FailingCliScript =
15+
"process.stderr.write('nonexistent test flag on stderr\\n'); process.exit(1);";
16+
1417
private E2ETestContext Ctx => fixture.Ctx;
1518

1619
[Theory]
@@ -177,11 +180,14 @@ public async Task Should_Not_Throw_When_Disposing_Session_After_Stopping_Client(
177180
[InlineData(false)] // TCP transport
178181
public async Task Should_Report_Error_With_Stderr_When_CLI_Fails_To_Start(bool useStdio)
179182
{
183+
var cliPath = Path.Join(Ctx.WorkDir, $"failing-cli-{Guid.NewGuid():N}.js");
184+
await File.WriteAllTextAsync(cliPath, FailingCliScript);
185+
180186
var client = new CopilotClient(new CopilotClientOptions
181187
{
182188
Connection = useStdio
183-
? RuntimeConnection.ForStdio(args: ["--nonexistent-flag-for-testing"])
184-
: RuntimeConnection.ForTcp(args: ["--nonexistent-flag-for-testing"])
189+
? RuntimeConnection.ForStdio(path: cliPath)
190+
: RuntimeConnection.ForTcp(path: cliPath)
185191
});
186192

187193
var ex = await Assert.ThrowsAsync<IOException>(() => client.StartAsync());

0 commit comments

Comments
 (0)