Skip to content

[Python3] Use correct Python version for LLDB-related tests #33181

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

Merged
merged 4 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion test/Runtime/linux-fatal-backtrace.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -o %t/a.out
// RUN: %{python} %S/../Inputs/not.py "%target-run %t/a.out" 2>&1 | PYTHONPATH=%lldb-python-path %{python} %utils/symbolicate-linux-fatal %t/a.out - | %{python} %utils/backtrace-check -u
// RUN: %{python} %S/../Inputs/not.py "%target-run %t/a.out" 2>&1 | %{lldb-python} %utils/symbolicate-linux-fatal %t/a.out - | %{python} %utils/backtrace-check -u
// REQUIRES: executable_test
// REQUIRES: OS=linux-gnu
// REQUIRES: lldb
Expand Down
17 changes: 15 additions & 2 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def get_lldb_python_path(lldb_build_root):
return None
return subprocess.check_output([lldb_path, "-P"]).rstrip().decode('utf-8')

def get_lldb_python_from_path(lldb_path):
for c in lldb_path.split('/'):
if re.match('^python[23].[0-9][0-9]*$', c):
return c
return None

###

# Check that the object root is known.
Expand Down Expand Up @@ -1953,8 +1959,15 @@ if config.lldb_build_root != "":
Specified lldb_build_root, but could not find lldb in that build root
""")
else:
config.available_features.add('lldb')
config.substitutions.append(('%lldb-python-path', lldb_python_path))
lldb_python = get_lldb_python_from_path(lldb_python_path)
if lldb_python == None:
lit_config.warning("""
Unable to determine python version from LLDB Python path %s
""" % lldb_python_path)
else:
config.available_features.add('lldb')
config.substitutions.append(('%lldb-python-path', lldb_python_path))
config.substitutions.append(('%{lldb-python}', 'PYTHONPATH=%s %s' % (lldb_python_path, lldb_python)))

# Disable randomized hash seeding by default. Tests need to manually opt in to
# random seeds by unsetting the SWIFT_DETERMINISTIC_HASHING environment
Expand Down