@@ -259,8 +259,8 @@ def setup_testbed():
259
259
f"{ temp_dir } /{ outer_jar } " , "gradle-wrapper.jar" ])
260
260
261
261
262
- # run_testbed will build the app automatically, but it hides the Gradle output
263
- # by default, so it's useful to have this as a separate command for the buildbot .
262
+ # run_testbed will build the app automatically, but it's useful to have this as
263
+ # a separate command to allow running the app outside of this script .
264
264
def build_testbed (context ):
265
265
setup_sdk ()
266
266
setup_testbed ()
@@ -376,6 +376,8 @@ async def find_pid(serial):
376
376
shown_error = False
377
377
while True :
378
378
try :
379
+ # `pidof` requires API level 24 or higher. The level 23 emulator
380
+ # includes it, but it doesn't work (it returns all processes).
379
381
pid = (await async_check_output (
380
382
adb , "-s" , serial , "shell" , "pidof" , "-s" , APP_ID
381
383
)).strip ()
@@ -407,6 +409,7 @@ async def logcat_task(context, initial_devices):
407
409
serial = await wait_for (find_device (context , initial_devices ), startup_timeout )
408
410
pid = await wait_for (find_pid (serial ), startup_timeout )
409
411
412
+ # `--pid` requires API level 24 or higher.
410
413
args = [adb , "-s" , serial , "logcat" , "--pid" , pid , "--format" , "tag" ]
411
414
hidden_output = []
412
415
async with async_process (
@@ -421,11 +424,15 @@ async def logcat_task(context, initial_devices):
421
424
# such messages, but other components might.
422
425
level , message = None , line
423
426
427
+ # Exclude high-volume messages which are rarely useful.
428
+ if context .verbose < 2 and "from python test_syslog" in message :
429
+ continue
430
+
424
431
# Put high-level messages on stderr so they're highlighted in the
425
432
# buildbot logs. This will include Python's own stderr.
426
433
stream = (
427
434
sys .stderr
428
- if level in ["E" , "F" ] # ERROR and FATAL (aka ASSERT)
435
+ if level in ["W" , " E" , "F" ] # WARNING, ERROR, FATAL (aka ASSERT)
429
436
else sys .stdout
430
437
)
431
438
@@ -573,8 +580,9 @@ def parse_args():
573
580
test = subcommands .add_parser (
574
581
"test" , help = "Run the test suite" )
575
582
test .add_argument (
576
- "-v" , "--verbose" , action = "store_true" ,
577
- help = "Show Gradle output, and non-Python logcat messages" )
583
+ "-v" , "--verbose" , action = "count" , default = 0 ,
584
+ help = "Show Gradle output, and non-Python logcat messages. "
585
+ "Use twice to include high-volume messages which are rarely useful." )
578
586
device_group = test .add_mutually_exclusive_group (required = True )
579
587
device_group .add_argument (
580
588
"--connected" , metavar = "SERIAL" , help = "Run on a connected device. "
@@ -591,6 +599,13 @@ def parse_args():
591
599
592
600
def main ():
593
601
install_signal_handler ()
602
+
603
+ # Under the buildbot, stdout is not a TTY, but we must still flush after
604
+ # every line to make sure our output appears in the correct order relative
605
+ # to the output of our subprocesses.
606
+ for stream in [sys .stdout , sys .stderr ]:
607
+ stream .reconfigure (line_buffering = True )
608
+
594
609
context = parse_args ()
595
610
dispatch = {"configure-build" : configure_build_python ,
596
611
"make-build" : make_build_python ,
0 commit comments