-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Fix tests failing without the fancy feature #89
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right thing to do. If someone were to copy-paste this snippet, they would be conditionalizing their set_hook based on their own
fancy
feature, notmiette
's.I think the fix for this is trickier than we're thinking and tbh I'm not opposed to the fix being "tests don't work without --all-features"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I'm not sure about this, since I don't think theres a better way to fix this error, but on the other hand I also think it'd be great if tests would pass regardless of the feature flags. Maybe we could add a comment explaining that the attribute is only there so tests pass? If you don't think this needs to be changed, feel free to close the issue and PR :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also ran into this error. One way to do it is to remove the
#[cfg(feature = "fancy")]
in lib.rsand to spread it in
handler.rs
to have a MietteHandlerOpts available without thefancy
feature and be able to configure thefooter
andcontext_lines
when building aNarratableReportHandler
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a better idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like that implementation would require a bunch of changes around miette. I'm also not sure how clean that would be, as it would require about 16 cfg attributes in handler.rs. Also, we'd probably have to make some dependencies that are currently only needed on the fancy feature be always required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some ways that may lead to less cfg attributes:
pub(crate)
from the members ofMietteHandlerOpts
impl MietteHandlerOpts
with on one sidefooter
andcontext_lines
and the other one guarded by a#[cfg(feature = "fancy")]
build
:build_narrated
and abuild_graphical
functions. The second one going in the guarded impl blocbuild
in 2 impl blocks one guarded and one whenfancy
is not active that calls the 2 new functionsMietteHandlerOpts
just be a facade.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LordMZTE do you still work on this one ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I'm not sure how to continue with this, or if this is something we should even worry about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would hide the
cfg
attribute in the generated documentation, avoiding the copy/paste issue. Still results in the test being silently ignored when thefancy
feature isn't enabled, which I'm not sure is desirable, sinceset_hook
is available either way.If we go the route of "tests don't work without --all-features" , it would be nice if there was a clearer indication of why the tests are failing. When I first started looking at this project, I was definitely confused by the failing tests, and it took a bit to find the relevant part in
CONTRIBUTING.md
that explained it.Something like this: