Completed
Pull Request — master (#1106)
by Lasse
01:50
created

bears.tests.c_languages.skip_test()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 6
rs 9.4286
1
import sys
2
import unittest
3
4
sys.path.insert(0, ".")
5
from bears.tests.LocalBearTestHelper import generate_local_bear_test
6
from bears.c_languages.ClangBear import ClangBear
7
from clang.cindex import Index, LibclangError
8
9
10
ClangBearTest = generate_local_bear_test(
11
    ClangBear,
12
    (["int main() {}"], ),
13
    (["bad things, this is no C code"],  # Has no fixit
14
     ["struct { int f0; } x = { f0 :1 };"],  # Has a fixit and no range
15
     ["int main() {int *b; return b}"]),  # Has a fixit and a range
16
    'test.c')
17
18
19
ClangBearIgnoreTest = generate_local_bear_test(
20
    ClangBear,
21
    # Should ignore the warning, valid!
22
    (["struct { int f0; } x = { f0 :1 };"],),
23
    (),
24
    'test.c',
25
    settings={'clang_cli_options': '-w'})
26
27
28
def skip_test():
29
    try:
30
        Index.create()
31
        return False
32
    except LibclangError as error:
33
        return str(error)
34
35
36
if __name__ == '__main__':
37
    unittest.main(verbosity=2)
38