Merge "Comment out errors encountered when running cargo test."

This commit is contained in:
Joel Galenson
2021-11-30 19:41:11 +00:00
committed by Gerrit Code Review

View File

@@ -131,6 +131,8 @@ CARGO_TEST_LIST_START_PAT = re.compile('^\s*Running (.*) \(.*\)$')
# cargo test --list output of the end of running a binary.
CARGO_TEST_LIST_END_PAT = re.compile('^(\d+) tests, (\d+) benchmarks$')
CARGO2ANDROID_RUNNING_PAT = re.compile('^### Running: .*$')
# Rust package name with suffix -d1.d2.d3(+.*)?.
VERSION_SUFFIX_PAT = re.compile(r'^(.*)-[0-9]+\.[0-9]+\.[0-9]+(?:\+.*)?$')
@@ -1140,6 +1142,7 @@ class Runner(object):
self.name_owners = {}
# Save and dump all errors from cargo to Android.bp.
self.errors = ''
self.test_errors = ''
self.setup_cargo_path()
# Default action is cargo clean, followed by build or user given actions.
if args.cargo:
@@ -1466,6 +1469,8 @@ class Runner(object):
self.append_to_bp('\n' + f.read() + '\n')
if self.errors:
self.append_to_bp('\n' + ERRORS_LINE + '\n' + self.errors)
if self.test_errors:
self.append_to_bp('\n// Errors when listing tests:\n' + self.test_errors)
return self
def add_ar_object(self, obj):
@@ -1575,6 +1580,7 @@ class Runner(object):
inf.seek(0)
prev_warning = False # true if the previous line was warning: ...
rustc_line = '' # previous line(s) matching RUSTC_VV_PAT
in_tests = False
for line in inf:
n += 1
if line.startswith('warning: '):
@@ -1597,7 +1603,12 @@ class Runner(object):
self.warning_files.add(fpath)
elif line.startswith('error: ') or line.startswith('error[E'):
if not self.args.ignore_cargo_errors:
self.errors += line
if in_tests:
self.test_errors += '// ' + line
else:
self.errors += line
elif CARGO2ANDROID_RUNNING_PAT.match(line):
in_tests = "cargo test" in line and "--list" in line
prev_warning = False
rustc_line = new_rustc
self.find_warning_owners()