Changeset 91210 in webkit


Ignore:
Timestamp:
Jul 18, 2011 2:16:45 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

webkit-patch apply-attachment does not work when not called from the root of the checkout
https://bugs.webkit.org/show_bug.cgi?id=64751

Reviewed by Adam Barth.

Last week I removed a os.chdir in EnsureWorkingDirectoryClean, which
is a step that we run for most commands (as one of the earliest steps).
EnsureWorkingDirectoryClean was incorrectly calling os.chdir to change
the CWD to the checkout root. This magically made a bunch of otherwise
wrong code work.

When I realized that apply-attachment no longer worked as expected today,
I went and fixed the bug, then realizing that we were not testing
what the cwd was when running various commands. I fixed our MockExecutive
to always log what the cwd is and fixed a whole bunch of places
where we needed to be setting the cwd.

Hopefully this will solve our cwd problems once and for-all, and webkit-patch
will again correctly work when called from any directory (including outside
of a webkit checkout).

  • Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
  • Scripts/webkitpy/common/system/executive.py:
  • Scripts/webkitpy/common/system/workspace_unittest.py:
  • Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
  • Scripts/webkitpy/layout_tests/port/gtk_unittest.py:
  • Scripts/webkitpy/layout_tests/port/mac_unittest.py:
  • Scripts/webkitpy/layout_tests/port/qt_unittest.py:
  • Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
  • Scripts/webkitpy/tool/bot/irc_command.py:
  • Scripts/webkitpy/tool/bot/irc_command_unittest.py:
  • Scripts/webkitpy/tool/bot/layouttestresultsreader_unittest.py:
  • Scripts/webkitpy/tool/commands/download_unittest.py:
  • Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:
  • Scripts/webkitpy/tool/commands/queues.py:
  • Scripts/webkitpy/tool/commands/queues_unittest.py:
  • Scripts/webkitpy/tool/commands/queuestest.py:
  • Scripts/webkitpy/tool/mocktool.py:
  • Scripts/webkitpy/tool/servers/gardeningserver.py:
  • Scripts/webkitpy/tool/servers/gardeningserver_unittest.py:
  • Scripts/webkitpy/tool/steps/build.py:
  • Scripts/webkitpy/tool/steps/checkstyle.py:
  • Scripts/webkitpy/tool/steps/editchangelog.py:
  • Scripts/webkitpy/tool/steps/preparechangelog.py:
  • Scripts/webkitpy/tool/steps/preparechangelogforrevert.py:
  • Scripts/webkitpy/tool/steps/runtests.py:
  • Scripts/webkitpy/tool/steps/steps_unittest.py:
  • Scripts/webkitpy/tool/steps/update.py:
Location:
trunk/Tools
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r91197 r91210  
     12011-07-18  Eric Seidel  <eric@webkit.org>
     2
     3        webkit-patch apply-attachment does not work when not called from the root of the checkout
     4        https://bugs.webkit.org/show_bug.cgi?id=64751
     5
     6        Reviewed by Adam Barth.
     7
     8        Last week I removed a os.chdir in EnsureWorkingDirectoryClean, which
     9        is a step that we run for most commands (as one of the earliest steps).
     10        EnsureWorkingDirectoryClean was incorrectly calling os.chdir to change
     11        the CWD to the checkout root.  This magically made a bunch of otherwise
     12        wrong code work.
     13
     14        When I realized that apply-attachment no longer worked as expected today,
     15        I went and fixed the bug, then realizing that we were not testing
     16        what the cwd was when running various commands.  I fixed our MockExecutive
     17        to always log what the cwd is and fixed a whole bunch of places
     18        where we needed to be setting the cwd.
     19
     20        Hopefully this will solve our cwd problems once and for-all, and webkit-patch
     21        will again correctly work when called from any directory (including outside
     22        of a webkit checkout).
     23
     24        * Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
     25        * Scripts/webkitpy/common/system/executive.py:
     26        * Scripts/webkitpy/common/system/workspace_unittest.py:
     27        * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
     28        * Scripts/webkitpy/layout_tests/port/gtk_unittest.py:
     29        * Scripts/webkitpy/layout_tests/port/mac_unittest.py:
     30        * Scripts/webkitpy/layout_tests/port/qt_unittest.py:
     31        * Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
     32        * Scripts/webkitpy/tool/bot/irc_command.py:
     33        * Scripts/webkitpy/tool/bot/irc_command_unittest.py:
     34        * Scripts/webkitpy/tool/bot/layouttestresultsreader_unittest.py:
     35        * Scripts/webkitpy/tool/commands/download_unittest.py:
     36        * Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:
     37        * Scripts/webkitpy/tool/commands/queues.py:
     38        * Scripts/webkitpy/tool/commands/queues_unittest.py:
     39        * Scripts/webkitpy/tool/commands/queuestest.py:
     40        * Scripts/webkitpy/tool/mocktool.py:
     41        * Scripts/webkitpy/tool/servers/gardeningserver.py:
     42        * Scripts/webkitpy/tool/servers/gardeningserver_unittest.py:
     43        * Scripts/webkitpy/tool/steps/build.py:
     44        * Scripts/webkitpy/tool/steps/checkstyle.py:
     45        * Scripts/webkitpy/tool/steps/editchangelog.py:
     46        * Scripts/webkitpy/tool/steps/preparechangelog.py:
     47        * Scripts/webkitpy/tool/steps/preparechangelogforrevert.py:
     48        * Scripts/webkitpy/tool/steps/runtests.py:
     49        * Scripts/webkitpy/tool/steps/steps_unittest.py:
     50        * Scripts/webkitpy/tool/steps/update.py:
     51
    1522011-07-18  Adam Barth  <abarth@webkit.org>
    253
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py

    r90978 r91210  
    15011501    def test_create_patch(self):
    15021502        scm = self.make_scm(logging_executive=True)
    1503         expected_stderr = "MOCK run_command: ['git', 'merge-base', u'refs/remotes/origin/master', 'HEAD']\nMOCK run_command: ['git', 'diff', '--binary', '--no-ext-diff', '--full-index', '-M', 'MOCK output of child process', '--']\nMOCK run_command: ['git', 'log', '-25']\n"
     1503        expected_stderr = "MOCK run_command: ['git', 'merge-base', u'refs/remotes/origin/master', 'HEAD'], cwd=/mock-checkoutMOCK run_command: ['git', 'diff', '--binary', '--no-ext-diff', '--full-index', '-M', 'MOCK output of child process', '--'], cwd=/mock-checkoutMOCK run_command: ['git', 'log', '-25'], cwd=/mock-checkout\n"
    15041504        OutputCapture().assert_outputs(self, scm.create_patch, expected_stderr=expected_stderr)
    15051505
  • trunk/Tools/Scripts/webkitpy/common/system/executive.py

    r90978 r91210  
    109109        return sys.platform not in ('win32', 'cygwin')
    110110
    111     def _run_command_with_teed_output(self, args, teed_output):
     111    def _run_command_with_teed_output(self, args, teed_output, cwd=None):
    112112        args = map(unicode, args)  # Popen will throw an exception if args are non-strings (like int())
    113113        args = map(self._encode_argument_if_needed, args)
     
    116116                                   stdout=self.PIPE,
    117117                                   stderr=self.STDOUT,
    118                                    close_fds=self._should_close_fds())
     118                                   close_fds=self._should_close_fds(),
     119                                   cwd=cwd)
    119120
    120121        # Use our own custom wait loop because Popen ignores a tee'd
     
    136137    # like "build-webkit" where we want to display to the user that we're building
    137138    # but still have the output to stuff into a log file.
    138     def run_and_throw_if_fail(self, args, quiet=False, decode_output=True):
     139    def run_and_throw_if_fail(self, args, quiet=False, decode_output=True, cwd=None):
    139140        # Cache the child's output locally so it can be used for error reports.
    140141        child_out_file = StringIO.StringIO()
     
    144145            tee_stdout = dev_null
    145146        child_stdout = tee(child_out_file, tee_stdout)
    146         exit_code = self._run_command_with_teed_output(args, child_stdout)
     147        exit_code = self._run_command_with_teed_output(args, child_stdout, cwd=cwd)
    147148        if quiet:
    148149            dev_null.close()
  • trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py

    r90702 r91210  
    8181
    8282    def path_to_module(self, module_name):
    83         return "/mock/Tools/Scripts/webkitpy/%s" % module_name
     83        return "/mock-checkout/Tools/Scripts/webkitpy/%s" % module_name
    8484
    8585    def chdir(self, path):
  • trunk/Tools/Scripts/webkitpy/common/system/workspace_unittest.py

    r87751 r91210  
    5151    def test_create_zip(self):
    5252        workspace = Workspace(None, MockExecutive(should_log=True))
    53         expected_stderr = "MOCK run_command: ['zip', '-9', '-r', '/zip/path', '/source/path']\n"
     53        expected_stderr = "MOCK run_command: ['zip', '-9', '-r', '/zip/path', '/source/path'], cwd=None\n"
    5454        class MockZipFile(object):
    5555            def __init__(self, path):
     
    6060    def test_create_zip_exception(self):
    6161        workspace = Workspace(None, MockExecutive(should_log=True, should_throw=True))
    62         expected_stderr = "MOCK run_command: ['zip', '-9', '-r', '/zip/path', '/source/path']\n"
     62        expected_stderr = "MOCK run_command: ['zip', '-9', '-r', '/zip/path', '/source/path'], cwd=None\n"
    6363        class MockZipFile(object):
    6464            def __init__(self, path):
  • trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py

    r91136 r91210  
    215215        # to fail, since they assert that we have no logging output.
    216216        # The revision lookup always fails when running the tests since it tries to read from
    217         # "/mock" using the real file system (since there is no way to mock out detect_scm_system at current).
     217        # "/mock-checkout" using the real file system (since there is no way to mock out detect_scm_system at current).
    218218        # Once we fix detect_scm_system to use the mock file system we can add this log back.
    219219        #_log.warn("Failed to determine svn revision for checkout (cwd: %s, webkit_base: %s), leaving 'revision' key blank in full_results.json.\n%s" % (port_obj._filesystem.getcwd(), port_obj.path_from_webkit_base(), e))
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py

    r90520 r91210  
    256256        filesystem = MockFileSystem()
    257257        port = Port(port_name='foo', filesystem=filesystem)
    258         port.path_to_test_expectations_file = lambda: '/mock/test_expectations.txt'
     258        port.path_to_test_expectations_file = lambda: '/mock-results/test_expectations.txt'
    259259        self.assertFalse(port.uses_test_expectations_file())
    260         port._filesystem = MockFileSystem({'/mock/test_expectations.txt': ''})
     260        port._filesystem = MockFileSystem({'/mock-results/test_expectations.txt': ''})
    261261        self.assertTrue(port.uses_test_expectations_file())
    262262
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py

    r90527 r91210  
    8888        port.path_from_chromium_base = self._mock_path_from_chromium_base
    8989        self._port = port
    90         setup_mount = self._mock_path_from_chromium_base("third_party",
    91                                                         "cygwin",
    92                                                         "setup_mount.bat")
     90        setup_mount = self._mock_path_from_chromium_base("third_party", "cygwin", "setup_mount.bat")
    9391        expected_stderr = "MOCK run_command: %s\n" % [setup_mount]
    9492        output = outputcapture.OutputCapture()
    95         output.assert_outputs(self, port.setup_environ_for_server,
    96                               expected_stderr=expected_stderr)
     93        output.assert_outputs(self, port.setup_environ_for_server, expected_stderr=expected_stderr)
    9794
    9895    def assert_name(self, port_name, windows_version, expected):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk_unittest.py

    r90826 r91210  
    4242        port = self.make_port()
    4343        port._executive = MockExecutive(should_log=True)
    44         expected_stderr = "MOCK run_command: ['Tools/Scripts/run-launcher', '--release', '--gtk', 'file://test.html']\n"
     44        expected_stderr = "MOCK run_command: ['Tools/Scripts/run-launcher', '--release', '--gtk', 'file://test.html'], cwd=/mock-checkout\n"
    4545        OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_stderr=expected_stderr)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py

    r90826 r91210  
    148148        # Delay setting a should_log executive to avoid logging from MacPort.__init__.
    149149        port._executive = MockExecutive(should_log=True)
    150         expected_stderr = "MOCK run_command: ['Tools/Scripts/run-safari', '--release', '-NSOpen', 'test.html']\n"
     150        expected_stderr = "MOCK run_command: ['Tools/Scripts/run-safari', '--release', '-NSOpen', 'test.html'], cwd=/mock-checkout\n"
    151151        OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_stderr=expected_stderr)
    152152
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/qt_unittest.py

    r90826 r91210  
    6666        port = self.make_port()
    6767        port._executive = MockExecutive(should_log=True)
    68         expected_stderr = "MOCK run_command: ['Tools/Scripts/run-launcher', '--release', '--qt', 'file://test.html']\n"
     68        expected_stderr = "MOCK run_command: ['Tools/Scripts/run-launcher', '--release', '--qt', 'file://test.html'], cwd=/mock-checkout\n"
    6969        OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_stderr=expected_stderr)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/server_process_unittest.py

    r90184 r91210  
    4646class TrivialMockPort(object):
    4747    def results_directory(self):
    48         return "/mock/results"
     48        return "/mock-results"
    4949
    5050
     
    9696        server_process = FakeServerProcess(port_obj=TrivialMockPort(), name="test", cmd=["test"], executive=MockExecutive2(run_command_fn=_logging_run_command))
    9797        server_process._proc = MockProc(server_process)
    98         expected_stdout = "['/usr/bin/sample', 1, 10, 10, '-file', '/mock/results/test-1.sample.txt']\n"
     98        expected_stdout = "['/usr/bin/sample', 1, 10, 10, '-file', '/mock-results/test-1.sample.txt']\n"
    9999        OutputCapture().assert_outputs(self, server_process._sample, expected_stdout=expected_stdout)
    100100
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py

    r91136 r91210  
    247247    files[LAYOUT_TEST_DIR + 'userscripts/resources/iframe.html'] = 'iframe'
    248248
    249     fs = filesystem_mock.MockFileSystem(files, dirs=set(['/mock']))  # Make sure at least the checkout_root exists as a directory.
     249    fs = filesystem_mock.MockFileSystem(files, dirs=set(['/mock-checkout']))  # Make sure at least the checkout_root exists as a directory.
    250250    fs._tests = test_list
    251251    return fs
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py

    r90810 r91210  
    119119        # Skipped file, and that we include the feature and platform checks.
    120120        files = {
    121             '/mock/LayoutTests/platform/testwebkitport/test_expectations.txt': 'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n',
    122             '/mock/LayoutTests/platform/testwebkitport/Skipped': 'fast/html/keygen.html',
     121            '/mock-checkout/LayoutTests/platform/testwebkitport/test_expectations.txt': 'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n',
     122            '/mock-checkout/LayoutTests/platform/testwebkitport/Skipped': 'fast/html/keygen.html',
    123123        }
    124124        mock_fs = MockFileSystem(files)
     
    135135        port._executive = MockExecutive(should_log=True)
    136136        port._options = MockOptions(configuration="Release")  # This should not be necessary, but I think TestWebKitPort is actually reading from disk (and thus detects the current configuration).
    137         expected_stderr = "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release']\n"
     137        expected_stderr = "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout\n"
    138138        self.assertTrue(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr))
    139139
    140140        # Make sure when passed --webkit-test-runner web build the right tool.
    141141        port._options = MockOptions(webkit_test_runner=True, configuration="Release")
    142         expected_stderr = "MOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release']\n"
     142        expected_stderr = "MOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release'], cwd=/mock-checkout\n"
    143143        self.assertTrue(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr))
    144144
    145145        # Make sure that failure to build returns False.
    146146        port._executive = MockExecutive(should_log=True, should_throw=True)
    147         expected_stderr = "MOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release']\n"
     147        expected_stderr = "MOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release'], cwd=/mock-checkout\n"
    148148        self.assertFalse(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr))
    149149
     
    186186        # Mock out _apache_config_file_name_for_platform to ignore the passed sys.platform value.
    187187        port._apache_config_file_name_for_platform = lambda platform: 'httpd.conf'
    188         self.assertEquals(port._path_to_apache_config_file(), '/mock/LayoutTests/http/conf/httpd.conf')
     188        self.assertEquals(port._path_to_apache_config_file(), '/mock-checkout/LayoutTests/http/conf/httpd.conf')
  • trunk/Tools/Scripts/webkitpy/tool/bot/flakytestreporter_unittest.py

    r90532 r91210  
    100100    def test_report_flaky_tests_creating_bug(self):
    101101        tool = MockTool()
    102         tool.filesystem = MockFileSystem({"/mock/foo/bar-diffs.txt": "mock"})
     102        tool.filesystem = MockFileSystem({"/mock-results/foo/bar-diffs.txt": "mock"})
    103103        tool.status_server = MockStatusServer(bot_id="mock-bot-id")
    104104        reporter = FlakyTestReporter(tool, 'dummy-queue')
  • trunk/Tools/Scripts/webkitpy/tool/bot/irc_command.py

    r90840 r91210  
    103103    def _update_working_copy(self, tool):
    104104        tool.scm().ensure_clean_working_directory(force_clean=True)
    105         tool.executive.run_and_throw_if_fail(tool.port().update_webkit_command(), quiet=True)
     105        tool.executive.run_and_throw_if_fail(tool.port().update_webkit_command(), quiet=True, cwd=tool.scm().checkout_root)
    106106
    107107    def execute(self, nick, args, tool, sheriff):
  • trunk/Tools/Scripts/webkitpy/tool/bot/irc_command_unittest.py

    r90840 r91210  
    8181        tool = MockTool()
    8282        tool.executive = MockExecutive(should_log=True)
    83         expected_stderr = "MOCK run_and_throw_if_fail: ['mock-update-webkit']\n"
     83        expected_stderr = "MOCK run_and_throw_if_fail: ['mock-update-webkit'], cwd=/mock-checkout\n"
    8484        OutputCapture().assert_outputs(self, rollout._update_working_copy, [tool], expected_stderr=expected_stderr)
    8585
  • trunk/Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py

    r84689 r91210  
    2626# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    28 
    29 import os
    3028
    3129from webkitpy.common.net.layouttestresults import LayoutTestResults
     
    7270        # which will not support Chromium.  However the new arch doesn't work with old-run-webkit-tests
    7371        # so we have to use this for now.
    74         return os.path.dirname(results_path)
     72        return self._tool.filesystem.dirname(results_path)
    7573
    7674    def archive(self, patch):
    7775        results_directory = self._results_directory()
    78         results_name, _ = os.path.splitext(os.path.basename(results_directory))
     76        results_name, _ = self._tool.filesystem.splitext(self._tool.filesystem.basename(results_directory))
    7977        # Note: We name the zip with the bug_id instead of patch_id to match work_item_log_path().
    8078        zip_path = self._tool.workspace.find_unused_filename(self._archive_directory, "%s-%s" % (patch.bug_id(), results_name), "zip")
  • trunk/Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader_unittest.py

    r85524 r91210  
    4040        tool = MockTool()
    4141        reader = LayoutTestResultsReader(tool, "/var/logs")
    42         results_path = '/mock/results.html'
     42        results_path = '/mock-results/results.html'
    4343        tool.filesystem = MockFileSystem({results_path: None})
    4444        # Make sure that our filesystem mock functions as we expect.
     
    6262        reader = LayoutTestResultsReader(tool, "/var/logs")
    6363        patch = tool.bugs.fetch_attachment(128)
     64        tool.filesystem = MockFileSystem()
    6465        # Should fail because the results_directory does not exist.
    65         expected_stderr = "/mock does not exist, not archiving.\n"
     66        expected_stderr = "/mock-results does not exist, not archiving.\n"
    6667        archive = OutputCapture().assert_outputs(self, reader.archive, [patch], expected_stderr=expected_stderr)
    6768        self.assertEqual(archive, None)
    6869
    69         results_directory = "/mock"
     70        results_directory = "/mock-results"
    7071        # Sanity check what we assume our mock results directory is.
    7172        self.assertEqual(reader._results_directory(), results_directory)
  • trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py

    r90513 r91210  
    126126        expected_stderr = """Processing 1 patch from 1 bug.
    127127Updating working directory
    128 MOCK run_and_throw_if_fail: ['mock-update-webkit']
     128MOCK run_and_throw_if_fail: ['mock-update-webkit'], cwd=/mock-checkout
    129129Processing patch 197 from bug 42.
    130 MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--git-commit', 'MOCK git commit', '--diff-files', 'MockFile1']
     130MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--git-commit', 'MOCK git commit', '--diff-files', 'MockFile1'], cwd=/mock-checkout
    131131"""
    132132        self.assert_execute_outputs(CheckStyle(), [197], options=self._default_options(), expected_stderr=expected_stderr, tool=MockTool(log_executive=True))
  • trunk/Tools/Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py

    r87626 r91210  
    4646        ews.bind_to_tool(MockTool())
    4747        ews._options = MockOptions(port=None, confirm=False)
    48         OutputCapture().assert_outputs(self, ews.begin_work_queue, expected_stderr=self._default_begin_work_queue_stderr(ews.name, ews._tool.scm().checkout_root))
     48        OutputCapture().assert_outputs(self, ews.begin_work_queue, expected_stderr=self._default_begin_work_queue_stderr(ews.name))
    4949        ews._expected_failures.unexpected_failures_observed = lambda results: set(["foo.html", "bar.html"])
    5050        task = Mock()
     
    6060        }
    6161        expected_stderr = {
    62             "begin_work_queue": self._default_begin_work_queue_stderr(ews.name, ews._tool.scm().checkout_root),
     62            "begin_work_queue": self._default_begin_work_queue_stderr(ews.name),
    6363            "handle_unexpected_error": "Mock error message\n",
    6464            "next_work_item": "",
  • trunk/Tools/Scripts/webkitpy/tool/commands/queues.py

    r87626 r91210  
    9696        # but the queues don't need live-progress, a dump-of-output at the
    9797        # end should be sufficient.
    98         return self._tool.executive.run_and_throw_if_fail(webkit_patch_args)
     98        return self._tool.executive.run_and_throw_if_fail(webkit_patch_args, cwd=self._tool.scm().checkout_root)
    9999
    100100    def _log_directory(self):
  • trunk/Tools/Scripts/webkitpy/tool/commands/queues_unittest.py

    r90532 r91210  
    8787            expected_run_args.append("--port=%s" % port)
    8888        expected_run_args.extend(run_args)
    89         tool.executive.run_and_throw_if_fail.assert_called_with(expected_run_args)
     89        tool.executive.run_and_throw_if_fail.assert_called_with(expected_run_args, cwd='/mock-checkout')
    9090
    9191    def test_run_webkit_patch(self):
     
    136136        tool = MockTool(log_executive=True)
    137137        expected_stderr = {
    138             "begin_work_queue": self._default_begin_work_queue_stderr("feeder-queue", MockSCM.fake_checkout_root),
     138            "begin_work_queue": self._default_begin_work_queue_stderr("feeder-queue"),
    139139            "should_proceed_with_work_item": "",
    140140            "next_work_item": "",
     
    237237    def test_commit_queue(self):
    238238        expected_stderr = {
    239             "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue", MockSCM.fake_checkout_root),
     239            "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue"),
    240240            "should_proceed_with_work_item": "MOCK: update_status: commit-queue Processing patch\n",
    241241            "next_work_item": "",
     
    256256    def test_commit_queue_failure(self):
    257257        expected_stderr = {
    258             "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue", MockSCM.fake_checkout_root),
     258            "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue"),
    259259            "should_proceed_with_work_item": "MOCK: update_status: commit-queue Processing patch\n",
    260260            "next_work_item": "",
     
    283283    def test_rollout(self):
    284284        tool = MockTool(log_executive=True)
    285         tool.filesystem.write_text_file('/mock/results.html', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
     285        tool.filesystem.write_text_file('/mock-results/results.html', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
    286286        tool.buildbot.light_tree_on_fire()
    287287        expected_stderr = {
    288             "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue", MockSCM.fake_checkout_root),
     288            "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue"),
    289289            "should_proceed_with_work_item": "MOCK: update_status: commit-queue Processing patch\n",
    290290            "next_work_item": "",
    291             "process_work_item": """MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'clean']
     291            "process_work_item": """MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'clean'], cwd=/mock-checkout
    292292MOCK: update_status: commit-queue Cleaned working directory
    293 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'update']
     293MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'update'], cwd=/mock-checkout
    294294MOCK: update_status: commit-queue Updated working directory
    295 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-attachment', '--no-update', '--non-interactive', 197]
     295MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-attachment', '--no-update', '--non-interactive', 197], cwd=/mock-checkout
    296296MOCK: update_status: commit-queue Applied patch
    297 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'build', '--no-clean', '--no-update', '--build-style=both']
     297MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'build', '--no-clean', '--no-update', '--build-style=both'], cwd=/mock-checkout
    298298MOCK: update_status: commit-queue Built patch
    299 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']
     299MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive'], cwd=/mock-checkout
    300300MOCK: update_status: commit-queue Passed tests
    301 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--ignore-builders', '--non-interactive', '--parent-command=commit-queue', 197]
     301MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--ignore-builders', '--non-interactive', '--parent-command=commit-queue', 197], cwd=/mock-checkout
    302302MOCK: update_status: commit-queue Landed patch
    303303MOCK: update_status: commit-queue Pass
     
    315315        assert(rollout_patch.is_rollout())
    316316        expected_stderr = {
    317             "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue", MockSCM.fake_checkout_root),
     317            "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue"),
    318318            "should_proceed_with_work_item": "MOCK: update_status: commit-queue Processing rollout patch\n",
    319319            "next_work_item": "",
    320             "process_work_item": """MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'clean']
     320            "process_work_item": """MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'clean'], cwd=/mock-checkout
    321321MOCK: update_status: commit-queue Cleaned working directory
    322 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'update']
     322MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'update'], cwd=/mock-checkout
    323323MOCK: update_status: commit-queue Updated working directory
    324 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-attachment', '--no-update', '--non-interactive', 106]
     324MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-attachment', '--no-update', '--non-interactive', 106], cwd=/mock-checkout
    325325MOCK: update_status: commit-queue Applied patch
    326 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--ignore-builders', '--non-interactive', '--parent-command=commit-queue', 106]
     326MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--ignore-builders', '--non-interactive', '--parent-command=commit-queue', 106], cwd=/mock-checkout
    327327MOCK: update_status: commit-queue Landed patch
    328328MOCK: update_status: commit-queue Pass
     
    352352        queue = SecondThoughtsCommitQueue(MockTool())
    353353        queue.begin_work_queue()
    354         queue._tool.filesystem.write_text_file('/mock/results.html', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
     354        queue._tool.filesystem.write_text_file('/mock-results/results.html', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
    355355        queue._options = Mock()
    356356        queue._options.port = None
     
    411411    def test_style_queue(self):
    412412        expected_stderr = {
    413             "begin_work_queue": self._default_begin_work_queue_stderr("style-queue", MockSCM.fake_checkout_root),
     413            "begin_work_queue": self._default_begin_work_queue_stderr("style-queue"),
    414414            "next_work_item": "",
    415415            "should_proceed_with_work_item": "MOCK: update_status: style-queue Checking style\n",
  • trunk/Tools/Scripts/webkitpy/tool/commands/queuestest.py

    r83795 r91210  
    6161                expected_exception=exception)
    6262
    63     def _default_begin_work_queue_stderr(self, name, checkout_dir):
     63    def _default_begin_work_queue_stderr(self, name):
     64        checkout_dir = '/mock-checkout'
    6465        string_replacements = {"name": name, 'checkout_dir': checkout_dir}
    6566        return "CAUTION: %(name)s will discard all local changes in \"%(checkout_dir)s\"\nRunning WebKit %(name)s.\nMOCK: update_status: %(name)s Starting Queue\n" % string_replacements
     
    7071            # This is a hack to make it easy for callers to not have to setup a custom MockFileSystem just to test the commit-queue
    7172            # the cq tries to read the layout test results, and will hit a KeyError in MockFileSystem if we don't do this.
    72             tool.filesystem.write_text_file('/mock/results.html', "")
     73            tool.filesystem.write_text_file('/mock-results/results.html', "")
    7374        if not expected_stdout:
    7475            expected_stdout = {}
  • trunk/Tools/Scripts/webkitpy/tool/mocktool.py

    r91144 r91210  
    480480
    481481class MockSCM(object):
    482 
    483     fake_checkout_root = os.path.realpath("/tmp") # realpath is needed to allow for Mac OS X's /private/tmp
    484 
    485482    def __init__(self, filesystem=None, executive=None):
    486         # FIXME: We should probably use real checkout-root detection logic here.
    487         # os.getcwd() can't work here because other parts of the code assume that "checkout_root"
    488         # will actually be the root.  Since getcwd() is wrong, use a globally fake root for now.
    489         self.checkout_root = self.fake_checkout_root
     483        self.checkout_root = "/mock-checkout"
    490484        self.added_paths = set()
    491485        self._filesystem = filesystem or MockFileSystem()
     
    723717        self._should_throw = should_throw
    724718
    725     def run_and_throw_if_fail(self, args, quiet=False):
     719    def run_and_throw_if_fail(self, args, quiet=False, cwd=None):
    726720        if self._should_log:
    727             log("MOCK run_and_throw_if_fail: %s" % args)
     721            log("MOCK run_and_throw_if_fail: %s, cwd=%s" % (args, cwd))
    728722        return "MOCK output of child process"
    729723
     
    737731                    decode_output=False):
    738732        if self._should_log:
    739             log("MOCK run_command: %s" % args)
     733            log("MOCK run_command: %s, cwd=%s" % (args, cwd))
    740734        if self._should_throw:
    741735            raise ScriptError("MOCK ScriptError")
     
    761755
    762756    def layout_tests_results_path(self):
    763         return "/mock/results.html"
     757        return "/mock-results/results.html"
    764758
    765759    def check_webkit_style_command(self):
  • trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py

    r91144 r91210  
    5454
    5555    def _run_webkit_patch(self, args):
    56         return self.server.tool.executive.run_command([self.server.tool.path()] + args)
     56        return self.server.tool.executive.run_command([self.server.tool.path()] + args, cwd=self.server.tool.scm().checkout_root)
    5757
    5858    def changelog(self):
     
    6262            # Updating the working copy could conflict with any rebaselines we have in progress.
    6363            update_webkit_command = self.server.tool.port().update_webkit_command()
    64             self.server.tool.executive.run_and_throw_if_fail(update_webkit_command, quiet=True)
     64            self.server.tool.executive.run_and_throw_if_fail(update_webkit_command, quiet=True, cwd=self.server.tool.scm().checkout_root)
    6565        commit_info = self.server.tool.checkout().commit_info_for_revision(revision)
    6666        if not commit_info:
  • trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py

    r91144 r91210  
    7171
    7272    def test_changelog(self):
    73         expected_stderr = "MOCK run_and_throw_if_fail: ['mock-update-webkit']\n"
     73        expected_stderr = "MOCK run_and_throw_if_fail: ['mock-update-webkit'], cwd=/mock-checkout\n"
    7474        expected_stdout = """== Begin JSON Response ==
    7575{"bug_id": 42, "author_email": "abarth@webkit.org", "reviewer_text": "Darin Adler", "author_name": "Adam Barth", "changed_files": ["path/to/file", "another/file"]}
     
    8383
    8484    def test_rollout(self):
    85         expected_stderr = "MOCK run_command: ['echo', 'rollout', '--force-clean', '--non-interactive', '2314', 'MOCK rollout reason']\n"
     85        expected_stderr = "MOCK run_command: ['echo', 'rollout', '--force-clean', '--non-interactive', '2314', 'MOCK rollout reason'], cwd=/mock-checkout\n"
    8686        expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
    8787        self._post_to_path("/rollout?revision=2314&reason=MOCK+rollout+reason", expected_stderr=expected_stderr, expected_stdout=expected_stdout)
    8888
    8989    def test_rebaseline(self):
    90         expected_stderr = "MOCK run_command: ['echo', 'rebaseline-test', 'MOCK builder', 'user-scripts/another-test.html', 'txt']\n"
     90        expected_stderr = "MOCK run_command: ['echo', 'rebaseline-test', 'MOCK builder', 'user-scripts/another-test.html', 'txt'], cwd=/mock-checkout\n"
    9191        expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
    9292        self._post_to_path("/rebaseline?builder=MOCK+builder&test=user-scripts/another-test.html&suffix=txt", expected_stderr=expected_stderr, expected_stdout=expected_stdout)
  • trunk/Tools/Scripts/webkitpy/tool/servers/rebaselineserver_unittest.py

    r90546 r91210  
    293293def get_test_config(test_files=[], result_files=[]):
    294294    # We could grab this from port.layout_tests_dir(), but instantiating a fully mocked port is a pain.
    295     layout_tests_directory = "/mock/LayoutTests"
     295    layout_tests_directory = "/mock-checkout/LayoutTests"
    296296    results_directory = '/WebKitBuild/Debug/layout-test-results'
    297297    mock_filesystem = filesystem_mock.MockFileSystem()
  • trunk/Tools/Scripts/webkitpy/tool/steps/build.py

    r69829 r91210  
    4242
    4343    def build(self, build_style):
    44         self._tool.executive.run_and_throw_if_fail(self._tool.port().build_webkit_command(build_style=build_style), self._options.quiet)
     44        self._tool.executive.run_and_throw_if_fail(self._tool.port().build_webkit_command(build_style=build_style), self._options.quiet, cwd=self._tool.scm().checkout_root)
    4545
    4646    def run(self, state):
  • trunk/Tools/Scripts/webkitpy/tool/steps/checkstyle.py

    r83158 r91210  
    4646        if not self._options.check_style:
    4747            return
    48         os.chdir(self._tool.scm().checkout_root)
    4948
    5049        args = []
     
    5756
    5857        try:
    59             self._tool.executive.run_and_throw_if_fail(self._tool.port().check_webkit_style_command() + args)
     58            self._tool.executive.run_and_throw_if_fail(self._tool.port().check_webkit_style_command() + args, cwd=self._tool.scm().checkout_root)
    6059        except ScriptError, e:
    6160            if self._options.non_interactive:
  • trunk/Tools/Scripts/webkitpy/tool/steps/cleanworkingdirectory_unittest.py

    r90978 r91210  
    3838        tool = MockTool()
    3939        tool._scm = Mock()
    40         tool._scm.checkout_root = '/mock'
     40        tool._scm.checkout_root = '/mock-checkout'
    4141        step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=False))
    4242        step.run({})
  • trunk/Tools/Scripts/webkitpy/tool/steps/editchangelog.py

    r70059 r91210  
    3434class EditChangeLog(AbstractStep):
    3535    def run(self, state):
    36         os.chdir(self._tool.scm().checkout_root)
    37         self._tool.user.edit_changelog(self.cached_lookup(state, "changelogs"))
     36        absolute_paths = map(self._tool.scm().absolute_path, self.cached_lookup(state, "changelogs"))
     37        self._tool.user.edit_changelog(absolute_paths)
    3838        self.did_modify_checkout(state)
  • trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelog.py

    r82771 r91210  
    6161            self._ensure_bug_url(state)
    6262            return
    63         os.chdir(self._tool.scm().checkout_root)
    6463        args = self._tool.port().prepare_changelog_command()
    6564        if state.get("bug_id"):
     
    7574
    7675        try:
    77             self._tool.executive.run_and_throw_if_fail(args, self._options.quiet)
     76            self._tool.executive.run_and_throw_if_fail(args, self._options.quiet, cwd=self._tool.scm().checkout_root)
    7877        except ScriptError, e:
    7978            error("Unable to prepare ChangeLogs.")
  • trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelogforrevert.py

    r82771 r91210  
    5151    def run(self, state):
    5252        # This could move to prepare-ChangeLog by adding a --revert= option.
    53         self._tool.executive.run_and_throw_if_fail(self._tool.port().prepare_changelog_command())
     53        self._tool.executive.run_and_throw_if_fail(self._tool.port().prepare_changelog_command(), cwd=self._tool.scm().checkout_root)
    5454        changelog_paths = self._tool.checkout().modified_changelogs(git_commit=None)
    5555        bug_url = self._tool.bugs.bug_url_for_bug_id(state["bug_id"]) if state["bug_id"] else None
  • trunk/Tools/Scripts/webkitpy/tool/steps/runtests.py

    r89289 r91210  
    5050        if python_unittests_command:
    5151            log("Running Python unit tests")
    52             self._tool.executive.run_and_throw_if_fail(python_unittests_command)
     52            self._tool.executive.run_and_throw_if_fail(python_unittests_command, cwd=self._tool.scm().checkout_root)
    5353
    5454        perl_unittests_command = self._tool.port().run_perl_unittests_command()
    5555        if perl_unittests_command:
    5656            log("Running Perl unit tests")
    57             self._tool.executive.run_and_throw_if_fail(perl_unittests_command)
     57            self._tool.executive.run_and_throw_if_fail(perl_unittests_command, cwd=self._tool.scm().checkout_root)
    5858
    5959        bindings_tests_command = self._tool.port().run_bindings_tests_command()
    6060        if bindings_tests_command:
    6161            log("Running Bindings tests")
    62             self._tool.executive.run_and_throw_if_fail(bindings_tests_command)
     62            self._tool.executive.run_and_throw_if_fail(bindings_tests_command, cwd=self._tool.scm().checkout_root)
    6363
    6464        javascriptcore_tests_command = self._tool.port().run_javascriptcore_tests_command()
    6565        if javascriptcore_tests_command:
    6666            log("Running JavaScriptCore tests")
    67             self._tool.executive.run_and_throw_if_fail(javascriptcore_tests_command, quiet=True)
     67            self._tool.executive.run_and_throw_if_fail(javascriptcore_tests_command, quiet=True, cwd=self._tool.scm().checkout_root)
    6868
    6969        log("Running run-webkit-tests")
     
    7676        if self._options.quiet:
    7777            args.append("--quiet")
    78         self._tool.executive.run_and_throw_if_fail(args)
     78        self._tool.executive.run_and_throw_if_fail(args, cwd=self._tool.scm().checkout_root)
    7979
  • trunk/Tools/Scripts/webkitpy/tool/steps/steps_unittest.py

    r89289 r91210  
    7777        step = RunTests(tool, mock_options)
    7878        expected_stderr = """Running Python unit tests
    79 MOCK run_and_throw_if_fail: ['Tools/Scripts/test-webkitpy']
     79MOCK run_and_throw_if_fail: ['Tools/Scripts/test-webkitpy'], cwd=/mock-checkout
    8080Running Perl unit tests
    81 MOCK run_and_throw_if_fail: ['Tools/Scripts/test-webkitperl']
     81MOCK run_and_throw_if_fail: ['Tools/Scripts/test-webkitperl'], cwd=/mock-checkout
    8282Running Bindings tests
    83 MOCK run_and_throw_if_fail: ['Tools/Scripts/run-bindings-tests']
     83MOCK run_and_throw_if_fail: ['Tools/Scripts/run-bindings-tests'], cwd=/mock-checkout
    8484Running JavaScriptCore tests
    85 MOCK run_and_throw_if_fail: ['Tools/Scripts/run-javascriptcore-tests']
     85MOCK run_and_throw_if_fail: ['Tools/Scripts/run-javascriptcore-tests'], cwd=/mock-checkout
    8686Running run-webkit-tests
    87 MOCK run_and_throw_if_fail: ['Tools/Scripts/run-webkit-tests', '--no-new-test-results', '--no-launch-safari', '--exit-after-n-failures=20', '--quiet']
     87MOCK run_and_throw_if_fail: ['Tools/Scripts/run-webkit-tests', '--no-new-test-results', '--no-launch-safari', '--exit-after-n-failures=20', '--quiet'], cwd=/mock-checkout
    8888"""
    8989        OutputCapture().assert_outputs(self, step.run, [{}], expected_stderr=expected_stderr)
  • trunk/Tools/Scripts/webkitpy/tool/steps/update.py

    r74914 r91210  
    4444            return
    4545        log("Updating working directory")
    46         self._tool.executive.run_and_throw_if_fail(self._tool.port().update_webkit_command(), quiet=self._options.quiet)
     46        self._tool.executive.run_and_throw_if_fail(self._tool.port().update_webkit_command(), quiet=self._options.quiet, cwd=self._tool.scm().checkout_root)
Note: See TracChangeset for help on using the changeset viewer.