Skip to content

Commit 11c9d86

Browse files
pieternclaude
andauthored
Fix line ending related integration failures (#4256)
## Why The root cause of TestExport and TestImportDir test failures was that we relied on the backend to normalize line endings. Previously, the backend would normalize line endings during import/export. Starting 2025-12-16, the backend changed to preserve line endings exactly as provided, without any normalization. This change fixes the tests by: 1. Including trailing newlines in input notebook content that we upload (fixes TestExport and TestExportWithFileFlag) 2. Adding integration/.gitattributes to enforce LF line endings on all platforms (Linux, Mac, Windows) for test files (fixes TestImportDir, TestImportDirDoesNotOverwrite, TestImportDirWithOverwriteFlag, TestImportFileFormatAuto, TestImportFileFormatSource) By sending payloads with the expected line endings and ensuring consistent checkout behavior via .gitattributes, the tests now validate correct round-trip behavior across all platforms. Without .gitattributes, Windows would check out test files with CRLF, causing the uploaded content to differ from what Linux/Mac upload, leading to platform-specific test failures. ## Tests The mentioned tests should show up as "recovered" in this run. Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent a2ed757 commit 11c9d86

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

integration/.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# We should always treat new lines in integration test files on Windows as \n.
2+
# This is important because the characters themselves are semantically important in tests.
3+
# For example, an additional \r character in Windows changes the upload payload when
4+
# uploading file content to a workspace.
5+
*.py text eol=lf
6+
*.sql text eol=lf
7+
*.r text eol=lf
8+
*.scala text eol=lf
9+
*.ipynb text eol=lf

integration/cmd/workspace/workspace_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func TestExport(t *testing.T) {
279279
assert.Equal(t, "abc", string(b))
280280

281281
// Export python notebook
282-
err = f.Write(ctx, "pyNotebook.py", strings.NewReader("# Databricks notebook source"))
282+
err = f.Write(ctx, "pyNotebook.py", strings.NewReader("# Databricks notebook source\n"))
283283
require.NoError(t, err)
284284
stdout, _ = testcli.RequireSuccessfulRun(t, ctx, "workspace", "export", path.Join(sourceDir, "pyNotebook"))
285285
b, err = io.ReadAll(&stdout)
@@ -311,7 +311,7 @@ func TestExportWithFileFlag(t *testing.T) {
311311
assertLocalFileContents(t, filepath.Join(localTmpDir, "file.txt"), "abc")
312312

313313
// Export python notebook
314-
err = f.Write(ctx, "pyNotebook.py", strings.NewReader("# Databricks notebook source"))
314+
err = f.Write(ctx, "pyNotebook.py", strings.NewReader("# Databricks notebook source\n"))
315315
require.NoError(t, err)
316316
stdout, _ = testcli.RequireSuccessfulRun(t, ctx, "workspace", "export", path.Join(sourceDir, "pyNotebook"), "--file", filepath.Join(localTmpDir, "pyNb.py"))
317317
b, err = io.ReadAll(&stdout)

0 commit comments

Comments
 (0)