Skip to content

Commit 3087d8c

Browse files
authored
Fix snapshot filename collisions on case-insensitive filesystems (github#2)
All SDK test harnesses now generate lowercase snapshot filenames to avoid collisions when checking out on macOS/Windows (case-insensitive filesystems). - Node.js: Added .toLowerCase() to filename generation - Go: Added strings.ToLower() to filename generation - .NET: Simplified to single regex + ToLowerInvariant() - Python: Added .lower() to filename generation Also renamed existing snapshot files to lowercase and removed duplicates that only differed by case.
1 parent 088fc1c commit 3087d8c

16 files changed

+6
-43
lines changed

dotnet/test/Harness/E2ETestContext.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,9 @@ private static string GetCliPath(string repoRoot)
7070

7171
public async Task ConfigureForTestAsync(string testFile, [CallerMemberName] string? testName = null)
7272
{
73-
// Convert PascalCase method names to snake_case matching snapshot filenames
74-
// e.g., Should_Create_A_Session_With_AvailableTools -> should_create_a_session_with_availableTools
75-
var sanitizedName = Regex.Replace(testName!, @"_([A-Z])([A-Z]+)(_|$)", m =>
76-
"_" + char.ToLowerInvariant(m.Groups[1].Value[0]) + m.Groups[2].Value.ToLowerInvariant() + m.Groups[3].Value);
77-
sanitizedName = Regex.Replace(sanitizedName, @"(^|_)([A-Z])(?=[a-z]|_|$)", m =>
78-
m.Groups[1].Value + char.ToLowerInvariant(m.Groups[2].Value[0]));
73+
// Convert test method names to lowercase snake_case for snapshot filenames
74+
// to avoid case collisions on case-insensitive filesystems (macOS/Windows)
75+
var sanitizedName = Regex.Replace(testName!, @"[^a-zA-Z0-9]", "_").ToLowerInvariant();
7976
var snapshotPath = Path.Combine(_repoRoot, "test", "snapshots", testFile, $"{sanitizedName}.yaml");
8077
await _proxy.ConfigureAsync(snapshotPath, WorkDir);
8178
}

go/e2e/testharness/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (c *TestContext) ConfigureForTest(t *testing.T) {
9999
parts := strings.SplitN(testName, "/", 2)
100100

101101
testFile := strings.ToLower(strings.TrimPrefix(parts[0], "Test"))
102-
sanitizedName := regexp.MustCompile(`[^a-zA-Z0-9]`).ReplaceAllString(parts[1], "_")
102+
sanitizedName := strings.ToLower(regexp.MustCompile(`[^a-zA-Z0-9]`).ReplaceAllString(parts[1], "_"))
103103
snapshotPath := filepath.Join("..", "..", "test", "snapshots", testFile, sanitizedName+".yaml")
104104

105105
absSnapshotPath, err := filepath.Abs(snapshotPath)

nodejs/test/e2e/harness/sdkTestContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function getTrafficCapturePath(testContext: TestContext): string {
8181
}
8282

8383
const testFileName = basename(testFilePath, suffix);
84-
const taskNameAsFilename = testContext.task.name.replace(/[^a-z0-9]/gi, "_");
84+
const taskNameAsFilename = testContext.task.name.replace(/[^a-z0-9]/gi, "_").toLowerCase();
8585
return join(SNAPSHOTS_DIR, testFileName, `${taskNameAsFilename}.yaml`);
8686
}
8787

python/e2e/testharness/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async def configure_for_test(self, test_file: str, test_name: str):
9797
test_file: The test file name (e.g., "session" from "test_session.py")
9898
test_name: The test name (e.g., "should_have_stateful_conversation")
9999
"""
100-
sanitized_name = re.sub(r"[^a-zA-Z0-9]", "_", test_name)
100+
sanitized_name = re.sub(r"[^a-zA-Z0-9]", "_", test_name).lower()
101101
snapshot_path = SNAPSHOTS_DIR / test_file / f"{sanitized_name}.yaml"
102102
abs_snapshot_path = str(snapshot_path.resolve())
103103

test/snapshots/ask/should_invoke_onEvent_callback_for_each_event.yaml renamed to test/snapshots/ask/should_invoke_onevent_callback_for_each_event.yaml

File renamed without changes.

test/snapshots/combinedconfiguration/accept_MCP_servers_and_custom_agents.yaml renamed to test/snapshots/combinedconfiguration/accept_mcp_servers_and_custom_agents.yaml

File renamed without changes.

test/snapshots/mcp-and-agents/should_accept_both_MCP_servers_and_custom_agents.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/snapshots/mcpservers/accept_MCP_server_config_on_create.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/snapshots/mcpservers/accept_MCP_server_config_on_resume.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/snapshots/mcp-and-agents/should_accept_MCP_server_configuration_on_session_create.yaml renamed to test/snapshots/mcpservers/accept_mcp_server_config_on_create.yaml

File renamed without changes.

0 commit comments

Comments
 (0)