-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
Improve expand_path
warnings
#687
Conversation
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 find this more-context-offering wording helpful and an improvement.
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'm not sure about this change, since to my mind both create_directory
and touch
should warn when passed absolute paths. Can you point me to a pull request or something for simplecov where I can take a closer look?
I do agree that the warning messages should be improved so that it is clearer where in the user code the problem lies.
features/04_aruba_api/filesystem/check_if_path_is_directory.feature
Outdated
Show resolved
Hide resolved
Include the exact method that was called with an absolute path in the warning message, to ease tracking what's wrong and how to fix it.
It was slightly out of date.
To more easily track down where the offending call is happening.
1c9f4ae
to
6aab02f
Compare
@mvz Since you agree with improving the messages, I removed the change fixing what I think are false positive warnings. Let's discuss the improvements in the warning message first, and then I'll open a separate PR to discuss whether all file helpers should warn or not when passed absolute paths. Sounds good? |
Looks good, thanks! |
And thanks for trying out the 1.0.0 pre-release, @deivid-rodriguez! |
No problem! I investigated a bit more the warnings I'm getting and I tracked them down to using the This seems currently hard to track down (even with the improvements in this PR) because it's not the end user code that calls $ bundle exec cucumber
Using the default profile...
............................2020-01-02 11:53:16 +0100 WARN: Using absolute paths in aruba at /home/deivid/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/aruba-1.0.0.pre.alpha.5/lib/aruba/api/filesystem.rb:38. Using absolute paths in Aruba is not recommended. Set config.allow_absolute_paths = true to silence this warning
2020-01-02 11:53:16 +0100 WARN: Using absolute paths in aruba at /home/deivid/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/aruba-1.0.0.pre.alpha.5/lib/aruba/api/filesystem.rb:30. Using absolute paths in Aruba is not recommended. Set config.allow_absolute_paths = true to silence this warning
2020-01-02 11:53:16 +0100 WARN: Using absolute paths in aruba at /home/deivid/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/aruba-1.0.0.pre.alpha.5/lib/aruba/api/filesystem.rb:30. Using absolute paths in Aruba is not recommended. Set config.allow_absolute_paths = true to silence this warning
..................................................................................................................................................................................................................................................................
55 scenarios (55 passed)
286 steps (286 passed)
0m56.172s Better than before, because it gives me a place to start looking, but still not very user friendly. If you really want to fix this for end users, I think that would involve showing proper warnings with proper user code locations for every end user file method, step or matcher being called with an absolute path argument, and then silencing any other warnings that might be triggered internally during its execution. But, I would honestly remove the warning. The original issue where the problem being fixed here was reported is #478 (not sure if you got other related problems reported over time). The scenario mentioned in the ticket is exactly the same scenario in simplecov that it's throwing the warning for me now. In this case, I consider our scenario perfectly fine, so my solution (now that I know what's happening) will be the But still, if the only problem you've been reported is considered as a false positive, it seems plausible to think that many other users will consider their cases as false positives too, so it seems questionable to warn everybody's code in exchange for protecting from potential bugs. But might be missing context, of course. Hope this helps! |
Also, if you go the "warn everything" way, the Lines 129 to 133 in c2fed66
without mentioning that it warns. |
I opened #691 to improve the message further. |
Summary
My changes improve the warnings printed when passing an absolute path to aruba's
expand_path
, and also suppress several warnings originated from aruba's own helpers, not from end user's code.Details
This PR improves warnings like this:
to instead read as
The new warning message is better because it gives information about:
In addition, this method prevents several
aruba
helpers from callingexpand_path
with absolute paths, and thus removes several warnings that would be printed to end users otherwise, without really being in control of fixing them (other than by creating a PR similar to this one :)).Motivation and Context
These changes were motivated because I tried to upgrade to latest aruba 1.0.0 pre-release to be able to use #675 in simplecov's specs, and I started seeing several of these warnings. I had no clue on how I should proceed to fix them so I investigated.
I hope this will help other users by either removing "false positive warnings" or by giving better warning messages when they are actually "true positives".
How Has This Been Tested?
I added several tests, and also made sure that warnings are no longer printed during simplecov specs after these changes.
Screenshots (if appropriate):
Types of changes
Checklist: