[clang] [llvm] [clang][python][test] Move python binding tests to lit framework (PR #142948)

Rainer Orth via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 11 04:54:07 PDT 2025


================
@@ -0,0 +1,22 @@
+def is_libclang_loadable():
+    try:
+        sys.path.append(os.path.join(config.clang_src_dir, "bindings/python"))
+        from clang.cindex import Config
+        conf = Config()
+        Config.set_library_path(config.clang_lib_dir)
+        conf.lib
+        return True
+    except Exception as e:
+        # Benign error modes.
+        if "wrong ELF class: ELFCLASS32" in str(e):
+            return False
+        elif "No such file or directory" in str(e):
+            return False
+        # Unknown error modes.
+        else:
+            return True
----------------
rorth wrote:

I think the update addresses your concern.  I also decided to log unexpected errors from `lit.local.cfg` to avoid every developer encountering this having to add their own debug code.

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


More information about the cfe-commits mailing list