Merge "Comment out errors encountered when running cargo test." am: b5b71540cc

Original change: https://android-review.googlesource.com/c/platform/development/+/1906753

Change-Id: Ie959e4b9d1f5ea9e9d10a05d500a484875475d0d
This commit is contained in:
Joel Galenson
2021-11-30 20:03:16 +00:00
committed by Automerger Merge Worker

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