def _step_options(self):
     options = MockOptions()
     options.non_interactive = True
     options.port = 'MOCK port'
     options.quiet = True
     options.test = True
     return options
 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, [{}])
Exemple #3
0
    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])
Exemple #4
0
    def test_attach_to_bug_no_description_or_comment(self):
        options = MockOptions()
        options.comment = None
        options.description = None
        expected_stderr = """MOCK add_attachment_to_bug: bug_id=50000, description=file.txt filename=None mimetype=None
"""
        self.assert_execute_outputs(AttachToBug(), [50000, "path/to/file.txt"], options=options, expected_stderr=expected_stderr)
Exemple #5
0
    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])
Exemple #6
0
    def test_rebaseline_all(self):
        old_exact_matches = builders._exact_matches
        builders._exact_matches = {
            "MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])},
            "MOCK builder (Debug)": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier", "debug"])},
        }

        command = RebaselineJson()
        tool = MockTool()
        options = MockOptions()
        options.optimize = True
        command.bind_to_tool(tool)
        tool.executive = MockExecutive(should_log=True)

        expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--builder', 'MOCK builder', '--test', 'user-scripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'user-scripts/another-test.html'], cwd=/mock-checkout
"""
        OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder": ["txt", "png"]}}], expected_stderr=expected_stderr)

        expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--builder', 'MOCK builder (Debug)', '--test', 'user-scripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'user-scripts/another-test.html'], cwd=/mock-checkout
"""
        OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt", "png"]}}], expected_stderr=expected_stderr)

        expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'MOCK builder', '--test', 'user-scripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'user-scripts/another-test.html'], cwd=/mock-checkout
"""
        OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt", "png"], "MOCK builder": ["txt"]}}], expected_stderr=expected_stderr)

        builders._exact_matches = old_exact_matches
Exemple #7
0
    def test_attach_to_bug(self):
        options = MockOptions()
        options.comment = "extra comment"
        options.description = "file description"
        expected_stderr = """MOCK add_attachment_to_bug: bug_id=50000, description=file description filename=None mimetype=None
-- Begin comment --
extra comment
-- End comment --
"""
        self.assert_execute_outputs(AttachToBug(), [50000, "path/to/file.txt", "file description"], options=options, expected_stderr=expected_stderr)
 def _make_options(self, verbose=False, **kwargs):
     defaults = {
         'committer_minimum': 10,
         'max_commit_age': 9,
         'reviewer_minimum': 80,
         'show_commits': False,
         'verbose': verbose,
     }
     options = MockOptions(**defaults)
     options.update(**kwargs)
     return options
Exemple #9
0
 def _default_options(self):
     options = MockOptions()
     options.force_clean = False
     options.clean = True
     options.check_builders = True
     options.quiet = False
     options.non_interactive = False
     options.update = True
     options.build = True
     options.test = True
     options.close_bug = True
     return options
 def test_command_aliases(self):
     tool = MockTool()
     options = MockOptions()
     options.ensure_value("confirm", False)
     options.ensure_value("seconds_to_sleep", 120)
     sheriffbot = SheriffBot()
     sheriffbot.execute(options, [], tool, MockQueueEngine)
     sheriffbot.begin_work_queue()
     irc_bot = sheriffbot._irc_bot
     # Test Rollout command aliases
     revert_command, args = irc_bot._parse_command_and_args("revert")
     self.assertEqual(revert_command, Rollout)
Exemple #11
0
    def test_skipped_layout_tests(self):
        mock_options = MockOptions()
        mock_options.configuration = 'release'
        port = ChromiumPortTest.TestLinuxPort(options=mock_options)

        fake_test = 'fast/js/not-good.js'

        port.test_expectations = lambda: """BUG_TEST SKIP : fast/js/not-good.js = TEXT
LINUX WIN : fast/js/very-good.js = TIMEOUT PASS"""
        port.test_expectations_overrides = lambda: ''
        port.tests = lambda paths: set()
        port.test_exists = lambda test: True

        skipped_tests = port.skipped_layout_tests(extra_test_files=[fake_test, ])
        self.assertTrue("fast/js/not-good.js" in skipped_tests)
Exemple #12
0
    def test_runtests_leopard_commit_queue_hack(self):
        mock_options = MockOptions()
        mock_options.non_interactive = True
        step = RunTests(MockTool(log_executive=True), mock_options)
        # FIXME: We shouldn't use a real port-object here, but there is too much to mock at the moment.
        mock_port = WebKitPort()
        mock_port.name = lambda: "Mac"
        mock_port.is_leopard = lambda: True
        step.port = lambda: mock_port
        expected_stderr = """Running Python unit tests
MOCK run_and_throw_if_fail: ['WebKitTools/Scripts/test-webkitpy']
Running Perl unit tests
MOCK run_and_throw_if_fail: ['WebKitTools/Scripts/test-webkitperl']
Running JavaScriptCore tests
MOCK run_and_throw_if_fail: ['WebKitTools/Scripts/run-javascriptcore-tests']
Running run-webkit-tests
MOCK run_and_throw_if_fail: ['WebKitTools/Scripts/run-webkit-tests', '--no-launch-safari', '--exit-after-n-failures=1', '--wait-for-httpd', '--ignore-tests', 'compositing,media', '--quiet']
"""
        OutputCapture().assert_outputs(self, step.run, [{}], expected_stderr=expected_stderr)
    def test_post(self):
        options = MockOptions()
        options.cc = None
        options.check_style = True
        options.check_style_filter = None
        options.comment = None
        options.description = "MOCK description"
        options.non_interactive = False
        options.request_commit = False
        options.review = True
        options.suggest_reviewers = False
        expected_logs = """MOCK: user.open_url: file://...
Was that diff correct?
Obsoleting 2 old patches on bug 50000
MOCK reassign_bug: bug_id=50000, assignee=None
MOCK add_patch_to_bug: bug_id=50000, description=MOCK description, mark_for_review=True, mark_for_commit_queue=False, mark_for_landing=False
MOCK: user.open_url: http://example.com/50000
"""
        self.assert_execute_outputs(Post(), [50000], options=options, expected_logs=expected_logs)
Exemple #14
0
 def test_command_aliases(self):
     tool = MockTool()
     options = MockOptions()
     options.ensure_value("confirm", False)
     sheriffbot = SheriffBot()
     sheriffbot.execute(options, [], tool, MockQueueEngine)
     sheriffbot.begin_work_queue()
     irc_bot = sheriffbot._irc_bot
     # Test Rollout command aliases
     revert_command, args = irc_bot._parse_command_and_args("revert")
     self.assertEqual(revert_command, Rollout)
     # Test Sheriffs command aliases
     gardeners_command, args = irc_bot._parse_command_and_args("gardeners")
     self.assertEqual(gardeners_command, Sheriffs)
     sherifs_command, args = irc_bot._parse_command_and_args("sherifs")
     self.assertEqual(sherifs_command, Sheriffs)
     sherrifs_command, args = irc_bot._parse_command_and_args("sherrifs")
     self.assertEqual(sherrifs_command, Sheriffs)
     sherriffs_command, args = irc_bot._parse_command_and_args("sherriffs")
     self.assertEqual(sherriffs_command, Sheriffs)
    def test_upload(self):
        options = MockOptions()
        options.cc = None
        options.check_style = True
        options.comment = None
        options.description = "MOCK description"
        options.request_commit = False
        options.review = True
        options.suggest_reviewers = False
        expected_stderr = """MOCK: user.open_url: file://...
Was that diff correct?
Obsoleting 2 old patches on bug 42
MOCK add_patch_to_bug: bug_id=42, description=MOCK description, mark_for_review=True, mark_for_commit_queue=False, mark_for_landing=False
MOCK: user.open_url: http://example.com/42
"""
        self.assert_execute_outputs(Upload(), [42], options=options, expected_stderr=expected_stderr)
    def test_post(self):
        options = MockOptions()
        options.cc = None
        options.check_style = True
        options.comment = None
        options.description = "MOCK description"
        options.request_commit = False
        options.review = True
        options.suggest_reviewers = False
        expected_stderr = """Running check-webkit-style
MOCK: user.open_url: file://...
Obsoleting 2 old patches on bug 42
MOCK add_patch_to_bug: bug_id=42, description=MOCK description, mark_for_review=True, mark_for_commit_queue=False, mark_for_landing=False
-- Begin comment --
None
-- End comment --
MOCK: user.open_url: http://example.com/42
"""
        expected_stdout = "Was that diff correct?\n"
        self.assert_execute_outputs(Post(), [42], options=options, expected_stdout=expected_stdout, expected_stderr=expected_stderr)
 def test_guess_reviewer_from_bug(self):
     step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions())
     with OutputCapture(level=logging.INFO) as captured:
         step._guess_reviewer_from_bug(50001)
     self.assertEqual(captured.root.log.getvalue(), 'No reviewed patches on bug 50001, cannot infer reviewer.\n')
Exemple #18
0
 def test_default_timeout_ms(self):
     super(MacTest, self).test_default_timeout_ms()
     self.assertEquals(
         self.make_port(options=MockOptions(
             guard_malloc=True)).default_timeout_ms(), 350000)
Exemple #19
0
 def test_update_step(self):
     options = MockOptions()
     options.update = True
     expected_stderr = "Updating working directory\n"
     OutputCapture().assert_outputs(self, self._run_step, [Update, options], expected_stderr=expected_stderr)
Exemple #20
0
 def test_root_option(self):
     port = TestWebKitPort()
     port._options = MockOptions(root='/foo')
     self.assertEqual(port._path_to_driver(), "/foo/DumpRenderTree")
 def make_port(self):
     port = Port(MockSystemHost(), 'test',
                 MockOptions(configuration='Release'))
     port._config.build_directory = lambda configuration: '/mock-build'
     return port
 def __init__(self, options=None):
     options = options or MockOptions()
     chromium_mac.ChromiumMacPort.__init__(self, MockSystemHost(os_name='mac', os_version='leopard'), 'chromium-mac-leopard', options=options)
 def test_default_timeout_ms(self):
     self.assertEquals(self.make_port(options=MockOptions(configuration='Release')).default_timeout_ms(), 6000)
     self.assertEquals(self.make_port(options=MockOptions(configuration='Debug')).default_timeout_ms(), 12000)
 def __init__(self, options=None):
     options = options or MockOptions()
     chromium_win.ChromiumWinPort.__init__(self, MockSystemHost(os_name='win', os_version='xp'), 'chromium-win-xp', options=options)
 def __init__(self, options=None):
     options = options or MockOptions()
     chromium_linux.ChromiumLinuxPort.__init__(self, MockSystemHost(os_name='linux', os_version='lucid'), 'chromium-linux-x86', options=options)
 def __init__(self, options=None):
     options = options or MockOptions()
     chromium_win.ChromiumAndroidPort.__init__(self, MockSystemHost(os_name='android', os_version='icecreamsandwich'), 'chromium-android', options=options)
 def test_guess_reviewer_from_multipatch_bug(self):
     step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions())
     with OutputCapture(level=logging.INFO) as captured:
         step._guess_reviewer_from_bug(50000)
     self.assertEqual(captured.root.log.getvalue(), 'Guessing "Reviewer2" as reviewer from attachment 10001 on bug 50000.\n')
Exemple #28
0
 def setUp(self):
     self.webkit_options = MockOptions(pixel_tests=False)
Exemple #29
0
 def test_prepare_diff_with_arg(self):
     options = MockOptions()
     options.sort_xcode_project = False
     self.assert_execute_outputs(Prepare(), [50000], options=options)
 def setUp(self):
     super(TestRebaselineExpectations, self).setUp()
     self.options = MockOptions(optimize=False, builders=None, suffixes=['txt'], verbose=False, platform=None,
                                move_overwritten_baselines=False, results_directory=None)
Exemple #31
0
 def test_prepare(self):
     options = MockOptions()
     options.sort_xcode_project = False
     options.non_interactive = True
     expected_logs = "MOCK create_bug\nbug_title: Mock user response\nbug_description: Mock user response\ncomponent: MOCK component\ncc: MOCK cc\n"
     self.assert_execute_outputs(Prepare(), [], expected_logs=expected_logs, options=options)
Exemple #32
0
 def test_setup_environ_for_server(self):
     port = self.make_port(options=MockOptions(leaks=True, guard_malloc=True))
     env = port.setup_environ_for_server(port.driver_name())
     self.assertEqual(env['MallocStackLogging'], '1')
     self.assertEqual(env['MallocScribble'], '1')
     self.assertEqual(env['DYLD_INSERT_LIBRARIES'], '/usr/lib/libgmalloc.dylib:/mock-build/libWebCoreTestShim.dylib')
Exemple #33
0
 def test_driver_name_option(self):
     self.assertTrue(
         self.make_port()._path_to_driver().endswith('Content Shell'))
     self.assertTrue(
         self.make_port(options=MockOptions(driver_name='OtherDriver')).
         _path_to_driver().endswith('OtherDriver'))
Exemple #34
0
 def _assert_wrapper(self, wrapper_string, expected_wrapper):
     wrapper = Driver(
         self.make_port(options=MockOptions(wrapper=wrapper_string)),
         None,
         pixel_tests=False)._command_wrapper()
     self.assertEqual(wrapper, expected_wrapper)
 def test_default(self):
     self.command.execute(MockOptions(suffixes='txt', missing=False, platform=None), ['passes/text.html'], self.tool)
     self.assertEqual(self.lines,
         ['passes/text-expected.txt:',
          '  (generic): 123456',
          '  test-mac-leopard: abcdef'])
 def _default_options(self):
     options = MockOptions()
     options.build = True
     options.build_style = True
     options.check_style = True
     options.check_style_filter = None
     options.clean = True
     options.close_bug = True
     options.force_clean = False
     options.non_interactive = False
     options.parent_command = "MOCK parent command"
     options.quiet = False
     options.test = True
     options.update = True
     options.architecture = "MOCK ARCH"
     return options
Exemple #37
0
 def make_port(self, host=None, options=None):
     port = Port(host or MockSystemHost(), 'test', options
                 or MockOptions(configuration='Release'))
     port._config.build_directory = lambda configuration: '/mock-build'
     return port
 def test_additional_platform_directory(self):
     port = self.make_port(options=MockOptions(
         additional_platform_directory=['/tmp/foo']))
     self.assertEqual(port.baseline_search_path()[0], '/tmp/foo')
 def setUp(self):
     super(TestRebaselineTest, self).setUp()
     self.options = MockOptions(builder="WebKit Mac10.7", test="userscripts/another-test.html", suffixes="txt",
                                move_overwritten_baselines_to=None, results_directory=None)
 def test_no_clean(self):
     tool = MockTool()
     tool._scm = Mock()
     step = CleanWorkingDirectory(tool, MockOptions(clean=False))
     step.run({})
     self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 0)
Exemple #41
0
 def _default_options(self):
     options = MockOptions()
     options.build = True
     options.build_style = "release"
     options.check_style = True
     options.check_style_filter = None
     options.clean = True
     options.close_bug = True
     options.force_clean = False
     options.non_interactive = False
     options.parent_command = 'MOCK parent command'
     options.quiet = False
     options.test = True
     options.update = True
     options.architecture = 'MOCK ARCH'
     options.iterate_on_new_tests = 0
     options.group = None
     options.sort_xcode_project = False
     return options
Exemple #42
0
    def test_upload_of_security_sensitive_patch_with_no_review_and_ews(self):
        options = MockOptions()
        options.cc = None
        options.check_style = True
        options.check_style_filter = None
        options.comment = None
        options.description = 'MOCK description'
        options.non_interactive = False
        options.request_commit = False
        options.review = False
        options.ews = True
        options.sort_xcode_project = False
        options.suggest_reviewers = False
        expected_logs = """MOCK: user.open_url: file://...
Was that diff correct?
Obsoleting 1 old patch on bug 50007
MOCK add_patch_to_bug: bug_id=50007, description=MOCK description, mark_for_review=False, mark_for_commit_queue=False, mark_for_landing=False
MOCK: user.open_url: http://example.com/50007
MOCK: upload_attachment: 10008
MOCK: submit_to_ews: 10008
"""
        self.assert_execute_outputs(Upload(), [50007], options=options, expected_logs=expected_logs)
 def get_manager(port):
     manager = Manager(port,
                       options=MockOptions(http=True,
                                           max_locked_shards=1),
                       printer=FakePrinter())
     return manager
 def _default_options(self):
     options = MockOptions()
     options.build = True
     options.build_style = True
     options.check_builders = True
     options.check_style = True
     options.clean = True
     options.close_bug = True
     options.force_clean = False
     options.force_patch = True
     options.non_interactive = False
     options.parent_command = 'MOCK parent command'
     options.quiet = False
     options.test = True
     options.update = True
     return options
Exemple #45
0
 def _default_options(self):
     options = MockOptions()
     options.build = True
     options.build_style = True
     options.check_style = True
     options.check_style_filter = None
     options.clean = True
     options.close_bug = True
     options.force_clean = False
     options.non_interactive = False
     options.parent_command = 'MOCK parent command'
     options.quiet = False
     options.test = True
     options.update = True
     return options
Exemple #46
0
    def test_post(self):
        options = MockOptions()
        options.cc = None
        options.check_style = True
        options.check_style_filter = None
        options.comment = None
        options.description = "MOCK description"
        options.non_interactive = False
        options.request_commit = False
        options.review = True
        options.suggest_reviewers = False
        expected_logs = """MOCK: user.open_url: file://...
Was that diff correct?
Obsoleting 2 old patches on bug 50000
MOCK reassign_bug: bug_id=50000, assignee=None
MOCK add_patch_to_bug: bug_id=50000, description=MOCK description, mark_for_review=True, mark_for_commit_queue=False, mark_for_landing=False
MOCK: user.open_url: http://example.com/50000
"""
        self.assert_execute_outputs(Post(), [50000], options=options, expected_logs=expected_logs)
Exemple #47
0
 def __init__(self, tool=None):
     CommitQueue.__init__(self)
     if tool:
         self.bind_to_tool(tool)
     self._options = MockOptions(confirm=False, parent_command="commit-queue")
Exemple #48
0
 def test_attach_to_bug_no_description_or_comment(self):
     options = MockOptions()
     options.comment = None
     options.description = None
     expected_logs = "MOCK add_attachment_to_bug: bug_id=50000, description=file.txt filename=None mimetype=None\n"
     self.assert_execute_outputs(AttachToBug(), [50000, "path/to/file.txt"], options=options, expected_logs=expected_logs)
 def _assert_expectations_files(self, search_paths, os_name):
     host = MockSystemHost(os_name=os_name)
     port = self.make_port(port_name=self.port_name,
                           host=host,
                           options=MockOptions(webkit_test_runner=True))
     self.assertEquals(port.expectations_files(), search_paths)