def test_publication(tmpdir, mock_issues, mock_phabricator): ''' Test debug publication and report analysis ''' from static_analysis_bot.report.debug import DebugReporter from static_analysis_bot.revisions import PhabricatorRevision report_dir = str(tmpdir.mkdir('public').realpath()) report_path = os.path.join(report_dir, 'report.json') assert not os.path.exists(report_path) with mock_phabricator as api: prev = PhabricatorRevision(api, 'PHID-DIFF-abcdef') r = DebugReporter(report_dir) r.publish(mock_issues, prev) assert os.path.exists(report_path) with open(report_path) as f: report = json.load(f) assert 'issues' in report assert report['issues'] == [{ 'nb': 0 }, { 'nb': 1 }, { 'nb': 2 }, { 'nb': 3 }, { 'nb': 4 }] assert 'revision' in report assert report['revision'] == { 'id': 51, 'diff_id': 42, 'url': 'https://phabricator.test/D51', 'bugzilla_id': '', 'diff_phid': 'PHID-DIFF-abcdef', 'phid': 'PHID-DREV-zzzzz', 'title': 'Static Analysis tests', 'has_clang_files': False, } assert 'time' in report assert isinstance(report['time'], float)
def __init__(self, reporters, analyzers, index_service, phabricator_api): assert isinstance(analyzers, list) assert len(analyzers) > 0, \ 'No analyzers specified, will not run.' self.analyzers = analyzers assert 'MOZCONFIG' in os.environ, \ 'Missing MOZCONFIG in environment' # Use share phabricator API client assert isinstance(phabricator_api, PhabricatorAPI) self.phabricator = phabricator_api # Save Taskcluster ID for logging if 'TASK_ID' in os.environ and 'RUN_ID' in os.environ: self.taskcluster_task_id = os.environ['TASK_ID'] self.taskcluster_run_id = os.environ['RUN_ID'] self.on_taskcluster = True else: self.taskcluster_task_id = 'local instance' self.taskcluster_run_id = 0 self.on_taskcluster = False # Load reporters to use self.reporters = reporters if not self.reporters: logger.warn( 'No reporters configured, this analysis will not be published') # Always add debug reporter and Diff reporter self.reporters['debug'] = DebugReporter( output_dir=settings.taskcluster_results_dir) # Use TC index service client self.index_service = index_service
def __init__(self, reporters, analyzers, index_service, queue_service, phabricator_api): assert isinstance(analyzers, list) assert len(analyzers) > 0, \ 'No analyzers specified, will not run.' self.analyzers = analyzers assert 'MOZCONFIG' in os.environ, \ 'Missing MOZCONFIG in environment' # Use share phabricator API client assert isinstance(phabricator_api, PhabricatorAPI) self.phabricator = phabricator_api # Load reporters to use self.reporters = reporters if not self.reporters: logger.warn('No reporters configured, this analysis will not be published') # Always add debug reporter and Diff reporter self.reporters['debug'] = DebugReporter(output_dir=settings.taskcluster.results_dir) # Use TC services client self.index_service = index_service self.queue_service = queue_service # Build analysis workflows to run self.workflows = []
def __init__(self, reporters, index_service, queue_service, phabricator_api, zero_coverage_enabled=True): assert settings.try_task_id is not None, \ 'Cannot run without Try task id' assert settings.try_group_id is not None, \ 'Cannot run without Try task id' self.zero_coverage_enabled = zero_coverage_enabled # Use share phabricator API client assert isinstance(phabricator_api, PhabricatorAPI) self.phabricator = phabricator_api # Load reporters to use self.reporters = reporters if not self.reporters: logger.warn( 'No reporters configured, this analysis will not be published') # Always add debug reporter and Diff reporter self.reporters['debug'] = DebugReporter( output_dir=settings.taskcluster.results_dir) # Use TC services client self.index_service = index_service self.queue_service = queue_service
def test_publication(tmpdir, mock_issues): ''' Test debug publication and report analysis ''' from static_analysis_bot.report.debug import DebugReporter from static_analysis_bot.revisions import MozReviewRevision report_dir = str(tmpdir.mkdir('public').realpath()) report_path = os.path.join(report_dir, 'report.json') assert not os.path.exists(report_path) r = DebugReporter(report_dir) mrev = MozReviewRevision('12345', 'abcdef', '1') r.publish(mock_issues, mrev) assert os.path.exists(report_path) with open(report_path) as f: report = json.load(f) assert 'issues' in report assert report['issues'] == [{ 'nb': 0 }, { 'nb': 1 }, { 'nb': 2 }, { 'nb': 3 }, { 'nb': 4 }] assert 'revision' in report assert report['revision'] == { 'source': 'mozreview', 'rev': 'abcdef', 'review_request': 12345, 'diffset': 1, 'has_clang_files': False, 'url': 'https://reviewboard.mozilla.org/r/12345/' } assert 'time' in report assert isinstance(report['time'], float)
def test_publication(tmpdir, mock_issues, mock_phabricator): ''' Test debug publication and report analysis ''' from static_analysis_bot.report.debug import DebugReporter from static_analysis_bot.revisions import PhabricatorRevision report_dir = str(tmpdir.mkdir('public').realpath()) report_path = os.path.join(report_dir, 'report.json') assert not os.path.exists(report_path) with mock_phabricator as api: prev = PhabricatorRevision(api, 'PHID-DIFF-abcdef') r = DebugReporter(report_dir) r.publish(mock_issues, prev) assert os.path.exists(report_path) with open(report_path) as f: report = json.load(f) assert 'issues' in report assert report['issues'] == [{'nb': 0}, {'nb': 1}, {'nb': 2}, {'nb': 3}, {'nb': 4}] assert 'revision' in report assert report['revision'] == { 'id': 51, 'diff_id': 42, 'url': 'https://phabricator.test/D51', 'bugzilla_id': '', 'diff_phid': 'PHID-DIFF-abcdef', 'phid': 'PHID-DREV-zzzzz', 'title': 'Static Analysis tests', 'has_clang_files': False, } assert 'time' in report assert isinstance(report['time'], float)