Skip to content

Fix flaky test in ScalaXmlSuite by properly handling XML special characters #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shivamsingh8883
Copy link

Issue

Fixes #88 - Flaky test in ScalaXmlSuite

Explanation

While investigating the flaky test behavior in ScalaXmlSuite, I found that the genText function in generators.scala wasn't handling XML special characters according to the XML 1.0 specification. This led to abnormal test behavior when special characters like "&" and "<" were present in the generated text.

Proposed Solution

The fix involves proper XML character escaping in the genText function:

  1. Replace "&" with "&"
  2. Replace "<" with "<"
  3. Maintain the original Gen[Text] return type for compatibility
  4. Follow XML 1.0 specification guidelines for character escaping

This change ensures that:

  1. Generated XML remains valid
  2. Special characters are preserved correctly
  3. Roundtrip serialization works properly
  4. Existing functionality is working

Testing

The changes have been tested to ensure:

  1. Valid XML generation
  2. Proper handling of special characters
  3. No regression in existing functionality
  4. Improved test stability

Questions for Review

I am eager to get feedback on:

  1. Does this approach align with the project's XML handling standards
  2. If there are any additional test cases we should consider
  3. Any suggestions for improving the implementation

Thank you for taking the time to review this PR

@ybasket
Copy link
Contributor

ybasket commented Apr 5, 2025

@shivamsingh8883 This approach has been tried 3 years ago already without success, see 62bd45b. Unfortunately, it is not as simple due to scala-xml's quirks.

As the PR description sounds like it was generated by AI, please note that we do not want AI-generated PRs. For me, it would be acceptable to use AI for some assistance (like wording, auto-complete or to understand the existing code), but not to generate whole PR descriptions nor the code changes themselves – I don't want to review AI code that doesn't work. This is especially true for GSoC – either you learn Scala yourself and dig into the problems to understand and solve them properly (with all the help we can provide as mentors) OR please do not apply for the http4s-fs2-data project.

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.

Flaky ScalaXmlSuite
2 participants