Skip to content

Fix failed test on Windows#15538

Merged
subhramit merged 4 commits intoJabRef:mainfrom
pluto-han:fix-failed-test
Apr 16, 2026
Merged

Fix failed test on Windows#15538
subhramit merged 4 commits intoJabRef:mainfrom
pluto-han:fix-failed-test

Conversation

@pluto-han
Copy link
Copy Markdown
Contributor

@pluto-han pluto-han commented Apr 13, 2026

Related issues and pull requests

Closes #15537

PR Description

Add linebreak unifier to method in RelatedWorkInserterTest.

Steps to test

On Windows, run test insertMatchedRelatedWorkAppendsToExistingUserSpecificCommentField in RelatedWorkInserterTest, it should pass now.

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • [/] I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • [/] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Fix Windows test failure with unified line breaks

🐞 Bug fix 🧪 Tests

Grey Divider

Walkthroughs

Description
• Replace OS-specific newline constant with unified line break handling
• Use StringUtil.unifyLineBreaks() for cross-platform test compatibility
• Fix Windows test failure in RelatedWorkInserterTest
Diagram
flowchart LR
  A["OS.NEWLINE constant"] -- "replace with" --> B["StringUtil.unifyLineBreaks()"]
  B -- "ensures" --> C["Cross-platform compatibility"]
  C -- "fixes" --> D["Windows test failure"]
Loading

Grey Divider

File Changes

1. jablib/src/test/java/org/jabref/logic/relatedwork/RelatedWorkInserterTest.java 🐞 Bug fix +2/-2

Replace OS newline constant with unified line breaks

• Changed import from OS to StringUtil for line break handling
• Replaced OS.NEWLINE constant with StringUtil.unifyLineBreaks() method call
• Added .stripTrailing() to remove trailing whitespace before unification
• Explicitly use \n character for consistent line break representation

jablib/src/test/java/org/jabref/logic/relatedwork/RelatedWorkInserterTest.java


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

qodo-free-for-open-source-projects bot commented Apr 13, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@github-actions github-actions bot added good first issue An issue intended for project-newcomers. Varies in difficulty. status: no-bot-comments labels Apr 13, 2026
koppor
koppor previously requested changes Apr 13, 2026

assertInstanceOf(RelatedWorkInsertionResult.Inserted.class, insertionResults.getFirst());
assertEquals("[test]: blahblah" + OS.NEWLINE + OS.NEWLINE + "[LunaOstos_2024]: Colombia is a middle-income country with a population of approximately 50 million.",
assertEquals(StringUtil.unifyLineBreaks("[test]: blahblah".stripTrailing(), "\n") + "\n\n" + "[LunaOstos_2024]: Colombia is a middle-income country with a population of approximately 50 million.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why double (!) changes

  • Use \n instead of OS.NEWLINE
  • Unify linebreaks at tests

I think, the first one is enough to do.

If BOTH is needed, there should be a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the confusion arises from a prior discussion #15316 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. In #15316 (comment), my thought is that we should first normalize the linebreak at the end of the sentence, before adding new linebreaks, so I use unifyLineBreaks.

In this test, I think we don't need unifyLineBreaks because the sentences contain no linebreaks. But I am not sure if we should also remove unifyLineBreaks in RelatedWorkInserter.

@calixtus
Copy link
Copy Markdown
Member

Move fast, break things, and fix them later.

calixtus
calixtus previously approved these changes Apr 16, 2026
@subhramit
Copy link
Copy Markdown
Member

You ticked that you modified CHANGELOG.md, but no new entry was found there.

If you made changes that are visible to the user, please add a brief description along with the issue number to the CHANGELOG.md file. If you did not, please replace the cross ([x]) by a slash ([/]) to indicate that no CHANGELOG.md entry is necessary. More details can be found in our Developer Documentation about the changelog.

false alarm

@subhramit
Copy link
Copy Markdown
Member

subhramit commented Apr 16, 2026

We don't normalize in tests, hence the commit 1337303

Edit (for addition to original context) - it might be the case that JavaFX normalizes to \n as pointed out in #15316 (comment), but there is no harm in keeping the backend logic more general/independent.

@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete status: no-bot-comments and removed status: no-bot-comments status: changes-required Pull requests that are not yet complete labels Apr 16, 2026
@subhramit subhramit disabled auto-merge April 16, 2026 08:21
@calixtus calixtus dismissed koppor’s stale review April 16, 2026 10:55

Issue tracked for follow up.

@calixtus calixtus added this pull request to the merge queue Apr 16, 2026
@github-actions github-actions bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Apr 16, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 16, 2026
@subhramit subhramit added this pull request to the merge queue Apr 16, 2026
Merged via the queue into JabRef:main with commit 69f0a94 Apr 16, 2026
52 checks passed
@pluto-han
Copy link
Copy Markdown
Contributor Author

Sorry for being inactive, just finished the last exam.

Should I make a follow-up PR to fix problems in #15538 (comment)?

@subhramit
Copy link
Copy Markdown
Member

We don't normalize in tests, hence the commit 1337303

Edit (for addition to original context) - it might be the case that JavaFX normalizes to \n as pointed out in #15316 (comment), but there is no harm in keeping the backend logic more general/independent.

@pluto-han I think the above^ justifies this PR as the fix? Do you have anything else in mind?

@pluto-han
Copy link
Copy Markdown
Contributor Author

I think the above^ justifies this PR as the fix?

Yep I think then we can keep this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue An issue intended for project-newcomers. Varies in difficulty. status: no-bot-comments status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix failing Windows tests

4 participants