1 # Copyright (C) 2010 Google Inc. All rights reserved. 2 # 3 # Redistribution and use in source and binary forms, with or without 4 # modification, are permitted provided that the following conditions are 5 # met: 6 # 7 # * Redistributions of source code must retain the above copyright 8 # notice, this list of conditions and the following disclaimer. 9 # * Redistributions in binary form must reproduce the above 10 # copyright notice, this list of conditions and the following disclaimer 11 # in the documentation and/or other materials provided with the 12 # distribution. 13 # * Neither the name of Google Inc. nor the names of its 14 # contributors may be used to endorse or promote products derived from 15 # this software without specific prior written permission. 16 # 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29 import logging 30 import os 31 import platform 32 import sys 33 from webkitpy.tool.steps.abstractstep import AbstractStep 34 from webkitpy.tool.steps.options import Options 35 from webkitpy.common.system.executive import ScriptError 36 37 _log = logging.getLogger(__name__) 38 39 class RunTests(AbstractStep): 40 # FIXME: This knowledge really belongs in the commit-queue. 41 NON_INTERACTIVE_FAILURE_LIMIT_COUNT = 30 42 43 @classmethod 44 def options(cls): 45 return AbstractStep.options() + [ 46 Options.build_style, 47 Options.test, 48 Options.non_interactive, 49 Options.quiet, 50 ] 51 52 def run(self, state): 53 if not self._options.test: 54 return 55 56 if not self._options.non_interactive: 57 # FIXME: We should teach the commit-queue and the EWS how to run these tests. 58 59 python_unittests_command = self._tool.deprecated_port().run_python_unittests_command() 60 if python_unittests_command: 61 _log.info("Running Python unit tests") 62 self._tool.executive.run_and_throw_if_fail(python_unittests_command, cwd=self._tool.scm().checkout_root) 63 64 perl_unittests_command = self._tool.deprecated_port().run_perl_unittests_command() 65 if perl_unittests_command: 66 _log.info("Running Perl unit tests") 67 self._tool.executive.run_and_throw_if_fail(perl_unittests_command, cwd=self._tool.scm().checkout_root) 68 69 bindings_tests_command = self._tool.deprecated_port().run_bindings_tests_command() 70 if bindings_tests_command: 71 _log.info("Running bindings generation tests") 72 args = bindings_tests_command 73 try: 74 self._tool.executive.run_and_throw_if_fail(args, cwd=self._tool.scm().checkout_root) 75 except ScriptError, e: 76 _log.info("Error running run-bindings-tests: %s" % e.message_with_output()) 77 78 webkit_unit_tests_command = self._tool.deprecated_port().run_webkit_unit_tests_command() 79 if webkit_unit_tests_command: 80 _log.info("Running WebKit unit tests") 81 args = webkit_unit_tests_command 82 try: 83 self._tool.executive.run_and_throw_if_fail(args, cwd=self._tool.scm().checkout_root) 84 except ScriptError, e: 85 _log.info("Error running webkit_unit_tests: %s" % e.message_with_output()) 86 87 88 _log.info("Running run-webkit-tests") 89 args = self._tool.deprecated_port().run_webkit_tests_command() 90 if self._options.non_interactive: 91 args.extend([ 92 "--no-new-test-results", 93 "--no-show-results", 94 "--exit-after-n-failures=%s" % self.NON_INTERACTIVE_FAILURE_LIMIT_COUNT, 95 ]) 96 97 # old-run-webkit-tests does not support --skip-failing-tests 98 # Using --quiet one Windows fails when we try to use /dev/null, disabling for now until we find a fix 99 if sys.platform != "cygwin": 100 args.append("--quiet") 101 args.append("--skip-failing-tests") 102 else: 103 args.append("--no-build"); 104 105 if self._options.quiet: 106 args.append("--quiet") 107 108 self._tool.executive.run_and_throw_if_fail(args, cwd=self._tool.scm().checkout_root) 109