def test_empty_state(self): capture = OutputCapture() options = MockOptions() options.reviewer = 'MOCK reviewer' options.git_commit = 'MOCK git commit' step = UpdateChangeLogsWithReviewer(MockTool(), options) capture.assert_outputs(self, step.run, [{}])
def _test_check_test_expectations(self, filename): capture = OutputCapture() options = MockOptions() options.git_commit = "" options.non_interactive = True tool = MockTool() tool.user = None # Will cause any access of tool.user to raise an exception. step = Commit(tool, options) state = { "changed_files": [filename + "XXX"], } tool.executive = MockExecutive(should_log=True, should_throw_when_run=False) expected_logs = "Committed r49824: <http://trac.webkit.org/changeset/49824>\n" capture.assert_outputs(self, step.run, [state], expected_logs=expected_logs) state = { "changed_files": ["platform/chromium/" + filename], } expected_logs = """MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/%s'], cwd=/mock-checkout Committed r49824: <http://trac.webkit.org/changeset/49824> """ % filename capture.assert_outputs(self, step.run, [state], expected_logs=expected_logs) tool.executive = MockExecutive(should_log=True, should_throw_when_run=set(["platform/chromium/" + filename])) self.assertRaises(ScriptError, capture.assert_outputs, self, step.run, [state])
def test_check_test_expectations(self): capture = OutputCapture() options = MockOptions() options.git_commit = "" tool = MockTool() step = Commit(tool, options) state = { "changed_files": ["test_expectations.txtXXX"], } tool.executive = MockExecutive(should_log=True, should_throw_when_run=False) capture.assert_outputs( self, step.run, [state], expected_stderr= "Committed r49824: <http://trac.webkit.org/changeset/49824>\n") state = { "changed_files": ["platform/chromium/test_expectations.txt"], } capture.assert_outputs( self, step.run, [state], expected_stderr= "MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/test_expectations.txt'], cwd=/mock-checkout\nCommitted r49824: <http://trac.webkit.org/changeset/49824>\n" ) tool.executive = MockExecutive( should_log=True, should_throw_when_run=set( ["platform/chromium/test_expectations.txt"])) self.assertRaises(SystemExit, capture.assert_outputs, self, step.run, [state])
def _test_check_test_expectations(self, filename): options = MockOptions() options.git_commit = "" options.non_interactive = True tool = MockTool() tool.user = None # Will cause any access of tool.user to raise an exception. step = Commit(tool, options) state = { "changed_files": [filename + "XXX"], } tool.executive = MockExecutive(should_log=True, should_throw_when_run=False) with OutputCapture(level=logging.INFO) as captured: step.run(state) self.assertEqual(captured.root.log.getvalue(), 'Committed r49824: <https://commits.webkit.org/r49824>\n') state = { "changed_files": ["platform/chromium/" + filename], } with OutputCapture(level=logging.INFO) as captured: step.run(state) self.assertEqual( captured.root.log.getvalue(), '''MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/{}'], cwd=/mock-checkout Committed r49824: <https://commits.webkit.org/r49824> '''.format(filename), ) tool.executive = MockExecutive(should_log=True, should_throw_when_run={"platform/chromium/" + filename}) with self.assertRaises(ScriptError), OutputCapture(): step.run(state)
def test_check_test_expectations(self): capture = OutputCapture() options = MockOptions() options.git_commit = "" tool = MockTool() step = Commit(tool, options) state = {"changed_files": ["test_expectations.txtXXX"]} tool.executive = MockExecutive(should_log=True, should_throw_when_run=False) capture.assert_outputs( self, step.run, [state], expected_stderr="Committed r49824: <http://trac.webkit.org/changeset/49824>\n" ) state = {"changed_files": ["platform/chromium/test_expectations.txt"]} capture.assert_outputs( self, step.run, [state], expected_stderr="MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/test_expectations.txt'], cwd=/mock-checkout\nCommitted r49824: <http://trac.webkit.org/changeset/49824>\n", ) tool.executive = MockExecutive( should_log=True, should_throw_when_run=set(["platform/chromium/test_expectations.txt"]) ) self.assertRaises(SystemExit, capture.assert_outputs, self, step.run, [state])
def test_empty_state(self): options = MockOptions() options.reviewer = 'MOCK reviewer' options.git_commit = 'MOCK git commit' step = UpdateChangeLogsWithReviewer(MockTool(), options) with OutputCapture(level=logging.INFO) as captured: step.run({}) self.assertEqual(captured.root.log.getvalue(), '')