[llvm] [mlir] [CMake] add SKIP to add_lit_testsuites (PR #157176)

Maksim Levental via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 5 14:02:30 PDT 2025


https://github.com/makslevental created https://github.com/llvm/llvm-project/pull/157176

This PR adds `SKIP` to `add_lit_testsuites`. The purpose is to let people filter the current exhaustive inclusion of subdirectories which might not all depend on the same `DEPENDS`. The immediate usecase is MLIR where we have a collection of Python tests that currently trigger rebuilds of various tools (like `mlir-opt`) which they do not depend on. That collection of tests is updated here too.

>From 794d4c841e5b605ac4123333c6565aa5183dab5c Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Fri, 5 Sep 2025 13:59:00 -0700
Subject: [PATCH] [CMake] add SKIP to add_lit_testsuites

---
 llvm/cmake/modules/AddLLVM.cmake | 14 +++++++++++++-
 mlir/test/CMakeLists.txt         |  1 +
 mlir/test/python/CMakeLists.txt  |  5 +++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 835750e2d2a13..9058ed3831b9c 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2192,7 +2192,7 @@ endfunction()
 
 function(add_lit_testsuites project directory)
   if (NOT LLVM_ENABLE_IDE)
-    cmake_parse_arguments(ARG "EXCLUDE_FROM_CHECK_ALL" "FOLDER;BINARY_DIR" "PARAMS;DEPENDS;ARGS" ${ARGN})
+    cmake_parse_arguments(ARG "EXCLUDE_FROM_CHECK_ALL" "FOLDER;BINARY_DIR" "PARAMS;DEPENDS;ARGS;SKIP" ${ARGN})
 
     if (NOT ARG_FOLDER)
       get_subproject_title(subproject_title)
@@ -2208,6 +2208,18 @@ function(add_lit_testsuites project directory)
       endif()
       string(FIND ${lit_suite} Inputs is_inputs)
       string(FIND ${lit_suite} Output is_output)
+      set(_should_skip FALSE)
+      foreach(skip ${ARG_SKIP})
+        string(FIND ${lit_suite} ${skip} is_skip)
+        if (NOT is_skip EQUAL -1)
+          set(_should_skip TRUE)
+          break()
+        endif()
+      endforeach()
+      if (_should_skip)
+        continue()
+      endif()
+      string(FIND ${lit_suite} Output is_output)
       if (NOT (is_inputs EQUAL -1 AND is_output EQUAL -1))
         continue()
       endif()
diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt
index 8ddc620ae33be..c415e65043d0f 100644
--- a/mlir/test/CMakeLists.txt
+++ b/mlir/test/CMakeLists.txt
@@ -247,4 +247,5 @@ add_lit_testsuite(check-mlir "Running the MLIR regression tests"
 
 add_lit_testsuites(MLIR ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${MLIR_TEST_DEPENDS}
+  SKIP python
 )
diff --git a/mlir/test/python/CMakeLists.txt b/mlir/test/python/CMakeLists.txt
index 1db957c86819d..b1d126754517f 100644
--- a/mlir/test/python/CMakeLists.txt
+++ b/mlir/test/python/CMakeLists.txt
@@ -10,3 +10,8 @@ mlir_tablegen(lib/PythonTestTypes.cpp.inc -gen-typedef-defs)
 add_public_tablegen_target(MLIRPythonTestIncGen)
 
 add_subdirectory(lib)
+
+add_lit_testsuite(check-mlir-python "Running the MLIR Python regression tests"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  DEPENDS MLIRPythonModules
+)
\ No newline at end of file



More information about the llvm-commits mailing list