[llvm] [CI] Add Support for Parsing Ninja Logs to generate_test_report_lib (PR #152620)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 06:52:59 PDT 2025


================
@@ -12,6 +12,57 @@
     "https://github.com/llvm/llvm-project/issues and add the "
     "`infrastructure` label."
 )
+# The maximum number of lines to pull from a ninja failure.
+NINJA_LOG_SIZE_THRESHOLD = 500
+
+
+def _parse_ninja_log(ninja_log: list[str]) -> list[tuple[str, str]]:
+    """Parses an individual ninja log."""
+    failures = []
+    index = 0
+    while index < len(ninja_log):
+        while index < len(ninja_log) and not ninja_log[index].startswith("FAILED:"):
+            index += 1
+        if index == len(ninja_log):
+            # We hit the end of the log without finding a build failure, go to
+            # the next log.
+            return failures
+        failing_action = ninja_log[index - 1].split("] ")[1]
----------------
boomanaiden154 wrote:

It looks more like this:
```
[4/5] test/4.stamp
FAILED: touch test/4.stamp
touch test/4.stamp
```

Index points to the line with `Failed:` on it. We also want to get the pretty printed name of the target rather than just the command, so we look at the line above (the progress indicator) and get rid of the progress information.

Added a comment to clarify things at least a bit.

https://github.com/llvm/llvm-project/pull/152620


More information about the llvm-commits mailing list