Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 0a642db

Browse files
committed
Add Rust support to the Python test harness
1 parent e8ba344 commit 0a642db

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/Python/lldbsuite/test/decorators.py

+11
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,17 @@ def skipUnlessDarwin(func):
600600
return skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples())(func)
601601

602602

603+
def skipUnlessRustInstalled(func):
604+
"""Decorate the item to skip tests when no Rust compiler is available."""
605+
606+
def is_rust_missing(self):
607+
compiler = self.getRustCompilerVersion()
608+
if not compiler:
609+
return "skipping because rust compiler not found"
610+
return None
611+
return skipTestIfFn(is_rust_missing)(func)
612+
613+
603614
def skipIfHostIncompatibleWithRemote(func):
604615
"""Decorate the item to skip tests if binaries built on this host are incompatible."""
605616

packages/Python/lldbsuite/test/lldbtest.py

+17
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,18 @@ def getCompilerVersion(self):
13071307
version = m.group(1)
13081308
return version
13091309

1310+
def getRustCompilerVersion(self):
1311+
""" Returns a string that represents the rust compiler version, or None if rust is not found.
1312+
"""
1313+
compiler = which("rustc")
1314+
if compiler:
1315+
version_output = system([[compiler, "--version"]])[0]
1316+
for line in version_output.split(os.linesep):
1317+
m = re.search('rustc ([0-9\.]+)', line)
1318+
if m:
1319+
return m.group(1)
1320+
return None
1321+
13101322
def platformIsDarwin(self):
13111323
"""Returns true if the OS triple for the selected platform is any valid apple OS"""
13121324
return lldbplatformutil.platformIsDarwin()
@@ -1575,6 +1587,11 @@ def buildGModules(
15751587
dictionary, testdir, testname):
15761588
raise Exception("Don't know how to build binary with gmodules")
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)