diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2012-02-05 11:41:58 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2012-02-05 11:41:58 +0000 |
commit | 9fc76f2cbf72697ddaf2a463749d19e2be5d3293 (patch) | |
tree | 8b5c1677c2db7effd97534851b84d72e5f723af6 /clang/bindings/python/tests | |
parent | fb7b4aa45a233e54711307f3d7c50a9848d5784f (diff) | |
download | bcm5719-llvm-9fc76f2cbf72697ddaf2a463749d19e2be5d3293.tar.gz bcm5719-llvm-9fc76f2cbf72697ddaf2a463749d19e2be5d3293.zip |
[clang.py] Expose diagnostic category and option info to Python binding
Contributed by: Gregory Szorc <gregory.szorc@gmail.com>
llvm-svn: 149825
Diffstat (limited to 'clang/bindings/python/tests')
-rw-r--r-- | clang/bindings/python/tests/cindex/test_diagnostics.py | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/clang/bindings/python/tests/cindex/test_diagnostics.py b/clang/bindings/python/tests/cindex/test_diagnostics.py index 98f97d3bd3b..b9872d9ce95 100644 --- a/clang/bindings/python/tests/cindex/test_diagnostics.py +++ b/clang/bindings/python/tests/cindex/test_diagnostics.py @@ -1,8 +1,13 @@ from clang.cindex import * -def tu_from_source(source): +def tu_from_source(source, all_warnings=False): + args = [] + if all_warnings: + args = ['-Wall', '-Wextra'] + index = Index.create() - tu = index.parse('INPUT.c', unsaved_files = [('INPUT.c', source)]) + tu = index.parse('INPUT.c', args=args, + unsaved_files = [('INPUT.c', source)]) return tu # FIXME: We need support for invalid translation units to test better. @@ -65,5 +70,28 @@ def test_diagnostic_range(): assert True else: assert False - + +def test_diagnostic_category(): + # Ensure that category properties work. + index = Index.create() + tu = tu_from_source("""int f(int i) { return 7; }""", all_warnings=True) + assert len(tu.diagnostics) == 1 + d = tu.diagnostics[0] + + assert d.severity == Diagnostic.Warning + assert d.location.line == 1 + assert d.location.column == 11 + + assert d.category_number == 2 + assert d.category_name == 'Semantic Issue' + +def test_diagnostic_option(): + # Ensure that category option properties work. + index = Index.create() + tu = tu_from_source("""int f(int i) { return 7; }""", all_warnings=True) + assert len(tu.diagnostics) == 1 + d = tu.diagnostics[0] + + assert d.option == '-Wunused-parameter' + assert d.disable_option == '-Wno-unused-parameter' |