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
Validates that short_paths_home is not equal to, or a subdirectory of… #5864
Conversation
…, the conan cache
This is an OK case, because we are just trying to validate that short_paths_home is not a subdirectory of the conan cache directory. If they are on separate drives then that validity condition is satisfied.
Changed function call from commonpath to commonprefix to support use on both python2 and python3 commonprefix does not raise an error if the root drives are not the same so that logic was removed.
@memsharded Can I get some guidance here? It seems like the test that is failing now is "failing correctly" according to the behavior this PR is trying to fix. Any suggestions for modifying the test to still perform the original intent but not flag the new exception logic? |
Hi @cctechwiz Yes, you are right, the test is failing correctly now. In fact that test shouldn't be there in the first place, it reads weird that allows that. I think you can take advantage of it and change the test to cover the functionality you are implementing. Try changing the test to something like: def test_config_home_short_home_dir(self):
cache_folder = os.path.join(temp_folder(), "custom")
with environment_append({"CONAN_USER_HOME_SHORT": cache_folder}):
client = TestClient(cache_folder=cache_folder)
client.run("config home", assert_error=True)
self.assertIn("cannot be a subdirectory of the conan cache", client.out) |
Probably a dumb question, but how do I run the tests locally? I'm not super familiar with python unit testing. Oh geez, nevermind. That's what I get for not remember what I read in the README. |
…e cannot be a subdirectory of the conan cache
Yes, in the Readme. I have check the jenkins logs, and I am sorry what I proposed is not right. As the exception is being launched earlier, it would be necessary to catch the exception. I'd suggest something in the line of: def test_config_home_short_home_dir(self):
cache_folder = os.path.join(temp_folder(), "custom")
with environment_append({"CONAN_USER_HOME_SHORT": cache_folder}):
with six.assertRaisesRegex(self, ConanException,
"cannot be a subdirectory of the conan cache"):
client = TestClient(cache_folder=cache_folder) remember to import six and ConanException. Sorry I am not testing it, just writing it on the fly. |
Thank you. I should have caught that. I am having some issues running the tests because it can't find my c++ compiler. I'm debugging that, so in the mean time I figured I would just let Jenkins run the tests for me. |
…tories of the cache for testing
Ok @memsharded I'm stumped again. Thanks to your advise I was able to resolve the initial failing test. I found a few other test that were failing and modified them so that the cache dir and short paths dir were different which allowed them to pass. However, I am unable to make any connection between my changes and the test that is failing now. Here's the excerpt from the Jenkins log:
Thanks again for all your help. |
I am having a look at this, not sure what it is, could be a glitch in CI (locally the test pass on my laptop). Relaunching CI. Don't worry about this, the PR is good, we'll manage. Thanks for your contribution! |
OK that's good to hear. Thank you for all your help. I was thinking that I should probably add one more test, similar to the one that throws an exception, but that uses different paths for short paths and the cache. This would test that the config files are actually written into the short path home. Would that be useful? |
Did a PR to your branch in https://github.com/cctechwiz-forks/conan/pull/1, to rebase this to latest develop. Lets see if that fixes the CI. Thanks! |
…tion Feature/short paths home validation
Ok, this is crazy, but this PR is identical to mine, and this fails, while mine is passing. Some glitch in the system is biting us. I am merging this even if CI is red, so you get the Hacktober fest attribution, and lets see what happens once merged in develop 😅 Thanks again! |
Awesome! Thank you for all your help. It has been a pleasure working with you. I look forward to making more contributions to conan. |
Changelog: Bugfix: Adds the
short_paths_home
property toConanClientConfigParser
to validate that it is not a subdirectory of the conan cache.Docs: conan-io/docs#1436
Fixes #5755
develop
branch, documenting this one.Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.