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

[tests] Do not trim from PATH if we did not append to it; Clean up/fix shebangs in scripts #1233

Merged
merged 3 commits into from
Nov 13, 2020
Merged

Conversation

jleveque
Copy link
Contributor

@jleveque jleveque commented Nov 12, 2020

- What I did

Some tests were trimming the last item from system PATH, but they never appended anything to it, thus these tests were trimming valid entries from the tail of the system path, which in turn caused scripts with shebangs like #!/usr/bin/env python to fail, because once /usr/bin was removed from PATH, python could not be found.

- How I did it

  • Remove lines which trimmed the last entry from system PATH in the teardown function if nothing was appended to PATH in the setup method.
  • Remove shebangs from non-executable Python files
  • Fix shebangs which had a space in them
  • Replace #!/usr/bin/python shebangs with the preferred, more portable #!/usr/bin/env python in executable scripts

- How to verify it

Ensure scripts with #!/usr/bin/env python shebangs execute properly in pytests.

- Previous command output (if the output of a command-line utility has changed)

- New command output (if the output of a command-line utility has changed)

@neethajohn
Copy link
Contributor

Thank you so much Joe for root causing this and fixing!

neethajohn
neethajohn previously approved these changes Nov 12, 2020
@jleveque
Copy link
Contributor Author

You're welcome, @neethajohn! If the tests pass, I think I will update this PR again and change all shebangs in the repo. Not only is the the preferred shebang, if all scripts use it and this issue arises again, we might be able to catch it sooner.

@jleveque jleveque changed the title [tests] Do not trim from PATH if we did not append to it [tests] Do not trim from PATH if we did not append to it; Clean up/fix shebangs Nov 13, 2020
@jleveque jleveque changed the title [tests] Do not trim from PATH if we did not append to it; Clean up/fix shebangs [tests] Do not trim from PATH if we did not append to it; Clean up/fix shebangs in scripts Nov 13, 2020
@jleveque jleveque merged commit 71aa221 into sonic-net:master Nov 13, 2020
@jleveque jleveque deleted the fix_path_tests branch November 13, 2020 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants