Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, *args):
parser_test_case.parser_test_case_t.__init__(self, *args)
if not os.path.exists(autoconfig.build_directory):
os.makedirs(autoconfig.build_directory)
prj_reader = parser.project_reader_t(self.config)
prj_decls = prj_reader.read_files(
self.__files,
compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
src_reader = parser.source_reader_t(self.config)
src_decls = src_reader.read_file('separate_compilation/all.h')
declarations.dump_declarations(
src_decls,
os.path.join(
autoconfig.build_directory, 'separate_compilation.sr.txt'))
declarations.dump_declarations(
prj_decls,
os.path.join(
autoconfig.build_directory, 'separate_compilation.pr.txt'))
self.assertTrue(
src_decls == prj_decls,
"There is a difference between declarations")
def test_cache_interface(self):
cache_file = os.path.join(
autoconfig.build_directory,
'decl_cache_test.test_cache_read.cache')
file1 = os.path.join(autoconfig.data_directory, 'decl_cache_file1.txt')
file1_dup = os.path.join(
autoconfig.data_directory,
'decl_cache_file1_duplicate.txt')
file2 = os.path.join(autoconfig.data_directory, 'decl_cache_file2.txt')
diff_cfg_list = self.build_differing_cfg_list()
def_cfg = diff_cfg_list[0]
if os.path.exists(cache_file):
os.remove(cache_file)
cache = declarations_cache.file_cache_t(cache_file)
self.assertTrue(len(cache._file_cache_t__cache) == 0)
# test creating new entries for differing files
try:
conf_t = parser.file_configuration_t
fconfig = conf_t(
data=xmlfile,
start_with_declarations=None,
content_type=conf_t.CONTENT_TYPE.GCCXML_GENERATED_FILE)
prj_reader = parser.project_reader_t(self.config)
prj_decls = prj_reader.read_files(
[fconfig],
compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
declarations.dump_declarations(
src_decls,
os.path.join(
autoconfig.build_directory,
'xmlfile_reader.src.txt'))
declarations.dump_declarations(
prj_decls,
os.path.join(
autoconfig.build_directory,
'xmlfile_reader.prj.txt'))
if src_decls != prj_decls:
self.fail(
"There is a difference between declarations in file %s." %
self.__fname)
finally:
pass # utils.remove_file_no_raise( xmlfile, self.config )
def __test_correctness_impl(self, file_name):
prj_reader = parser.project_reader_t(self.config)
prj_decls = prj_reader.read_files(
[file_name] * 2,
compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
src_reader = parser.source_reader_t(self.config)
src_decls = src_reader.read_file(file_name)
if src_decls != prj_decls:
s = src_decls[0]
p = prj_decls[0]
bdir = autoconfig.build_directory
with open(os.path.join(bdir, file_name + '.sr.txt'), 'w+') as sr:
with open(
os.path.join(bdir, file_name + '.pr.txt'), 'w+') as pr:
declarations.print_declarations(
s, writer=lambda l: sr.write(l + os.linesep))
declarations.print_declarations(
p, writer=lambda l: pr.write(l + os.linesep))
self.fail(
"There is a difference between declarations in file %s." %
file_name)
content_type=conf_t.CONTENT_TYPE.GCCXML_GENERATED_FILE)
prj_reader = parser.project_reader_t(self.config)
prj_decls = prj_reader.read_files(
[fconfig],
compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
declarations.dump_declarations(
src_decls,
os.path.join(
autoconfig.build_directory,
'xmlfile_reader.src.txt'))
declarations.dump_declarations(
prj_decls,
os.path.join(
autoconfig.build_directory,
'xmlfile_reader.prj.txt'))
if src_decls != prj_decls:
self.fail(
"There is a difference between declarations in file %s." %
self.__fname)
finally:
pass # utils.remove_file_no_raise( xmlfile, self.config )