def test_run_fixers__integration(): # Test fixer integration with phpcs. tail_path = 'tests/fixtures/phpcs/has_errors.php' phpcs = Phpcs(Mock(), {'fixer': True}, clone_path) diff = fixers.run_fixers([phpcs], clone_path, [tail_path]) eq_(1, len(diff)) eq_(tail_path, diff[0].filename)
def test_run_fixers__integration(self): # Test fixer integration with phpcs. tail_path = 'tests/fixtures/phpcs/has_errors.php' phpcs = Phpcs(Mock(), {'fixer': True}, clone_path) diff = fixers.run_fixers([phpcs], clone_path, [tail_path]) self.assertEqual(1, len(diff)) self.assertEqual(tail_path, diff[0].filename)
def test_run_fixers(self): # Test that fixers are executed if fixer is enabled mock_tool = Mock() mock_tool.has_fixer.return_value = True files = ['diff/adjacent_original.txt'] out = fixers.run_fixers([mock_tool], fixtures_path, files) self.assertEqual(1, mock_tool.execute_fixer.call_count) self.assertEqual(0, len(out))
def test_run_fixers(): # Test that fixers are executed if fixer is enabled mock_tool = Mock() mock_tool.has_fixer.return_value = True files = ['diff/adjacent_original.txt'] out = fixers.run_fixers([mock_tool], fixtures_path, files) eq_(1, mock_tool.execute_fixer.call_count) eq_(0, len(out))
def test_run_fixers__no_fixer_mode(): # Test that fixers are skipped when has_fixer fails # Test that fixers are executed if fixer is enabled mock_tool = Mock() mock_tool.has_fixer.return_value = False files = ['diff/adjacent_original.txt'] out = fixers.run_fixers([mock_tool], fixtures_path, files) eq_(0, mock_tool.execute_fixer.call_count) eq_(0, len(out))
def apply_fixers(self, tool_list, files_to_check): try: fixer_context = fixers.create_context( self._config, self._target_path, self._repository, self._pull_request, ) fixer_diff = fixers.run_fixers(tool_list, self._target_path, files_to_check) fixers.apply_fixer_diff(self._changes, fixer_diff, fixer_context) except (ConfigurationError, WorkflowError) as e: log.warn('Fixer application failed. Got %s', e) message = u'Unable to apply fixers. {}'.format(e) self.problems.add(IssueComment(message)) except Exception as e: log.warn( 'Fixer application failed, ' 'rolling back working tree. Got %s', e) fixers.rollback_changes(self._target_path)
def apply_fixers(self, tool_list, files_to_check): try: fixer_context = fixers.create_context( self._config, self._target_path, self._repository, self._pull_request, ) fixer_diff = fixers.run_fixers( tool_list, self._target_path, files_to_check) fixers.apply_fixer_diff( self._changes, fixer_diff, fixer_context) except (ConfigurationError, WorkflowError) as e: log.info('Fixer application failed. Got %s', e) message = u'Unable to apply fixers. {}'.format(e) self.problems.add(InfoComment(message)) except Exception as e: log.info('Fixer application failed, ' 'rolling back working tree. Got %s', e) fixers.rollback_changes(self._target_path)