15 def __are_directory_identical(cls, dircmp):
16 if len(dircmp.diff_files) > 0
or len(dircmp.funny_files) > 0:
19 for sub_dircmp
in dircmp.subdirs.values():
26 def __execute_codingstyle(cls, test, enableReformat, *args, **kwargs):
31 codingstyle.YEAR = 2999
34 dir_path = os.path.dirname(os.path.realpath(__file__))
35 test_data_path = dir_path +
'/' + test
39 test_data_path_copy = test_data_path + str(os.getpid())
40 shutil.copytree(test_data_path, test_data_path_copy)
50 shutil.rmtree(test_data_path_copy)
54 verbatim = kwargs.get(
'verbatim',
None)
56 if verbatim
is not None:
57 verbatim_data_path = dir_path +
'/' + verbatim
58 dircmp = filecmp.dircmp(verbatim_data_path, test_data_path_copy)
63 shutil.rmtree(test_data_path_copy)
71 return result, reformatted
73 def test_codingstyle_formatted(self):
77 self.assertFalse(result,
"Codingstyle function should return no error.")
78 self.assertFalse(len(reformatted) > 0,
"No file should have been reformatted.")
80 def test_codingstyle_lgpl_check(self):
84 self.assertTrue(result,
"Codingstyle function should return True as one file at least contains one error.")
85 self.assertFalse(len(reformatted) > 0,
"No file should have been fixed.")
87 def test_codingstyle_lgpl_reformat(self):
91 self.assertFalse(result,
"Codingstyle function should return no error.")
92 self.assertTrue(len(reformatted) > 0,
"Some files should have been fixed.")
94 def test_codingstyle_sort_includes_check(self):
98 self.assertTrue(result,
"Codingstyle function should return True as one file at least contains one error.")
99 self.assertFalse(len(reformatted) > 0,
"No file should have been fixed.")
101 def test_codingstyle_sort_includes_reformat(self):
105 self.assertFalse(result,
"Codingstyle function should return no error.")
106 self.assertTrue(len(reformatted) > 0,
"Some files should have been fixed.")
108 def test_codingstyle_header_guards_typo_check(self):
112 self.assertTrue(result,
"Codingstyle function should return True as one file at least contains one error.")
113 self.assertFalse(len(reformatted) > 0,
"No file should have been fixed.")
115 def test_codingstyle_header_guards_typo_reformat(self):
119 self.assertFalse(result,
"Codingstyle function should return no error.")
120 self.assertTrue(len(reformatted) > 0,
"Some files should have been fixed.")
122 def test_codingstyle_header_guards_forgotten_check(self):
126 self.assertTrue(result,
"Codingstyle function should return True as one file at least contains one error.")
127 self.assertFalse(len(reformatted) > 0,
"No file should have been fixed.")
129 def test_codingstyle_uncrusitfy_formatted_check(self):
133 self.assertFalse(result,
"Codingstyle function should return True as no file contains error.")
134 self.assertFalse(len(reformatted) > 0,
"No file should have been fixed.")
136 def test_codingstyle_uncrusitfy_unformatted_check(self):
140 self.assertTrue(result,
"Codingstyle function should return False as one file at least contains one error.")
141 self.assertFalse(len(reformatted) > 0,
"No file should have been fixed.")
143 def test_codingstyle_uncrustify_unformatted_reformat(self):
146 verbatim=
'data/Codingstyle/Uncrustify_formatted')
149 self.assertFalse(result,
"Codingstyle function should return no error.")
150 self.assertTrue(len(reformatted) > 0,
"Some files should have been fixed.")
153 if __name__ ==
'__main__':
def codingstyle(files, enable_reformat, check_lgpl, check_commits_date)
def directory_on_disk(path)
def __are_directory_identical(cls, dircmp)
def __execute_codingstyle(cls, test, enableReformat, args, kwargs)