tests of bindings/python fail?

On a clean checkout + build of Clang from trunk, taken yesterday, I run:

~/test/llvm/tools/clang/bindings/python$ nosetests -v

tests.cindex.test_cursor.test_get_children … FAIL
tests.cindex.test_cursor_kind.test_name … ok
tests.cindex.test_cursor_kind.test_get_all_kinds … ok
Check that every kind classifies to exactly one group. … FAIL
tests.cindex.test_diagnostics.test_diagnostic_warning … ok
tests.cindex.test_diagnostics.test_diagnostic_note … ok
tests.cindex.test_diagnostics.test_diagnostic_fixit … ok
tests.cindex.test_diagnostics.test_diagnostic_range … ok
tests.cindex.test_index.test_create … ok
tests.cindex.test_index.test_parse … ok
tests.cindex.test_translation_unit.test_spelling … ok
tests.cindex.test_translation_unit.test_cursor … ok
tests.cindex.test_translation_unit.test_parse_arguments … ok
tests.cindex.test_translation_unit.test_reparse_arguments … ok
tests.cindex.test_translation_unit.test_unsaved_files … ok
tests.cindex.test_translation_unit.test_unsaved_files_2 … ok
tests.cindex.test_translation_unit.test_includes … FAIL

Is this something with my setup, or do others see these failures as well?

Eli

I see the same failures.

The Python bindings haven't been maintained and aren't regularly tested, so they've suffered some bit-rot.

  - Doug

Is this something with my setup, or do others see these failures as well?

I see the same failures.

The Python bindings haven’t been maintained and aren’t regularly tested, so they’ve suffered some bit-rot.

  • Doug

Hi Doug,

Is there an intention to keep them maintained, however? I.e. if I send patches, are there core devs interested enough to commit them?

Eli

Is this something with my setup, or do others see these failures as well?

I see the same failures.

The Python bindings haven’t been maintained and aren’t regularly tested, so they’ve suffered some bit-rot.

  • Doug

Hi Doug,

Is there an intention to keep them maintained, however? I.e. if I send patches, are there core devs interested enough to commit them?

We’ll happily commit patches to keep the Python bindings working.

  • Doug

We’ll happily commit patches to keep the Python bindings working.

  • Doug

I’m attaching a patch (diffed against trunk) with some fixes to the Python bindings, making its tests pass again (on Linux and Windows).

Some details of the patch:

  • Implemented a new function in libclang: clang_isAttr - it is similar to existing clang_Is* functions. Also exposed it to the Python bindings as the is_attr method of Cursor
  • Fixing TranslationUnit.get_includes to only go through the argument buffer when it contains something. This fixed a crash on Windows
  • clang_getFileName returns CXString, not char*. Made appropriate fixes in cindex.py - now the relevant tests pass and we can see the full locations correctly again (previously there was garbage in place of the file name)
  • Exposed clang_getCursorDisplayName to the python bindings

P.S. the patch file was created with ‘svn diff’ in the root of clang, so it should be applied as ‘patch -p0’ there. I hope this is an accepted way to submit patches - if something different is required, I’ll gladly fix.

Eli

pybindings_fixes.patch (6.01 KB)

We’ll happily commit patches to keep the Python bindings working.

  • Doug

I’m attaching a patch (diffed against trunk) with some fixes to the Python bindings, making its tests pass again (on Linux and Windows).

Some details of the patch:

  • Implemented a new function in libclang: clang_isAttr - it is similar to existing clang_Is* functions. Also exposed it to the Python bindings as the is_attr method of Cursor
  • Fixing TranslationUnit.get_includes to only go through the argument buffer when it contains something. This fixed a crash on Windows
  • clang_getFileName returns CXString, not char*. Made appropriate fixes in cindex.py - now the relevant tests pass and we can see the full locations correctly again (previously there was garbage in place of the file name)
  • Exposed clang_getCursorDisplayName to the python bindings

Very nice.

P.S. the patch file was created with ‘svn diff’ in the root of clang, so it should be applied as ‘patch -p0’ there. I hope this is an accepted way to submit patches - if something different is required, I’ll gladly fix.

Yes, this is the right way to submit patches, thanks for working on this!

A few minor comments:

Index: include/clang-c/Index.h

Hi Doug, thanks for the review. I’m attaching an updated patch with fixes for all your comments.

Eli

pybindings_fixes.2.patch (6.5 KB)

Committed as r134460, thanks!

I forgot to mention it before, but please send future patches to the cfe-commits mailing list.

  • Doug

Hi Doug, thanks for the review. I’m attaching an updated patch with fixes for all your comments.

Committed as r134460, thanks!

I forgot to mention it before, but please send future patches to the cfe-commits mailing list.

Thanks. Will do.
Eli

Hi Doug, thanks for the review. I’m attaching an updated patch with fixes for all your comments.

Committed as r134460, thanks!

I forgot to mention it before, but please send future patches to the cfe-commits mailing list.

  • Doug

Hi Doug,
Another related question: I would like to expose the various statement kinds in libclang, to allow client code to reason based on the type of statement it encounters. Currently none of the statement kinds (except labels) is exposed. Would it be acceptable to submit a fix for this, or is the statement kind enumeration kept intentionally minimal?
Eli

It’s fine to submit a fix for this, as long as the exposed cursor kinds map to language constructs and not Clang internal implementation details.

  • Doug