Skip to content

Commit 9915343

Browse files
stephentoubCopilot
andauthored
Fix C# listFiles E2E ordering assumption (#1261)
* Fix listFiles E2E order assertion Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix Rust listFiles E2E order assertion Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4a0437b commit 9915343

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

dotnet/test/E2E/RpcAdditionalEdgeCasesE2ETests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public async Task Permissions_SetApproveAll_Toggle_Round_Trips()
188188
}
189189

190190
[Fact]
191-
public async Task Workspaces_CreateFile_Then_ListFiles_Returns_Sorted_Or_Stable_Order()
191+
public async Task Workspaces_CreateFile_Then_ListFiles_Returns_All_Files()
192192
{
193193
var session = await CreateSessionAsync();
194194
var prefix = $"order-{Guid.NewGuid():N}-";
@@ -204,15 +204,16 @@ public async Task Workspaces_CreateFile_Then_ListFiles_Returns_Sorted_Or_Stable_
204204
.Where(path => path.StartsWith(prefix, StringComparison.Ordinal))
205205
.ToList();
206206

207-
// The files this test created should be returned in sorted order.
208-
Assert.Equal(paths, matchingFiles);
207+
// The files this test created should all be returned; the runtime does not guarantee
208+
// that workspace file enumeration is sorted.
209+
Assert.Equal(paths, matchingFiles.OrderBy(path => path, StringComparer.Ordinal));
209210

210-
// Calling list again immediately must preserve the same order.
211+
// A repeated list should still include the files regardless of returned order.
211212
var listed2 = await session.Rpc.Workspaces.ListFilesAsync();
212213
var matchingFiles2 = listed2.Files
213214
.Where(path => path.StartsWith(prefix, StringComparison.Ordinal))
214215
.ToList();
215-
Assert.Equal(matchingFiles, matchingFiles2);
216+
Assert.Equal(paths, matchingFiles2.OrderBy(path => path, StringComparer.Ordinal));
216217
}
217218

218219
[Fact]

rust/tests/e2e/rpc_additional_edge_cases.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,10 @@ async fn permissions_set_approve_all_toggle_round_trips() {
428428
}
429429

430430
#[tokio::test]
431-
async fn workspaces_createfile_then_listfiles_returns_sorted_or_stable_order() {
431+
async fn workspaces_createfile_then_listfiles_returns_all_files() {
432432
with_e2e_context(
433433
"rpc_additional_edge_cases",
434-
"workspaces_createfile_then_listfiles_returns_sorted_or_stable_order",
434+
"workspaces_createfile_then_listfiles_returns_all_files",
435435
|ctx| {
436436
Box::pin(async move {
437437
ctx.set_default_copilot_user();
@@ -465,9 +465,10 @@ async fn workspaces_createfile_then_listfiles_returns_sorted_or_stable_order() {
465465
.list_files()
466466
.await
467467
.expect("list files again");
468-
assert_eq!(first.files, second.files);
469-
for expected in ["a-rust.txt", "b-rust.txt", "c-rust.txt"] {
470-
assert!(first.files.iter().any(|file| file == expected));
468+
for files in [&first.files, &second.files] {
469+
for expected in ["a-rust.txt", "b-rust.txt", "c-rust.txt"] {
470+
assert!(files.iter().any(|file| file == expected));
471+
}
471472
}
472473

473474
session.disconnect().await.expect("disconnect session");

0 commit comments

Comments
 (0)