1 # Copyright (C) 2009 Google Inc. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
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
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.
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.
31 from optparse import make_option
33 from modules.logging import log, error
34 from modules.processutils import run_and_throw_if_fail
35 from modules.webkitport import WebKitPort
38 # FIXME: The options should really live on each "Step" object.
40 def cleaning_options():
42 make_option("--force-clean", action="store_true", dest="force_clean", default=False, help="Clean working directory before applying patches (removes local changes and commits)"),
43 make_option("--no-clean", action="store_false", dest="clean", default=True, help="Don't check if the working directory is clean before applying patches"),
49 make_option("--ignore-builders", action="store_false", dest="check_builders", default=True, help="Don't check to see if the build.webkit.org builders are green before landing."),
50 make_option("--quiet", action="store_true", dest="quiet", default=False, help="Produce less console output."),
51 make_option("--non-interactive", action="store_true", dest="non_interactive", default=False, help="Never prompt the user, fail as fast as possible."),
52 make_option("--parent-command", action="store", dest="parent_command", default=None, help="(Internal) The command that spawned this instance."),
53 ] + WebKitPort.port_options()
58 make_option("--no-update", action="store_false", dest="update", default=True, help="Don't update the working directory."),
59 make_option("--no-build", action="store_false", dest="build", default=True, help="Commit without building first, implies --no-test."),
60 make_option("--no-test", action="store_false", dest="test", default=True, help="Commit without running run-webkit-tests."),
61 make_option("--no-close", action="store_false", dest="close_bug", default=True, help="Leave bug open after landing."),
64 def _run_script(cls, script_name, quiet=False, port=WebKitPort):
65 log("Running %s" % script_name)
66 run_and_throw_if_fail(port.script_path(script_name), quiet)
68 def prepare_changelog(self):
69 self.run_script("prepare-ChangeLog")
71 def clean_working_directory(self, scm, options, allow_local_commits=False):
72 os.chdir(scm.checkout_root)
73 if not allow_local_commits:
74 scm.ensure_no_local_commits(options.force_clean)
76 scm.ensure_clean_working_directory(force_clean=options.force_clean)
78 def run_tests(self, launch_safari, fail_fast=False, quiet=False, port=WebKitPort):
79 args = port.run_webkit_tests_command()
81 args.append("--no-launch-safari")
83 args.append("--quiet")
85 args.append("--exit-after-n-failures=1")
86 run_and_throw_if_fail(args)
88 def ensure_builders_are_green(self, buildbot, options):
89 if not options.check_builders or buildbot.core_builders_are_green():
91 error("Builders at %s are red, please do not commit. Pass --ignore-builders to bypass this check." % (buildbot.buildbot_host))
93 def build_webkit(self, quiet=False, port=WebKitPort):
94 log("Building WebKit")
95 run_and_throw_if_fail(port.build_webkit_command(), quiet)
97 def check_style(self):
98 self._run_script("check-webkit-style")