-
Notifications
You must be signed in to change notification settings - Fork 993
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
Clean repeated entries in PATH after vcvars call #3598
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -710,6 +710,38 @@ def vcvars_echo_test(self): | |
self.assertIn("Conan:vcvars already set", str(output)) | ||
self.assertIn("VS140COMNTOOLS=", str(output)) | ||
|
||
@unittest.skipUnless(platform.system() == "Windows", "Requires Windows") | ||
def vcvars_env_not_duplicated_path_test(self): | ||
"""vcvars is not looking at the current values of the env vars, with PATH it is a problem because you | ||
can already have set some of the vars and accumulate unnecessary entries.""" | ||
settings = Settings.loads(default_settings_yml) | ||
settings.os = "Windows" | ||
settings.compiler = "Visual Studio" | ||
settings.compiler.version = "15" | ||
settings.arch = "x86" | ||
settings.arch_build = "x86_64" | ||
|
||
# Set the env with a PATH containing the vcvars paths | ||
tmp = tools.vcvars_dict(settings, only_diff=False) | ||
tmp = {key.lower(): value for key, value in tmp.items()} | ||
with tools.environment_append({"path": ";".join(tmp["path"])}): | ||
previous_path = os.environ["PATH"].split(";") | ||
# Duplicate the path, inside the tools.vcvars shouldn't have repeated entries in PATH | ||
with tools.vcvars(settings): | ||
path = os.environ["PATH"].split(";") | ||
new_values = [] | ||
repeated_keys = [] | ||
for i in path: | ||
if i not in new_values: | ||
new_values.append(i) | ||
else: | ||
repeated_keys.append(i) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is working as expected. We are appending a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
for repeated in repeated_keys: | ||
if previous_path.count(repeated) < 2: | ||
# If the entry was already repeated before calling "tools.vcvars" we keep it | ||
raise AssertionError("The key '%s' was not repeated previously but now it is" % repeated) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
|
||
@unittest.skipUnless(platform.system() == "Windows", "Requires Windows") | ||
def vcvars_amd64_32_cross_building_support_test(self): | ||
# amd64_x86 crossbuilder | ||
|
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 can be just one line: