Skip to content

Partial fix for Windows unit test failure, including addition of .gitattributes to resolve EOL issues#264

Open
checkinnuggets wants to merge 3 commits into
mozilla-ai:mainfrom
checkinnuggets:initial-unit-test-tidyup
Open

Partial fix for Windows unit test failure, including addition of .gitattributes to resolve EOL issues#264
checkinnuggets wants to merge 3 commits into
mozilla-ai:mainfrom
checkinnuggets:initial-unit-test-tidyup

Conversation

@checkinnuggets

@checkinnuggets checkinnuggets commented Jun 9, 2026

Copy link
Copy Markdown

Original issue: #218
Further discussion with @peteski22 on PR: #221

(I note that CONTRIBUTING.md suggests following a PR template, but I'm not sure where to find that).

This PR fixes some issues identified as part of investigating reinstating Windows support. There are many failing unit tests on Windows. This PR aims to clears up some of the noise leaving only the tests relating to the core permission issues failing on Windows (see discussion linked above).

  • Added .gitattributes to ensure files checked out as LF - for dev experience, but also because there are test which assert file content and mixed up line endings cause them to fail.
  • Fixed some tests which fail due to temp files created by the test not being closed.
  • Fixed some tests which fail due to checking temp paths which were not correctly constructed.

Update 21/06
Path construction fix split to a separate PR.

Summary by CodeRabbit

  • Tests

    • Improved test reliability by properly releasing file handles during test setup.
    • Enhanced test isolation by replacing hard-coded paths with temporary directory-based paths, ensuring tests run independently without relying on specific system configurations.
  • Chores

    • Updated repository configuration to enforce consistent line ending handling across the codebase.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c79d07bc-b92a-43f8-a537-23d9b7331f63

📥 Commits

Reviewing files that changed from the base of the PR and between 157e51f and 5cb44c0.

📒 Files selected for processing (1)
  • internal/files/files_test.go

Walkthrough

.gitattributes gains an eol=lf rule. Temporary file handles are explicitly closed (with require.NoError) in four test functions across cmd/remove_test.go and internal/config/config_test.go. XDG path tests in internal/files/files_test.go replace hard-coded /custom/... paths with os.TempDir()-based paths.

Changes

Test robustness improvements and line-ending configuration

Layer / File(s) Summary
Git line-ending configuration
.gitattributes
Adds text=auto eol=lf rule to enforce LF line endings across the repository.
File handle closure in configuration tests
internal/config/config_test.go, cmd/remove_test.go
TestInit_CreatesNewConfigFile, TestAddServer_AppendsServerAndPersists, TestRemoveServer_RemovesCorrectEntry, and TestRemoveServer each gain an explicit tempFile.Close() call with require.NoError immediately after temp file creation, before any subsequent file path operations.
Temporary directory paths in XDG tests
internal/files/files_test.go
TestUserSpecificConfigDir and TestUserSpecificCacheDir replace fixed /custom/xdg/path and /custom/cache/path values with paths constructed via os.TempDir() and filepath.Join, while retaining coverage for both direct use and whitespace-trimming cases.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarises the main changes in the changeset: adding .gitattributes for EOL issues and fixing Windows unit test failures related to temporary file handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@checkinnuggets checkinnuggets force-pushed the initial-unit-test-tidyup branch from e384077 to 157e51f Compare June 9, 2026 10:56
@checkinnuggets checkinnuggets marked this pull request as ready for review June 9, 2026 10:56
@peteski22 peteski22 self-assigned this Jun 10, 2026
@checkinnuggets checkinnuggets marked this pull request as draft June 10, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants