Fix timeout handling in test_runner.py.

When a timeout occurs, the test runner tries to redirect captured output
to the original stdout. Only do this if there is captured output, as
TimeoutExpired's stdout may be set to None.

Change-Id: I919332d2581dbffcd5a6b32334e1220b908a4002
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/103376
Reviewed-by: Nigi <nigi@chromium.org>
Reviewed-by: K. Moon <kmoon@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/testing/tools/test_runner.py b/testing/tools/test_runner.py
index a065820..713812a 100644
--- a/testing/tools/test_runner.py
+++ b/testing/tools/test_runner.py
@@ -591,8 +591,9 @@
       test_result.reason = 'Command {} timed out'.format(run_result.cmd)
 
     if stdout == subprocess.PIPE and stderr == subprocess.PIPE:
-      # Copy captured standard output to the original `stdout`.
-      original_stdout.write(run_result.stdout)
+      # Copy captured standard output, if any, to the original `stdout`.
+      if run_result.stdout:
+        original_stdout.write(run_result.stdout)
 
     if not test_result.IsPass():
       # On failure, report captured output to the test log.