[llvm] [llvm][lit] fix writing results to file (PR #130845)

Ebuka Ezike via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 12 03:07:13 PDT 2025


https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/130845

>From d388b1564e4cf1feee3b9b8c77b584f157971136 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 11 Mar 2025 21:39:18 +0000
Subject: [PATCH 1/2] [llvm][lit] fix writing results to file

---
 llvm/utils/lit/lit/reports.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/lit/lit/reports.py b/llvm/utils/lit/lit/reports.py
index 8312dcddc769a..cd32f0396677c 100755
--- a/llvm/utils/lit/lit/reports.py
+++ b/llvm/utils/lit/lit/reports.py
@@ -286,7 +286,8 @@ def _write_results_to_file(self, tests, elapsed, file):
 
         json_data = {"traceEvents": events}
 
-        json.dump(json_data, time_trace_file, indent=2, sort_keys=True)
+        with open(self.output_file, "w") as time_trace_file:
+            json.dump(json_data, time_trace_file, indent=2, sort_keys=True)
 
     def _get_test_event(self, test, first_start_time):
         test_name = test.getFullName()

>From f0e0075abe5d771aa2b40f30e4183dd99e500501 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Wed, 12 Mar 2025 10:06:46 +0000
Subject: [PATCH 2/2] [llvm][lit] fix use the file in as param

---
 llvm/utils/lit/lit/reports.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/utils/lit/lit/reports.py b/llvm/utils/lit/lit/reports.py
index cd32f0396677c..1b43ab9357b37 100755
--- a/llvm/utils/lit/lit/reports.py
+++ b/llvm/utils/lit/lit/reports.py
@@ -286,8 +286,7 @@ def _write_results_to_file(self, tests, elapsed, file):
 
         json_data = {"traceEvents": events}
 
-        with open(self.output_file, "w") as time_trace_file:
-            json.dump(json_data, time_trace_file, indent=2, sort_keys=True)
+        json.dump(json_data, file, indent=2, sort_keys=True)
 
     def _get_test_event(self, test, first_start_time):
         test_name = test.getFullName()



More information about the llvm-commits mailing list