Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 57aa855

Browse files
committed
Add Rust support to the Python test harness
1 parent 7646bd5 commit 57aa855

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/Python/lldbsuite/test/decorators.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,17 @@ def is_go_missing(self):
615615
return skipTestIfFn(is_go_missing)(func)
616616

617617

618+
def skipUnlessRustInstalled(func):
619+
"""Decorate the item to skip tests when no Rust compiler is available."""
620+
621+
def is_rust_missing(self):
622+
compiler = self.getRustCompilerVersion()
623+
if not compiler:
624+
return "skipping because rust compiler not found"
625+
return None
626+
return skipTestIfFn(is_rust_missing)(func)
627+
628+
618629
def skipIfHostIncompatibleWithRemote(func):
619630
"""Decorate the item to skip tests if binaries built on this host are incompatible."""
620631

packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,18 @@ def getGoCompilerVersion(self):
13041304
return m.group(1)
13051305
return None
13061306

1307+
def getRustCompilerVersion(self):
1308+
""" Returns a string that represents the rust compiler version, or None if rust is not found.
1309+
"""
1310+
compiler = which("rustc")
1311+
if compiler:
1312+
version_output = system([[compiler, "--version"]])[0]
1313+
for line in version_output.split(os.linesep):
1314+
m = re.search('rustc ([0-9\.]+)', line)
1315+
if m:
1316+
return m.group(1)
1317+
return None
1318+
13071319
def platformIsDarwin(self):
13081320
"""Returns true if the OS triple for the selected platform is any valid apple OS"""
13091321
return lldbplatformutil.platformIsDarwin()
@@ -1575,6 +1587,11 @@ def buildGo(self):
15751587
"""
15761588
system([[which('go'), 'build -gcflags "-N -l" -o a.out main.go']])
15771589

1590+
def buildRust(self):
1591+
"""Build the default rust binary.
1592+
"""
1593+
system([[which('rustc'), '-g main.rs']])
1594+
15781595
def signBinary(self, binary_path):
15791596
if sys.platform.startswith("darwin"):
15801597
codesign_cmd = "codesign --force --sign \"%s\" %s" % (

0 commit comments

Comments
 (0)