14 Commits

Author SHA1 Message Date
Jannick Kremer
0da291f8a6 Revert "Move python binding tests to lit framework" (#149012)
This reverts commit f8707f994af2582f6dc58190106946efeb43bf05.

(cherry picked from commit 7a9bef0166951a61bc7094514a20471ae45f6090)
2025-07-22 10:33:35 +02:00
Jannick Kremer
ec149d5ef8
[clang][python][test] Move python binding tests to lit framework (#148802)
As discussed in PR #142353, the current testsuite of the `clang` Python
bindings has several issues:

- It `libclang.so` cannot be loaded into `python` to run the testsuite,
the whole `ninja check-all` aborts.
- The result of running the testsuite isn't report like the `lit`-based
tests, rendering them almost invisible.
- The testsuite is disabled in a non-obvious way (`RUN_PYTHON_TESTS`) in
`tests/CMakeLists.txt`, which again doesn't show up in the test results.

All these issues can be avoided by integrating the Python bindings tests
with `lit`, which is what this patch does:

- The actual test lives in `clang/test/bindings/python/bindings.sh` and
is run by `lit`.
- The current `clang/bindings/python/tests` directory (minus the
now-subperfluous `CMakeLists.txt`) is moved into the same directory.
- The check if `libclang` is loadable (originally from PR #142353) is
now handled via a new `lit` feature, `libclang-loadable`.
- The various ways to disable the tests have been turned into `XFAIL`s
as appropriate. This isn't complete and not completely tested yet.

Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`,
`i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and
`x86_64-pc-linux-gnu`.

Co-authored-by: Rainer Orth <ro@gcc.gnu.org>
2025-07-15 12:48:24 +02:00
Jannick Kremer
d66254e7fe
Revert " Move python binding tests to lit framework (#146844)" (#146931)
This reverts commit 2532bde0388980ac7e299b02bc554e6fde6c686e.
2025-07-03 19:34:19 +02:00
Jannick Kremer
2532bde038
[clang][python][test] Move python binding tests to lit framework (#146844)
As discussed in PR #142353, the current testsuite of the `clang` Python
bindings has several issues:

- It `libclang.so` cannot be loaded into `python` to run the testsuite,
the whole `ninja check-all` aborts.
- The result of running the testsuite isn't report like the `lit`-based
tests, rendering them almost invisible.
- The testsuite is disabled in a non-obvious way (`RUN_PYTHON_TESTS`) in
`tests/CMakeLists.txt`, which again doesn't show up in the test results.

All these issues can be avoided by integrating the Python bindings tests
with `lit`, which is what this patch does:

- The actual test lives in `clang/test/bindings/python/bindings.sh` and
is run by `lit`.
- The current `clang/bindings/python/tests` directory (minus the
now-subperfluous `CMakeLists.txt`) is moved into the same directory.
- The check if `libclang` is loadable (originally from PR #142353) is
now handled via a new `lit` feature, `libclang-loadable`.
- The various ways to disable the tests have been turned into `XFAIL`s
as appropriate. This isn't complete and not completely tested yet.

Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`,
`i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and
`x86_64-pc-linux-gnu`.

Co-authored-by: Rainer Orth <ro@gcc.gnu.org>
2025-07-03 13:56:54 +02:00
Jannick Kremer
c863e0ebc2
Revert "Move python binding tests to lit framework (#146486)" (#146789)
This reverts commit a75587d2718f76dc53112065da36e08d04034eb9.
2025-07-02 23:41:01 +02:00
Jannick Kremer
a75587d271
[clang][python][test] Move python binding tests to lit framework (#146486)
As discussed in PR #142353, the current testsuite of the `clang` Python
bindings has several issues:

- It `libclang.so` cannot be loaded into `python` to run the testsuite,
the whole `ninja check-all` aborts.
- The result of running the testsuite isn't report like the `lit`-based
tests, rendering them almost invisible.
- The testsuite is disabled in a non-obvious way (`RUN_PYTHON_TESTS`) in
`tests/CMakeLists.txt`, which again doesn't show up in the test results.

All these issues can be avoided by integrating the Python bindings tests
with `lit`, which is what this patch does:

- The actual test lives in `clang/test/bindings/python/bindings.sh` and
is run by `lit`.
- The current `clang/bindings/python/tests` directory (minus the
now-subperfluous `CMakeLists.txt`) is moved into the same directory.
- The check if `libclang` is loadable (originally from PR #142353) is
now handled via a new `lit` feature, `libclang-loadable`.
- The various ways to disable the tests have been turned into `XFAIL`s
as appropriate. This isn't complete and not completely tested yet.

Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`,
`i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and
`x86_64-pc-linux-gnu`.

Co-authored-by: Rainer Orth <ro@gcc.gnu.org>
2025-07-02 10:11:48 +02:00
dyung
b0500f56c8
Revert "[clang][python][test] Move python binding tests to lit framework" (#145951)
Reverts llvm/llvm-project#145855

The test added is XPASS-ing on a bot:
https://lab.llvm.org/buildbot/#/builders/144/builds/28623
2025-06-26 15:02:14 -04:00
Rainer Orth
90c9cc2c98
[clang][python][test] Move python binding tests to lit framework (#145855)
As discussed in PR #142353, the current testsuite of the `clang` Python
bindings has several issues:

- If `libclang.so` cannot be loaded into `python` to run the testsuite,
the whole `ninja check-all` aborts.
- The result of running the testsuite isn't report like the `lit`-based
tests, rendering them almost invisible.
- The testsuite is disabled in a non-obvious way (`RUN_PYTHON_TESTS`) in
`tests/CMakeLists.txt`, which again doesn't show up in the test results.

All these issues can be avoided by integrating the Python bindings tests
with `lit`, which is what this patch does:

- The actual test lives in `clang/test/bindings/python/bindings.sh` and
is run by `lit`.
- The current `clang/bindings/python/tests` directory (minus the
now-superfluous `CMakeLists.txt`) is moved into the same directory.
- The check if `libclang` is loadable (originally from PR #142353) is
now handled via a new `lit` feature, `libclang-loadable`.
- The various ways to disable the tests have been turned into `XFAIL`s
as appropriate.
- AArch64 doesn't `FAIL` any longer, so no `XFAIL` is necessary.
- It keeps the `check-clang-python` target for use by the Clang Python
CI.

Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`,
`i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and
`x86_64-pc-linux-gnu`.
2025-06-26 16:34:10 +02:00
Jannick Kremer
0c359d747d
Revert "Move python binding tests to lit framework (#142948)" (#145774)
This reverts commit 7dfcced079e3e7962cbbf780ebf4a472fbf4baf3 since it
casued a buildfailure:
https://lab.llvm.org/buildbot/#/builders/46/builds/19019
2025-06-25 22:13:20 +02:00
Rainer Orth
7dfcced079
[clang][python][test] Move python binding tests to lit framework (#142948)
As discussed in PR #142353, the current testsuite of the `clang` Python
bindings has several issues:

- If `libclang.so` cannot be loaded into `python` to run the testsuite,
the whole `ninja check-all` aborts.
- The result of running the testsuite isn't report like the `lit`-based
tests, rendering them almost invisible.
- The testsuite is disabled in a non-obvious way (`RUN_PYTHON_TESTS`) in
`tests/CMakeLists.txt`, which again doesn't show up in the test results.

All these issues can be avoided by integrating the Python bindings tests
with `lit`, which is what this patch does:

- The actual test lives in `clang/test/bindings/python/bindings.sh` and
is run by `lit`.
- The current `clang/bindings/python/tests` directory (minus the
now-superfluous `CMakeLists.txt`) is moved into the same directory.
- The check if `libclang` is loadable (originally from PR #142353) is
now handled via a new `lit` feature, `libclang-loadable`.
- The various ways to disable the tests have been turned into `XFAIL`s
as appropriate. This isn't complete and not completely tested yet.
- It keeps the `check-clang-python` target for use by the Clang Python
CI.

Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`,
`i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and
`x86_64-pc-linux-gnu`.
2025-06-25 21:37:03 +02:00
Jannick Kremer
71cfa381ef
[libclang/python/tests] Clean up imports (#114409)
Sort imports using `isort`.
Remove unused imports.
Collect multiple imports from the same module into a single import
statement.
Unify import style.
2024-10-31 16:48:20 +00:00
Thomas Wucher
a972a394af
Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface (#98489)
This is a rework of patch [D10833](https://reviews.llvm.org/D10833)
previously posted on LLVM Phabricator by arthurp in 2015. It allows to
retrieve the type of binary operator via libclangs python bindings.

I did clean up the changes, removed unrelated changes and rebased the
changeset to the latest main branch. As this is my first contribution to
the LLVM project, let me know if any required tests or documentation are
missing.
2024-07-15 09:17:28 -04:00
Jannick Kremer
a4cdd94ed0
[libclang/python] Refactor enum usage (#95608)
Use Python's builtin enum class instead of writing our own.

This is preparation for passing a strict type check in PR #78114 ,
fixing 927 out of 1341 strict typing errors

---------

Co-authored-by: Jannick Kremer <jannick-kremer@gmx.de>
Co-authored-by: Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>
2024-07-12 13:03:17 +04:00
Jannick Kremer
88e42c6779
[libclang/python] Fix bugs in custom enum implementation and add tests (#95381)
Do not allow initialization of enum from negative IDs (e.g. from_id(-1)
currently produces the last known variant)
Rename duplicate enums: CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE and
TypeKind.OBJCCLASS
Add tests to cover these cases
2024-06-14 13:19:28 +04:00