diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index ae7899e47ee9bc23ff9daa0b50f7204f45b35e08..c78a120fc6569510842a59bab8999dea14fc6646 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -844,6 +844,7 @@ def _build_and_run(
                  for _ in range(0, args.antagonists)]
   port_server_port = 32767
   _start_port_server(port_server_port)
+  resultset = None
   try:
     infinite_runs = runs_per_test == 0
     one_run = set(
@@ -889,7 +890,7 @@ def _build_and_run(
   finally:
     for antagonist in antagonists:
       antagonist.kill()
-    if xml_report:
+    if xml_report and resultset:
       report_utils.render_xml_report(resultset, xml_report)
 
   number_failures, _ = jobset.run(