DebugSymbols: materialize output of GatherSymbolFiles.
Ensure all symbol file processing is done, which will copy all
symbol files and return the full list.
Resolves error of calling 'len' on generator function.
For example, doing this (where real args are supplied
instead of ...):
sym_file_list = artifacts.GatherSymbolFiles(...)
instead of this:
sym_file_list = list(artifacts.GatherSymbolFiles(...))
results in:
TypeError: object of type 'generator' has no len()
Found by using
'bb -add' to turn on the DebugSymbols collection on staging builder.
but updates artifacts_unittest.py to verify and fix.
BUG=chromium:1031380
TEST=./run_pytest api/controller/artifacts_unittest.py
Change-Id: I0d2f84aef3231867415a720852fc1be872a6b0a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2818965
Tested-by: Michael Mortensen <mmortensen@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Michael Mortensen <mmortensen@google.com>
diff --git a/api/controller/artifacts.py b/api/controller/artifacts.py
index 5c81396..fefc172 100644
--- a/api/controller/artifacts.py
+++ b/api/controller/artifacts.py
@@ -713,10 +713,13 @@
with chroot.tempdir() as symbol_tmpdir, chroot.tempdir() as dest_tmpdir:
breakpad_dir = os.path.join('/build', build_target.name,
'usr/lib/debug/breakpad')
- sym_file_list = artifacts.GatherSymbolFiles(tempdir=symbol_tmpdir,
- destdir=dest_tmpdir,
- paths=[breakpad_dir])
- if len(sym_file_list) == 0:
+ # Call list on the atifacts.GatherSymbolFiles generator function to
+ # materialize and consume all entries so that all are copied to
+ # dest dir and complete list of all symbol files is returned.
+ sym_file_list = list(artifacts.GatherSymbolFiles(tempdir=symbol_tmpdir,
+ destdir=dest_tmpdir,
+ paths=[breakpad_dir]))
+ if not sym_file_list:
logging.warning('No sym files found in %s.', breakpad_dir)
# Create tarball from destination_tmp, then copy it...
tarball_path = os.path.join(output_dir, constants.DEBUG_SYMBOLS_TAR)