def __test_html_builder(self, proj): """ Test building html file from the given proj's plist file. """ proj_dir = os.path.join(self.test_workspace, 'test_files', proj) plist_file = os.path.join(proj_dir, proj + '.plist') plist = load_plist_data(plist_file) report_data = PlistToHtml.get_report_data_from_plist(plist) output_dir = os.path.join(proj_dir, 'html') if not os.path.exists(output_dir): os.mkdir(output_dir) output_path = os.path.join(output_dir, proj + '.html') html_builder = PlistToHtml.HtmlBuilder(self.layout_dir) html_builder.create(output_path, report_data) self.assertTrue(os.path.exists(output_path)) html_builder.create_index_html(output_dir) html_builder.create_statistics_html(output_dir) index_html = os.path.join(output_dir, 'index.html') self.assertTrue(os.path.exists(index_html))
def test_get_report_data_simple(self): """ Get report data for plist which contains simple reports. """ proj_simple = os.path.join(self.test_workspace, 'test_files', 'simple') plist_file = os.path.join(proj_simple, 'simple.plist') plist = load_plist_data(plist_file) res = PlistToHtml.get_report_data_from_plist(plist) self.assertEqual(len(res['files']), 1) reports = res['reports'] self.assertEqual(len(reports), 2) dead_stores = [ r for r in reports if r['checkerName'] == 'deadcode.DeadStores' ][0] self.assertEqual(len(dead_stores['notes']), 0) self.assertEqual(len(dead_stores['macros']), 0) self.assertGreaterEqual(len(dead_stores['events']), 1) divide_zero = [ r for r in reports if r['checkerName'] == 'core.DivideZero' ][0] self.assertEqual(len(divide_zero['notes']), 0) self.assertEqual(len(divide_zero['macros']), 0) self.assertGreaterEqual(len(divide_zero['events']), 1)
def __test_html_builder(self, proj): """ Test building html file from the given proj's plist file. """ proj_dir = os.path.join(self.test_workspace, 'test_files', proj) plist_file = os.path.join(proj_dir, proj + '.plist') plist = plistlib.readPlist(plist_file) report_data = PlistToHtml.get_report_data_from_plist(plist) output_dir = os.path.join(proj_dir, 'html') if not os.path.exists(output_dir): os.mkdir(output_dir) output_path = os.path.join(output_dir, proj + '.html') html_builder = PlistToHtml.HtmlBuilder(self.layout_dir) html_builder.create(output_path, report_data) self.assertTrue(os.path.exists(output_path)) html_builder.create_index_html(output_dir) html_builder.create_statistics_html(output_dir) index_html = os.path.join(output_dir, 'index.html') self.assertTrue(os.path.exists(index_html))
def test_get_report_data_macros(self): """ Get report data for plist which contains macro expansion. """ proj_macros = os.path.join(self.test_workspace, 'test_files', 'macros') plist_file = os.path.join(proj_macros, 'macros.plist') plist = load_plist_data(plist_file) res = PlistToHtml.get_report_data_from_plist(plist) self.assertEqual(len(res['files']), 1) reports = res['reports'] self.assertEqual(len(reports), 1) report = reports[0] self.assertEqual(len(report['notes']), 0) self.assertEqual(len(report['macros']), 1) self.assertGreaterEqual(len(report['events']), 1) self.assertEqual(report['checkerName'], 'core.NullDereference')
def test_get_report_data_notes(self): """ Get report data for plist which contains notes. """ proj_notes = os.path.join(self.test_workspace, 'test_files', 'notes') plist_file = os.path.join(proj_notes, 'notes.plist') plist = load_plist_data(plist_file) res = PlistToHtml.get_report_data_from_plist(plist) self.assertEqual(len(res['files']), 1) reports = res['reports'] self.assertEqual(len(reports), 1) report = reports[0] self.assertEqual(len(report['notes']), 1) self.assertEqual(len(report['macros']), 0) self.assertGreaterEqual(len(report['events']), 1) self.assertEqual(report['checkerName'], 'alpha.clone.CloneChecker')
def test_get_report_data_macros(self): """ Get report data for plist which contains macro expansion. """ proj_macros = os.path.join(self.test_workspace, 'test_files', 'macros') plist_file = os.path.join(proj_macros, 'macros.plist') plist = plistlib.readPlist(plist_file) res = PlistToHtml.get_report_data_from_plist(plist) self.assertEqual(len(res['files']), 1) reports = res['reports'] self.assertEqual(len(reports), 1) report = reports[0] self.assertEqual(len(report['notes']), 0) self.assertEqual(len(report['macros']), 1) self.assertGreaterEqual(len(report['events']), 1) self.assertEqual(report['checkerName'], 'core.NullDereference')
def test_get_report_data_notes(self): """ Get report data for plist which contains notes. """ proj_notes = os.path.join(self.test_workspace, 'test_files', 'notes') plist_file = os.path.join(proj_notes, 'notes.plist') plist = plistlib.readPlist(plist_file) res = PlistToHtml.get_report_data_from_plist(plist) self.assertEqual(len(res['files']), 1) reports = res['reports'] self.assertEqual(len(reports), 1) report = reports[0] self.assertEqual(len(report['notes']), 1) self.assertEqual(len(report['macros']), 0) self.assertGreaterEqual(len(report['events']), 1) self.assertEqual(report['checkerName'], 'alpha.clone.CloneChecker')
def test_get_report_data_simple(self): """ Get report data for plist which contains simple reports. """ proj_simple = os.path.join(self.test_workspace, 'test_files', 'simple') plist_file = os.path.join(proj_simple, 'simple.plist') plist = plistlib.readPlist(plist_file) res = PlistToHtml.get_report_data_from_plist(plist) self.assertEqual(len(res['files']), 1) reports = res['reports'] self.assertEqual(len(reports), 2) dead_stores = [r for r in reports if r['checkerName'] == 'deadcode.DeadStores'][0] self.assertEqual(len(dead_stores['notes']), 0) self.assertEqual(len(dead_stores['macros']), 0) self.assertGreaterEqual(len(dead_stores['events']), 1) divide_zero = [r for r in reports if r['checkerName'] == 'core.DivideZero'][0] self.assertEqual(len(divide_zero['notes']), 0) self.assertEqual(len(divide_zero['macros']), 0) self.assertGreaterEqual(len(divide_zero['events']), 1)