Skip to content
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 path list with whitespace #588

Merged
merged 2 commits into from
May 7, 2019

Conversation

asztalosdani
Copy link
Contributor

The packages path is split badly if a path contains whitespace.
If I set REZ_PACKAGES_PATH to c:/foo bar/baz, rez will interpret it as ["c:/foo", "bar/baz"].

This PR fixes this issue. I also made a test to prove this.

@oktomus
Copy link

oktomus commented Mar 29, 2019

You haven't committed with your github account. You can fix this by doing the following

git config user.email "github email"
git reset [hash of previous commit]
git add 
git commit "Fix path list with whitespace"
git push -f asztalosdani:master

@asztalosdani
Copy link
Contributor Author

Thank you, I fixed it.

@@ -226,6 +226,22 @@ def _data(self):
finally:
os.environ = old_environ

def test_7(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

fails on linux (pathsep is :)

@nerdvegas nerdvegas merged commit 0c7dc25 into AcademySoftwareFoundation:master May 7, 2019
"/home/foo bar/baz",
r"/home/foo\ bar/baz"
]
os.environ["REZ_PACKAGES_PATH"] = os.pathsep.join(packages_path)
Copy link

Choose a reason for hiding this comment

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

I think it is not a good idea to change an environment variable in the UT as it affects all other tests that are run as part of the same process (i.e when running rez selftests)
This line breaks a test on other unrelated area.
If you really need to, then put the original value back...something along the lines

original_packages_path = os.environ["REZ_PACKAGES_PATH"]
os.environ["REZ_PACKAGES_PATH"] = os.pathsep.join(packages_path)
self.assertEqual(c.packages_path, packages_path)
os.environ["REZ_PACKAGES_PATH"] = original_packages_path

or if you are going to use it several times create a @contextmanager and with with ...

Also, I do not understand the original use case of this change.
Why not set the path like c:/foo;c:/bar/baz or "/foo:baz/bar` why do you need the space?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed on not changing variables that persist across tests, however:

Why not set the path like c:/foo;c:/bar/baz or "/foo:baz/bar` why do you need the space?

The folder c:\foo bar\ is different from c:\foo and c:\bar I think.

Copy link

Choose a reason for hiding this comment

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

Would quotes work in this case? ie. "c:\foo bar"?

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.

5 participants