Skip to content

No default features #430

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 4 commits into
base: main
Choose a base branch
from
Open

Conversation

mhils
Copy link

@mhils mhils commented Aug 6, 2025

This PR fixes #429. I've moved uuid, chrono and strip-ansi-escapes into optional (on-by-default) features, and then made sure this configuration is tested in CI as well.

Thank you for building and maintaining quick-junit! 🍰

@mhils mhils force-pushed the no-default-features branch from a6c7961 to 733a049 Compare August 6, 2025 09:50
<flakyError type="flaky error type">flaky error description
<stackTrace>flaky stack trace</stackTrace>
<system-out>flaky system output</system-out>
<system-err>flaky system error with [34mANSI escape codes[39m</system-err>
Copy link
Author

@mhils mhils Aug 6, 2025

Choose a reason for hiding this comment

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

Without the ansi-escape feature flag, ANSI escape codes are just added to the XML. It looks like there is actually no additional escaping necessary to be valid XML (but if it were, quick-xml would take care of it).

Of course we shouldn't have unescaped ANSI codes in here, but in many cases you may know that the target application is never producing them in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting -- I think a newer version of quick-xml might be doing some filtering here.

Copy link
Member

@sunshowers sunshowers left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

[features]
default = ["timestamps", "uuids", "strip-ansi"]
timestamps = ["dep:chrono"]
uuids = ["dep:uuid", "dep:newtype-uuid"]
Copy link
Member

Choose a reason for hiding this comment

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

Let's call this feature uuid.

@@ -11,14 +11,20 @@ categories = ["encoding", "development-tools"]
edition = "2021"
rust-version = "1.70"

[features]
default = ["timestamps", "uuids", "strip-ansi"]
Copy link
Member

Choose a reason for hiding this comment

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

I'd make timestamps default and the other two non-default.

Comment on lines +743 to 744
#[cfg(feature = "strip-ansi")]
let data = strip_ansi_escapes::strip_str(data);
Copy link
Member

Choose a reason for hiding this comment

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

This isn't right -- enabling a feature shouldn't cause this kind of behavior change. Instead I'd recommend adding an alternative constructor.

Copy link
Author

@mhils mhils Aug 7, 2025

Choose a reason for hiding this comment

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

To clarify, you mean something like XmlString::escape_ansi() -> Self? XmlString::new would not do automatic stripping and consumers would use this alternative constructor if they need to strip ANSI escapes?

Copy link
Member

Choose a reason for hiding this comment

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

For backwards compatibility, I think new should retain the strip-ansi behavior, and there should be a separate constructor that only removes bytes illegal in XML without stripping ANSI codes. The latter could be called new_minimal or something. (This also suggests that the strip-ansi feature should be turned on by default.)

Oh it looks like in the loop below, it's quick-junit that's doing the filtering of illegal bytes.

<flakyError type="flaky error type">flaky error description
<stackTrace>flaky stack trace</stackTrace>
<system-out>flaky system output</system-out>
<system-err>flaky system error with [34mANSI escape codes[39m</system-err>
Copy link
Member

Choose a reason for hiding this comment

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

Interesting -- I think a newer version of quick-xml might be doing some filtering here.

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.

Move Dependencies behind feature flags?
2 participants