[PATCH] D141248: [Clang] [Python] Fix tests when default config file contains -include
Sam James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 8 20:33:42 PST 2023
thesamesam created this revision.
thesamesam added a reviewer: mgorny.
Herald added a subscriber: arphaman.
Herald added a project: All.
thesamesam requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
In Gentoo, we make use of Clang's recently-enhanced config file support
and add a default include to `clang` invocations using '-include ...'.
This breaks clang-python tests like so:
======================================================================
ERROR: test_includes (tests.cindex.test_translation_unit.TestTranslationUnit)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/var/tmp/portage/dev-python/clang-python-15.0.6/work/clang/bindings/python/tests/cindex/test_translation_unit.py", line 145, in test_includes
eq(i[0], i[1])
File "/var/tmp/portage/dev-python/clang-python-15.0.6/work/clang/bindings/python/tests/cindex/test_translation_unit.py", line 132, in eq
self.assert_normpaths_equal(expected[0], actual.source.name)
AttributeError: 'NoneType' object has no attribute 'name'
======================================================================
FAIL: test_inclusion_directive (tests.cindex.test_translation_unit.TestTranslationUnit)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/var/tmp/portage/dev-python/clang-python-15.0.6/work/clang/bindings/python/tests/cindex/test_translation_unit.py", line 157, in test_inclusion_directive
self.assert_normpaths_equal(i[0], i[1])
File "/var/tmp/portage/dev-python/clang-python-15.0.6/work/clang/bindings/python/tests/cindex/test_translation_unit.py", line 126, in assert_normpaths_equal
self.assertEqual(os.path.normpath(path1),
AssertionError: '/var/tmp/portage/dev-python/clang-python-1[58 chars]r1.h' != '/usr/include/gentoo/fortify.h'
- /var/tmp/portage/dev-python/clang-python-15.0.6/work/clang/bindings/python/tests/cindex/INPUTS/header1.h
+ /usr/include/gentoo/fortify.h
Disable using the default Clang configuration files on the system, like
we did for other tests.
Bug: https://bugs.gentoo.org/890204
Signed-off-by: Sam James <sam at gentoo.org>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141248
Files:
clang/bindings/python/tests/cindex/test_translation_unit.py
Index: clang/bindings/python/tests/cindex/test_translation_unit.py
===================================================================
--- clang/bindings/python/tests/cindex/test_translation_unit.py
+++ clang/bindings/python/tests/cindex/test_translation_unit.py
@@ -140,7 +140,7 @@
h3 = os.path.join(kInputsDir, "header3.h")
inc = [(src, h1), (h1, h3), (src, h2), (h2, h3)]
- tu = TranslationUnit.from_source(src)
+ tu = TranslationUnit.from_source(src, ["--no-default-config"])
for i in zip(inc, tu.get_includes()):
eq(i[0], i[1])
@@ -151,7 +151,7 @@
h3 = os.path.join(kInputsDir, "header3.h")
inc = [h1, h3, h2, h3, h1]
- tu = TranslationUnit.from_source(src, options=TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD)
+ tu = TranslationUnit.from_source(src, ["--no-default-config"], options=TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD)
inclusion_directive_files = [c.get_included_file().name for c in tu.cursor.get_children() if c.kind == CursorKind.INCLUSION_DIRECTIVE]
for i in zip(inc, inclusion_directive_files):
self.assert_normpaths_equal(i[0], i[1])
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141248.487271.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230109/29be0119/attachment.bin>
More information about the cfe-commits
mailing list