Make NRWT show DRT/WTR build logs when the build fails or --verbose is passed
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Nov 2011 19:12:36 +0000 (19:12 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Nov 2011 19:12:36 +0000 (19:12 +0000)
This will make it a lot easier to investigate build failures on the bots.

Fixes <http://webkit.org/b/71160> NRWT doesn't show build output when building DRT

Reviewed by Eric Seidel.

* Scripts/webkitpy/common/system/executive_mock.py:
(MockExecutive.run_command): Include the mock output in the ScriptError we raise since it
makes the expected output in WebKitPortTest.test_build_driver more closely mimic the output
seen in practice.

* Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
(ManagerTest.test_http_locking): Pass False for the configure_logging parameter to Printer.
The Printer was modifying the root logger in way that would cause my new tests in
WebKitPort.test_build_driver to fail. The value of the configure_logging parameter doesn't
seem important to the functioning of this test, and passing False makes Printer not modify
the root logger.

* Scripts/webkitpy/layout_tests/port/webkit.py:
(WebKitPort._run_script): Log the output of the command at the DEBUG level so it will show
up when --verbose is passed but not otherwise.
(WebKitPort._build_driver): When an error occurs, log the error message and the script's
output at the ERROR level so it will always show up.

* Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
(WebKitPortTest.test_build_driver): Test that nothing is logged in the normal, successful
cases. Test that the build scripts' output is logged when --verbose is passed or the build
fails.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@101534 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/system/executive_mock.py
Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py
Tools/Scripts/webkitpy/layout_tests/port/webkit.py
Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py

index 4290aa5..7d26216 100644 (file)
@@ -1,5 +1,38 @@
 2011-11-30  Adam Roben  <aroben@apple.com>
 
+        Make NRWT show DRT/WTR build logs when the build fails or --verbose is passed
+
+        This will make it a lot easier to investigate build failures on the bots.
+
+        Fixes <http://webkit.org/b/71160> NRWT doesn't show build output when building DRT
+
+        Reviewed by Eric Seidel.
+
+        * Scripts/webkitpy/common/system/executive_mock.py:
+        (MockExecutive.run_command): Include the mock output in the ScriptError we raise since it
+        makes the expected output in WebKitPortTest.test_build_driver more closely mimic the output
+        seen in practice.
+
+        * Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
+        (ManagerTest.test_http_locking): Pass False for the configure_logging parameter to Printer.
+        The Printer was modifying the root logger in way that would cause my new tests in
+        WebKitPort.test_build_driver to fail. The value of the configure_logging parameter doesn't
+        seem important to the functioning of this test, and passing False makes Printer not modify
+        the root logger.
+
+        * Scripts/webkitpy/layout_tests/port/webkit.py:
+        (WebKitPort._run_script): Log the output of the command at the DEBUG level so it will show
+        up when --verbose is passed but not otherwise.
+        (WebKitPort._build_driver): When an error occurs, log the error message and the script's
+        output at the ERROR level so it will always show up.
+
+        * Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
+        (WebKitPortTest.test_build_driver): Test that nothing is logged in the normal, successful
+        cases. Test that the build scripts' output is logged when --verbose is passed or the build
+        fails.
+
+2011-11-30  Adam Roben  <aroben@apple.com>
+
         Add a way to set OutputCapture's log level
 
         This will be used by some unit tests I'm planning to add.
index 8b39668..0bc3c56 100644 (file)
@@ -69,9 +69,10 @@ class MockExecutive(object):
             if env:
                 env_string = ", env=%s" % env
             log("MOCK run_command: %s, cwd=%s%s" % (args, cwd, env_string))
+        output = "MOCK output of child process"
         if self._should_throw:
-            raise ScriptError("MOCK ScriptError")
-        return "MOCK output of child process"
+            raise ScriptError("MOCK ScriptError", output=output)
+        return output
 
 
 class MockExecutive2(object):
index 11ac453..ee846ed 100644 (file)
@@ -190,7 +190,7 @@ class ManagerTest(unittest.TestCase):
         host = MockHost()
         port = host.port_factory.get(port_name=options.platform, options=options)
         run_webkit_tests._set_up_derived_options(port, options)
-        printer = printing.Printer(port, options, StringIO.StringIO(), StringIO.StringIO(), configure_logging=True)
+        printer = printing.Printer(port, options, StringIO.StringIO(), StringIO.StringIO(), configure_logging=False)
         manager = LockCheckingManager(port, options, printer)
         manager.collect_tests(args)
         manager.parse_expectations()
index de3e893..619ff59 100644 (file)
@@ -103,7 +103,9 @@ class WebKitPort(Port):
             run_script_command.extend(self._arguments_for_configuration())
         if args:
             run_script_command.extend(args)
-        return self._executive.run_command(run_script_command, cwd=self._config.webkit_base_dir(), decode_output=decode_output, env=env)
+        output = self._executive.run_command(run_script_command, cwd=self._config.webkit_base_dir(), decode_output=decode_output, env=env)
+        _log.debug('Output of %s:\n%s' % (run_script_command, output))
+        return output
 
     def _build_driver(self):
         environment = self.host.copy_current_environment()
@@ -119,8 +121,8 @@ class WebKitPort(Port):
             self._run_script("build-dumprendertree", env=env)
             if self.get_option('webkit_test_runner'):
                 self._run_script("build-webkittestrunner", env=env)
-        except ScriptError:
-            _log.error("Failed to build %s" % self.driver_name())
+        except ScriptError, e:
+            _log.error(e.message_with_output(output_limit=None))
             return False
         return True
 
index 768c66f..910559a 100755 (executable)
@@ -25,6 +25,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import logging
 import unittest
 
 from webkitpy.common.host_mock import MockHost
@@ -178,18 +179,27 @@ BUG_SKIPPED SKIP : media = FAIL""")
         port._executive = MockExecutive(should_log=True)
         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).
         expected_stderr = "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'}\n"
-        self.assertTrue(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr))
+        self.assertTrue(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr, expected_logs=''))
 
-        # Make sure when passed --webkit-test-runner web build the right tool.
+        # Make sure when passed --webkit-test-runner we build the right tool.
         port._options = MockOptions(webkit_test_runner=True, configuration="Release")
         expected_stderr = "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'}\nMOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'}\n"
-        self.assertTrue(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr))
+        self.assertTrue(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr, expected_logs=''))
+
+        # Make sure we show the build log when --verbose is passed, which we simulate by setting the logging level to DEBUG.
+        output.set_log_level(logging.DEBUG)
+        port._options = MockOptions(configuration="Release")
+        expected_stderr = "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'}\n"
+        expected_logs = "Output of ['Tools/Scripts/build-dumprendertree', '--release']:\nMOCK output of child process\n"
+        self.assertTrue(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr, expected_logs=expected_logs))
+        output.set_log_level(logging.INFO)
 
         # Make sure that failure to build returns False.
         port._executive = MockExecutive(should_log=True, should_throw=True)
         # Because WK2 currently has to build both webkittestrunner and DRT, if DRT fails, that's the only one it tries.
         expected_stderr = "MOCK run_command: ['Tools/Scripts/build-dumprendertree', '--release'], cwd=/mock-checkout, env={'LC_ALL': 'C', 'MOCK_ENVIRON_COPY': '1'}\n"
-        self.assertFalse(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr))
+        expected_logs = "MOCK ScriptError\n\nMOCK output of child process\n"
+        self.assertFalse(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr, expected_logs=expected_logs))
 
     def _assert_config_file_for_platform(self, port, platform, config_file):
         self.assertEquals(port._apache_config_file_name_for_platform(platform), config_file)