-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathtest_source_reader.py
50 lines (38 loc) · 1.59 KB
/
test_source_reader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright 2014-2017 Insight Software Consortium.
# Copyright 2004-2009 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt
import platform
import os
import pytest
from . import autoconfig
from pygccxml import parser
from pygccxml import declarations
TEST_FILES = [
'declarations_calldef.hpp'
]
@pytest.fixture
def global_ns():
COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE
config = autoconfig.cxx_parsers_cfg.config.clone()
if platform.system() == "Darwin":
config.cflags = "-Dat_quick_exit=atexit -Dquick_exit=exit"
# https://fr.mathworks.com/matlabcentral/answers/2013982-clibgen-generatelibrarydefinition-error-the-global-scope-has-no-quick_exit-on-mac-m2#answer_1439856
# https://github.com/jetbrains/kotlin/commit/d50f585911dedec5723213da8835707ac95e1c01
decls = parser.parse(TEST_FILES, config, COMPILATION_MODE)
global_ns = declarations.get_global_namespace(decls)
global_ns.init_optimizer()
return global_ns
def test_compound_argument_type(global_ns):
do_smth = global_ns.calldefs('do_smth')
assert do_smth is not None
do_smth.function_type()
def test_stderr_present_and_readable():
with open(os.path.join('tests', 'data', TEST_FILES[0]), 'r') as f:
source_str = f.read()
err_str = "add some stuff that should not compile"
source_str += err_str
config = autoconfig.cxx_parsers_cfg.config.clone()
with pytest.raises(RuntimeError) as e_context:
parser.parse_string(source_str, config)
assert err_str in str(e_context)