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

[noetic] wrap rostest call to add python pointing to sys.executable in PATH #1879

Merged
merged 5 commits into from
Feb 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion tools/rostest/scripts/rostest
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,30 @@

from rostest import rostestmain

rostestmain()
import os
import sys
import tempfile


class PythonPathOverride:
"""Replace python so test scripts with unmodified shebangs use correct python version."""

def __enter__(self):
# skip this hack on windows
if 'nt' == os.name:
return

self.dir = tempfile.TemporaryDirectory(prefix="rostest_bin_hook")
os.symlink(os.path.abspath(sys.executable), os.path.join(self.dir.name, "python"))
dirk-thomas marked this conversation as resolved.
Show resolved Hide resolved
os.environ['PATH'] = self.dir.name + ":" + os.environ['PATH']

def __exit__(self, t, v, tb):
# skip this hack on windows
if 'nt' == os.name:
return

self.dir.cleanup()


with PythonPathOverride():
rostestmain()