[llvm] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

Joel E. Denny via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 4 12:30:14 PDT 2023


================
@@ -2115,10 +2100,35 @@ def parseIntegratedTestScript(test, additional_parsers=[], require_script=True):
 
 def _runShTest(test, litConfig, useExternalSh, script, tmpBase):
     def runOnce(execdir):
+        # Set unique LLVM_PROFILE_FILE for each run command
+        if litConfig.per_test_coverage:
+            # Extract the test case name from the test object, and remove the
+            # file extension.
+            test_case_name = test.path_in_suite[-1]
+            test_case_name = test_case_name.rsplit(".", 1)[0]
+            coverage_index = 0  # Counter for coverage file index
+            scriptProf = []
+            for ln in script:
+                match = re.match(kPdbgRegex, ln)
+                if match:
+                    dbg = match.group(1)
+                    command = match.group(2)
+                else:
+                    command = ln
+                profile = f"{test_case_name}{coverage_index}.profraw"
+                coverage_index += 1
+                command = f"export LLVM_PROFILE_FILE={profile} && {command}"
+                if match:
+                    command = buildPdbgCommand(dbg, command)
----------------
jdenny-ornl wrote:

In case it's not clear, `%dbg` is normally used in lit.  It produces the `RUN: at line N` info.

It's the windows `cmd` use case that appears to be uncommon (or non-existent now), and `%dbg` was broken for that case.  I think that case will be checked by `execute_external=True` tests in lit's test suite... if anyone actually runs lit's test suite such that the external shell is windows `cmd`.

Even if we eliminate support for windows `cmd` as a lit external shell, I think this patch will live on in some form to remove unreachable `%dbg` expansion code and to support `--per-test-coverage` with lit's internal shell.  With that in mind, I added a commit to extend test coverage for `%dbg` behavior when `--per-test-coverage` is used.

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


More information about the llvm-commits mailing list