Changeset 51888 in webkit


Ignore:
Timestamp:
Dec 8, 2009 11:51:39 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-08 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

run_command and ScriptError should move into processutils.py
https://bugs.webkit.org/show_bug.cgi?id=32305

Turns out there are a zillion callers to run_command.

  • Scripts/modules/commands/download.py:
  • Scripts/modules/commands/early_warning_system.py:
  • Scripts/modules/commands/queues.py:
  • Scripts/modules/landingsequence.py:
  • Scripts/modules/logging_unittest.py:
  • Scripts/modules/processutils.py:
  • Scripts/modules/scm.py:
  • Scripts/modules/scm_unittest.py:
  • Scripts/modules/workqueue.py:
  • Scripts/modules/workqueue_unittest.py:
Location:
trunk/WebKitTools
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r51880 r51888  
     12009-12-08  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        run_command and ScriptError should move into processutils.py
     6        https://bugs.webkit.org/show_bug.cgi?id=32305
     7
     8        Turns out there are a zillion callers to run_command.
     9
     10        * Scripts/modules/commands/download.py:
     11        * Scripts/modules/commands/early_warning_system.py:
     12        * Scripts/modules/commands/queues.py:
     13        * Scripts/modules/landingsequence.py:
     14        * Scripts/modules/logging_unittest.py:
     15        * Scripts/modules/processutils.py:
     16        * Scripts/modules/scm.py:
     17        * Scripts/modules/scm_unittest.py:
     18        * Scripts/modules/workqueue.py:
     19        * Scripts/modules/workqueue_unittest.py:
     20
    1212009-12-08  Kevin Watters  <kevinwatters@gmail.com>
    222
  • trunk/WebKitTools/Scripts/modules/commands/download.py

    r51750 r51888  
    4141from modules.logging import error, log
    4242from modules.multicommandtool import Command
    43 from modules.scm import ScriptError
     43from modules.processutils import ScriptError
    4444
    4545
  • trunk/WebKitTools/Scripts/modules/commands/early_warning_system.py

    r51746 r51888  
    2929
    3030from modules.commands.queues import AbstractReviewQueue
    31 from modules.scm import ScriptError
     31from modules.processutils import ScriptError
    3232from modules.webkitport import WebKitPort
    3333
  • trunk/WebKitTools/Scripts/modules/commands/queues.py

    r51746 r51888  
    3939from modules.multicommandtool import Command
    4040from modules.patchcollection import PatchCollection, PersistentPatchCollection, PersistentPatchCollectionDelegate
    41 from modules.processutils import run_and_throw_if_fail
    42 from modules.scm import ScriptError
     41from modules.processutils import run_and_throw_if_fail, ScriptError
    4342from modules.statusbot import StatusBot
    4443from modules.workqueue import WorkQueue, WorkQueueDelegate
  • trunk/WebKitTools/Scripts/modules/landingsequence.py

    r51749 r51888  
    3131from modules.comments import bug_comment_from_commit_text
    3232from modules.logging import log
    33 from modules.scm import ScriptError, CheckoutNeedsUpdate
     33from modules.processutils import ScriptError
     34from modules.scm import CheckoutNeedsUpdate
    3435from modules.webkitport import WebKitPort
    3536from modules.workqueue import WorkQueue
  • trunk/WebKitTools/Scripts/modules/logging_unittest.py

    r48762 r51888  
    3434
    3535from modules.logging import *
    36 from modules.scm import ScriptError
     36from modules.processutils import ScriptError
    3737
    3838class LoggingTest(unittest.TestCase):
  • trunk/WebKitTools/Scripts/modules/processutils.py

    r51435 r51888  
    3434
    3535from modules.logging import tee
    36 from modules.scm import ScriptError
     36
     37# FIXME: These methods could all be unified into one!
     38
     39class ScriptError(Exception):
     40    def __init__(self, message=None, script_args=None, exit_code=None, output=None, cwd=None):
     41        if not message:
     42            message = 'Failed to run "%s"' % script_args
     43            if exit_code:
     44                message += " exit_code: %d" % exit_code
     45            if cwd:
     46                message += " cwd: %s" % cwd
     47
     48        Exception.__init__(self, message)
     49        self.script_args = script_args # 'args' is already used by Exception
     50        self.exit_code = exit_code
     51        self.output = output
     52        self.cwd = cwd
     53
     54    def message_with_output(self, output_limit=500):
     55        if self.output:
     56            if output_limit and len(self.output) > output_limit:
     57                 return "%s\nLast %s characters of output:\n%s" % (self, output_limit, self.output[-output_limit:])
     58            return "%s\n%s" % (self, self.output)
     59        return str(self)
     60
     61def default_error_handler(error):
     62    raise error
     63
     64def ignore_error(error):
     65    pass
    3766
    3867def run_command_with_teed_output(args, teed_output):
     
    4675            return child_process.poll()
    4776        teed_output.write(output_line)
     77
     78def run_command(args, cwd=None, input=None, error_handler=default_error_handler, return_exit_code=False, return_stderr=True):
     79    if hasattr(input, 'read'): # Check if the input is a file.
     80        stdin = input
     81        string_to_communicate = None
     82    else:
     83        stdin = subprocess.PIPE if input else None
     84        string_to_communicate = input
     85    if return_stderr:
     86        stderr = subprocess.STDOUT
     87    else:
     88        stderr = None
     89    process = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, cwd=cwd)
     90    output = process.communicate(string_to_communicate)[0]
     91    exit_code = process.wait()
     92    if exit_code:
     93        script_error = ScriptError(script_args=args, exit_code=exit_code, output=output, cwd=cwd)
     94        error_handler(script_error)
     95    if return_exit_code:
     96        return exit_code
     97    return output
    4898
    4999def run_and_throw_if_fail(args, quiet=False):
  • trunk/WebKitTools/Scripts/modules/scm.py

    r51729 r51888  
    3737from modules.changelogs import ChangeLog
    3838from modules.logging import error, log
     39from modules.processutils import run_command, ScriptError, default_error_handler, ignore_error
    3940
    4041def detect_scm_system(path):
     
    7980
    8081
    81 class ScriptError(Exception):
    82     def __init__(self, message=None, script_args=None, exit_code=None, output=None, cwd=None):
    83         if not message:
    84             message = 'Failed to run "%s"' % script_args
    85             if exit_code:
    86                 message += " exit_code: %d" % exit_code
    87             if cwd:
    88                 message += " cwd: %s" % cwd
    89 
    90         Exception.__init__(self, message)
    91         self.script_args = script_args # 'args' is already used by Exception
    92         self.exit_code = exit_code
    93         self.output = output
    94         self.cwd = cwd
    95 
    96     def message_with_output(self, output_limit=500):
    97         if self.output:
    98             if output_limit and len(self.output) > output_limit:
    99                  return "%s\nLast %s characters of output:\n%s" % (self, output_limit, self.output[-output_limit:])
    100             return "%s\n%s" % (self, self.output)
    101         return str(self)
    102 
    103 
    10482class CheckoutNeedsUpdate(ScriptError):
    10583    def __init__(self, script_args, exit_code, output, cwd):
    10684        ScriptError.__init__(self, script_args=script_args, exit_code=exit_code, output=output, cwd=cwd)
    10785
    108 
    109 def default_error_handler(error):
    110     raise error
    11186
    11287def commit_error_handler(error):
     
    11590    default_error_handler(error)
    11691
    117 def ignore_error(error):
    118     pass
    11992
    12093class SCM:
     
    12497        self.dryrun = dryrun
    12598
    126     @staticmethod
    127     def run_command(args, cwd=None, input=None, error_handler=default_error_handler, return_exit_code=False, return_stderr=True):
    128         if hasattr(input, 'read'): # Check if the input is a file.
    129             stdin = input
    130             string_to_communicate = None
    131         else:
    132             stdin = subprocess.PIPE if input else None
    133             string_to_communicate = input
    134         if return_stderr:
    135             stderr = subprocess.STDOUT
    136         else:
    137             stderr = None
    138         process = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, cwd=cwd)
    139         output = process.communicate(string_to_communicate)[0]
    140         exit_code = process.wait()
    141         if exit_code:
    142             script_error = ScriptError(script_args=args, exit_code=exit_code, output=output, cwd=cwd)
    143             error_handler(script_error)
    144         if return_exit_code:
    145             return exit_code
    146         return output
    147 
    14899    def scripts_directory(self):
    149100        return os.path.join(self.checkout_root, "WebKitTools", "Scripts")
     
    154105    def ensure_clean_working_directory(self, force_clean):
    155106        if not force_clean and not self.working_directory_is_clean():
    156             print self.run_command(self.status_command(), error_handler=ignore_error)
     107            print run_command(self.status_command(), error_handler=ignore_error)
    157108            raise ScriptError(message="Working directory has modifications, pass --force-clean or --no-clean to continue.")
    158109       
     
    180131            args.append('--force')
    181132
    182         self.run_command(args, input=curl_process.stdout)
     133        run_command(args, input=curl_process.stdout)
    183134
    184135    def run_status_and_extract_filenames(self, status_command, status_regexp):
    185136        filenames = []
    186         for line in self.run_command(status_command).splitlines():
     137        for line in run_command(status_command).splitlines():
    187138            match = re.search(status_regexp, line)
    188139            if not match:
     
    322273    def value_from_svn_info(cls, path, field_name):
    323274        svn_info_args = ['svn', 'info', path]
    324         info_output = cls.run_command(svn_info_args).rstrip()
     275        info_output = run_command(svn_info_args).rstrip()
    325276        match = re.search("^%s: (?P<value>.+)$" % field_name, info_output, re.MULTILINE)
    326277        if not match:
     
    350301    def svn_version(self):
    351302        if not self.cached_version:
    352             self.cached_version = self.run_command(['svn', '--version', '--quiet'])
     303            self.cached_version = run_command(['svn', '--version', '--quiet'])
    353304       
    354305        return self.cached_version
    355306
    356307    def working_directory_is_clean(self):
    357         return self.run_command(['svn', 'diff']) == ""
     308        return run_command(['svn', 'diff']) == ""
    358309
    359310    def clean_working_directory(self):
    360         self.run_command(['svn', 'revert', '-R', '.'])
     311        run_command(['svn', 'revert', '-R', '.'])
    361312
    362313    def status_command(self):
     
    378329
    379330    def create_patch(self):
    380         return self.run_command(self.script_path("svn-create-patch"), cwd=self.checkout_root, return_stderr=False)
     331        return run_command(self.script_path("svn-create-patch"), cwd=self.checkout_root, return_stderr=False)
    381332
    382333    def diff_for_revision(self, revision):
    383         return self.run_command(['svn', 'diff', '-c', str(revision)])
     334        return run_command(['svn', 'diff', '-c', str(revision)])
    384335
    385336    def _repository_url(self):
     
    391342        log("WARNING: svn merge has been known to take more than 10 minutes to complete.  It is recommended you use git for rollouts.")
    392343        log("Running '%s'" % " ".join(svn_merge_args))
    393         self.run_command(svn_merge_args)
     344        run_command(svn_merge_args)
    394345
    395346    def revert_files(self, file_paths):
    396         self.run_command(['svn', 'revert'] + file_paths)
     347        run_command(['svn', 'revert'] + file_paths)
    397348
    398349    def commit_with_message(self, message):
     
    400351            # Return a string which looks like a commit so that things which parse this output will succeed.
    401352            return "Dry run, no commit.\nCommitted revision 0."
    402         return self.run_command(['svn', 'commit', '-m', message], error_handler=commit_error_handler)
     353        return run_command(['svn', 'commit', '-m', message], error_handler=commit_error_handler)
    403354
    404355    def svn_commit_log(self, svn_revision):
    405356        svn_revision = self.strip_r_from_svn_revision(str(svn_revision))
    406         return self.run_command(['svn', 'log', '--non-interactive', '--revision', svn_revision]);
     357        return run_command(['svn', 'log', '--non-interactive', '--revision', svn_revision]);
    407358
    408359    def last_svn_commit_log(self):
     
    418369    @classmethod
    419370    def in_working_directory(cls, path):
    420         return cls.run_command(['git', 'rev-parse', '--is-inside-work-tree'], cwd=path, error_handler=ignore_error).rstrip() == "true"
     371        return run_command(['git', 'rev-parse', '--is-inside-work-tree'], cwd=path, error_handler=ignore_error).rstrip() == "true"
    421372
    422373    @classmethod
    423374    def find_checkout_root(cls, path):
    424375        # "git rev-parse --show-cdup" would be another way to get to the root
    425         (checkout_root, dot_git) = os.path.split(cls.run_command(['git', 'rev-parse', '--git-dir'], cwd=path))
     376        (checkout_root, dot_git) = os.path.split(run_command(['git', 'rev-parse', '--git-dir'], cwd=path))
    426377        # If we were using 2.6 # checkout_root = os.path.relpath(checkout_root, path)
    427378        if not os.path.isabs(checkout_root): # Sometimes git returns relative paths
     
    435386
    436387    def discard_local_commits(self):
    437         self.run_command(['git', 'reset', '--hard', 'trunk'])
     388        run_command(['git', 'reset', '--hard', 'trunk'])
    438389   
    439390    def local_commits(self):
    440         return self.run_command(['git', 'log', '--pretty=oneline', 'HEAD...trunk']).splitlines()
     391        return run_command(['git', 'log', '--pretty=oneline', 'HEAD...trunk']).splitlines()
    441392
    442393    def rebase_in_progress(self):
     
    444395
    445396    def working_directory_is_clean(self):
    446         return self.run_command(['git', 'diff-index', 'HEAD']) == ""
     397        return run_command(['git', 'diff-index', 'HEAD']) == ""
    447398
    448399    def clean_working_directory(self):
    449400        # Could run git clean here too, but that wouldn't match working_directory_is_clean
    450         self.run_command(['git', 'reset', '--hard', 'HEAD'])
     401        run_command(['git', 'reset', '--hard', 'HEAD'])
    451402        # Aborting rebase even though this does not match working_directory_is_clean
    452403        if self.rebase_in_progress():
    453             self.run_command(['git', 'rebase', '--abort'])
     404            run_command(['git', 'rebase', '--abort'])
    454405
    455406    def status_command(self):
     
    469420
    470421    def create_patch(self):
    471         return self.run_command(['git', 'diff', '--binary', 'HEAD'])
     422        return run_command(['git', 'diff', '--binary', 'HEAD'])
    472423
    473424    @classmethod
    474425    def git_commit_from_svn_revision(cls, revision):
    475426        # git svn find-rev always exits 0, even when the revision is not found.
    476         return cls.run_command(['git', 'svn', 'find-rev', 'r%s' % revision]).rstrip()
     427        return run_command(['git', 'svn', 'find-rev', 'r%s' % revision]).rstrip()
    477428
    478429    def diff_for_revision(self, revision):
     
    488439        # I think this will always fail due to ChangeLogs.
    489440        # FIXME: We need to detec specific failure conditions and handle them.
    490         self.run_command(['git', 'revert', '--no-commit', git_commit], error_handler=ignore_error)
     441        run_command(['git', 'revert', '--no-commit', git_commit], error_handler=ignore_error)
    491442
    492443        # Fix any ChangeLogs if necessary.
    493444        changelog_paths = self.modified_changelogs()
    494445        if len(changelog_paths):
    495             self.run_command([self.script_path('resolve-ChangeLogs')] + changelog_paths)
     446            run_command([self.script_path('resolve-ChangeLogs')] + changelog_paths)
    496447
    497448    def revert_files(self, file_paths):
    498         self.run_command(['git', 'checkout', 'HEAD'] + file_paths)
     449        run_command(['git', 'checkout', 'HEAD'] + file_paths)
    499450
    500451    def commit_with_message(self, message):
     
    504455    def svn_commit_log(self, svn_revision):
    505456        svn_revision = self.strip_r_from_svn_revision(svn_revision)
    506         return self.run_command(['git', 'svn', 'log', '-r', svn_revision])
     457        return run_command(['git', 'svn', 'log', '-r', svn_revision])
    507458
    508459    def last_svn_commit_log(self):
    509         return self.run_command(['git', 'svn', 'log', '--limit=1'])
     460        return run_command(['git', 'svn', 'log', '--limit=1'])
    510461
    511462    # Git-specific methods:
    512463
    513464    def create_patch_from_local_commit(self, commit_id):
    514         return self.run_command(['git', 'diff', '--binary', commit_id + "^.." + commit_id])
     465        return run_command(['git', 'diff', '--binary', commit_id + "^.." + commit_id])
    515466
    516467    def create_patch_since_local_commit(self, commit_id):
    517         return self.run_command(['git', 'diff', '--binary', commit_id])
     468        return run_command(['git', 'diff', '--binary', commit_id])
    518469
    519470    def commit_locally_with_message(self, message):
    520         self.run_command(['git', 'commit', '--all', '-F', '-'], input=message)
     471        run_command(['git', 'commit', '--all', '-F', '-'], input=message)
    521472       
    522473    def push_local_commits_to_server(self):
     
    524475            # Return a string which looks like a commit so that things which parse this output will succeed.
    525476            return "Dry run, no remote commit.\nCommitted r0"
    526         return self.run_command(['git', 'svn', 'dcommit'], error_handler=commit_error_handler)
     477        return run_command(['git', 'svn', 'dcommit'], error_handler=commit_error_handler)
    527478
    528479    # This function supports the following argument formats:
     
    541492                raise ScriptError(message="'...' is not supported (found in '%s'). Did you mean '..'?" % commitish)
    542493            elif '..' in commitish:
    543                 commit_ids += reversed(self.run_command(['git', 'rev-list', commitish]).splitlines())
     494                commit_ids += reversed(run_command(['git', 'rev-list', commitish]).splitlines())
    544495            else:
    545496                # Turn single commits or branch or tag names into commit ids.
    546                 commit_ids += self.run_command(['git', 'rev-parse', '--revs-only', commitish]).splitlines()
     497                commit_ids += run_command(['git', 'rev-parse', '--revs-only', commitish]).splitlines()
    547498        return commit_ids
    548499
    549500    def commit_message_for_local_commit(self, commit_id):
    550         commit_lines = self.run_command(['git', 'cat-file', 'commit', commit_id]).splitlines()
     501        commit_lines = run_command(['git', 'cat-file', 'commit', commit_id]).splitlines()
    551502
    552503        # Skip the git headers.
     
    559510
    560511    def files_changed_summary_for_commit(self, commit_id):
    561         return self.run_command(['git', 'diff-tree', '--shortstat', '--no-commit-id', commit_id])
     512        return run_command(['git', 'diff-tree', '--shortstat', '--no-commit-id', commit_id])
  • trunk/WebKitTools/Scripts/modules/scm_unittest.py

    r51590 r51888  
    3939
    4040from datetime import date
    41 from modules.scm import detect_scm_system, SCM, ScriptError, CheckoutNeedsUpdate, ignore_error, commit_error_handler
    42 
     41from modules.scm import detect_scm_system, SCM, CheckoutNeedsUpdate, commit_error_handler
     42from modules.processutils import run_command, ignore_error, ScriptError
    4343
    4444# Eventually we will want to write tests which work for both scms. (like update_webkit, changed_files, etc.)
    4545# Perhaps through some SCMTest base-class which both SVNTest and GitTest inherit from.
    4646
    47 def run(args, cwd=None):
    48     return SCM.run_command(args, cwd=cwd)
    49 
     47# FIXME: This should be unified into one of the processutils.py commands!
    5048def run_silent(args, cwd=None):
    5149    process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
     
    7674        test_file.flush()
    7775       
    78         run(['svn', 'add', 'test_file'])
    79         run(['svn', 'commit', '--quiet', '--message', 'initial commit'])
     76        run_command(['svn', 'add', 'test_file'])
     77        run_command(['svn', 'commit', '--quiet', '--message', 'initial commit'])
    8078       
    8179        test_file.write("test2")
    8280        test_file.flush()
    8381       
    84         run(['svn', 'commit', '--quiet', '--message', 'second commit'])
     82        run_command(['svn', 'commit', '--quiet', '--message', 'second commit'])
    8583       
    8684        test_file.write("test3\n")
    8785        test_file.flush()
    8886       
    89         run(['svn', 'commit', '--quiet', '--message', 'third commit'])
     87        run_command(['svn', 'commit', '--quiet', '--message', 'third commit'])
    9088
    9189        test_file.write("test4\n")
    9290        test_file.close()
    9391
    94         run(['svn', 'commit', '--quiet', '--message', 'fourth commit'])
     92        run_command(['svn', 'commit', '--quiet', '--message', 'fourth commit'])
    9593
    9694        # svn does not seem to update after commit as I would expect.
    97         run(['svn', 'update'])
     95        run_command(['svn', 'update'])
    9896
    9997    @classmethod
     
    104102        # git svn complains if we don't pass --pre-1.5-compatible, not sure why:
    105103        # Expected FS format '2'; found format '3' at /usr/local/libexec/git-core//git-svn line 1477
    106         run(['svnadmin', 'create', '--pre-1.5-compatible', test_object.svn_repo_path])
     104        run_command(['svnadmin', 'create', '--pre-1.5-compatible', test_object.svn_repo_path])
    107105
    108106        # Create a test svn checkout
    109107        test_object.svn_checkout_path = tempfile.mkdtemp(suffix="svn_test_checkout")
    110         run(['svn', 'checkout', '--quiet', test_object.svn_repo_url, test_object.svn_checkout_path])
     108        run_command(['svn', 'checkout', '--quiet', test_object.svn_repo_url, test_object.svn_checkout_path])
    111109
    112110        cls._setup_test_commits(test_object)
     
    114112    @classmethod
    115113    def tear_down(cls, test_object):
    116         run(['rm', '-rf', test_object.svn_repo_path])
    117         run(['rm', '-rf', test_object.svn_checkout_path])
     114        run_command(['rm', '-rf', test_object.svn_repo_path])
     115        run_command(['rm', '-rf', test_object.svn_checkout_path])
    118116
    119117# For testing the SCM baseclass directly.
     
    127125    def test_run_command_with_pipe(self):
    128126        input_process = subprocess.Popen(['echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null)
    129         self.assertEqual(SCM.run_command(['grep', 'bar'], input=input_process.stdout), "bar\n")
     127        self.assertEqual(run_command(['grep', 'bar'], input=input_process.stdout), "bar\n")
    130128
    131129        # Test the non-pipe case too:
    132         self.assertEqual(SCM.run_command(['grep', 'bar'], input="foo\nbar"), "bar\n")
     130        self.assertEqual(run_command(['grep', 'bar'], input="foo\nbar"), "bar\n")
    133131
    134132        command_returns_non_zero = ['/bin/sh', '--invalid-option']
     
    136134        input_process = subprocess.Popen(command_returns_non_zero, stdout=subprocess.PIPE, stderr=self.dev_null)
    137135        self.assertTrue(input_process.poll() != 0)
    138         self.assertRaises(ScriptError, SCM.run_command, ['grep', 'bar'], input=input_process.stdout)
     136        self.assertRaises(ScriptError, run_command, ['grep', 'bar'], input=input_process.stdout)
    139137
    140138        # Test when the run_command process fails.
    141139        input_process = subprocess.Popen(['echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null) # grep shows usage and calls exit(2) when called w/o arguments.
    142         self.assertRaises(ScriptError, SCM.run_command, command_returns_non_zero, input=input_process.stdout)
     140        self.assertRaises(ScriptError, run_command, command_returns_non_zero, input=input_process.stdout)
    143141
    144142    def test_error_handlers(self):
     
    149147"""
    150148        command_does_not_exist = ['does_not_exist', 'invalid_option']
    151         self.assertRaises(OSError, SCM.run_command, command_does_not_exist)
    152         self.assertRaises(OSError, SCM.run_command, command_does_not_exist, error_handler=ignore_error)
     149        self.assertRaises(OSError, run_command, command_does_not_exist)
     150        self.assertRaises(OSError, run_command, command_does_not_exist, error_handler=ignore_error)
    153151
    154152        command_returns_non_zero = ['/bin/sh', '--invalid-option']
    155         self.assertRaises(ScriptError, SCM.run_command, command_returns_non_zero)
     153        self.assertRaises(ScriptError, run_command, command_returns_non_zero)
    156154        # Check if returns error text:
    157         self.assertTrue(SCM.run_command(command_returns_non_zero, error_handler=ignore_error))
     155        self.assertTrue(run_command(command_returns_non_zero, error_handler=ignore_error))
    158156
    159157        self.assertRaises(CheckoutNeedsUpdate, commit_error_handler, ScriptError(output=git_failure_message))
     
    366364"""
    367365        write_into_file_at_path('ChangeLog', first_entry)
    368         run(['svn', 'add', 'ChangeLog'])
    369         run(['svn', 'commit', '--quiet', '--message', 'ChangeLog commit'])
     366        run_command(['svn', 'add', 'ChangeLog'])
     367        run_command(['svn', 'commit', '--quiet', '--message', 'ChangeLog commit'])
    370368
    371369        # Patch files were created against just 'first_entry'.
     
    373371        changelog_contents = "%s\n%s" % (intermediate_entry, first_entry)
    374372        write_into_file_at_path('ChangeLog', changelog_contents)
    375         run(['svn', 'commit', '--quiet', '--message', 'Intermediate commit'])
     373        run_command(['svn', 'commit', '--quiet', '--message', 'Intermediate commit'])
    376374
    377375        self._setup_webkittools_scripts_symlink(self.scm)
     
    398396        test_file_path = os.path.join(test_dir_path, 'test_file2')
    399397        write_into_file_at_path(test_file_path, 'test content')
    400         run(['svn', 'add', 'test_dir'])
     398        run_command(['svn', 'add', 'test_dir'])
    401399
    402400        # create_patch depends on 'svn-create-patch', so make a dummy version.
     
    443441    def test_apply_svn_patch(self):
    444442        scm = detect_scm_system(self.svn_checkout_path)
    445         patch = self._create_patch(run(['svn', 'diff', '-r4:3']))
     443        patch = self._create_patch(run_command(['svn', 'diff', '-r4:3']))
    446444        self._setup_webkittools_scripts_symlink(scm)
    447445        scm.apply_patch(patch)
     
    449447    def test_apply_svn_patch_force(self):
    450448        scm = detect_scm_system(self.svn_checkout_path)
    451         patch = self._create_patch(run(['svn', 'diff', '-r2:4']))
     449        patch = self._create_patch(run_command(['svn', 'diff', '-r2:4']))
    452450        self._setup_webkittools_scripts_symlink(scm)
    453451        self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)
     
    478476
    479477    def _tear_down_git_clone_of_svn_repository(self):
    480         run(['rm', '-rf', self.git_checkout_path])
     478        run_command(['rm', '-rf', self.git_checkout_path])
    481479
    482480    def setUp(self):
     
    498496        svn_test_file = os.path.join(self.svn_checkout_path, 'test_file')
    499497        write_into_file_at_path(svn_test_file, "svn_checkout")
    500         run(['svn', 'commit', '--message', 'commit to conflict with git commit'], cwd=self.svn_checkout_path)
     498        run_command(['svn', 'commit', '--message', 'commit to conflict with git commit'], cwd=self.svn_checkout_path)
    501499
    502500        git_test_file = os.path.join(self.git_checkout_path, 'test_file')
    503501        write_into_file_at_path(git_test_file, "git_checkout")
    504         run(['git', 'commit', '-a', '-m', 'commit to be thrown away by rebase abort'])
     502        run_command(['git', 'commit', '-a', '-m', 'commit to be thrown away by rebase abort'])
    505503
    506504        # --quiet doesn't make git svn silent, so use run_silent to redirect output
     
    534532        actual_commits = scm.commit_ids_from_commitish_arguments([commit_range])
    535533        expected_commits = []
    536         expected_commits += reversed(run(['git', 'rev-list', commit_range]).splitlines())
     534        expected_commits += reversed(run_command(['git', 'rev-list', commit_range]).splitlines())
    537535
    538536        self.assertEqual(actual_commits, expected_commits)
     
    540538    def test_apply_git_patch(self):
    541539        scm = detect_scm_system(self.git_checkout_path)
    542         patch = self._create_patch(run(['git', 'diff', 'HEAD..HEAD^']))
     540        patch = self._create_patch(run_command(['git', 'diff', 'HEAD..HEAD^']))
    543541        self._setup_webkittools_scripts_symlink(scm)
    544542        scm.apply_patch(patch)
     
    546544    def test_apply_git_patch_force(self):
    547545        scm = detect_scm_system(self.git_checkout_path)
    548         patch = self._create_patch(run(['git', 'diff', 'HEAD~2..HEAD']))
     546        patch = self._create_patch(run_command(['git', 'diff', 'HEAD~2..HEAD']))
    549547        self._setup_webkittools_scripts_symlink(scm)
    550548        self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)
     
    569567        file_contents = ''.join(map(chr, range(256)))
    570568        write_into_file_at_path(test_file_path, file_contents)
    571         run(['git', 'add', test_file_name])
     569        run_command(['git', 'add', test_file_name])
    572570        patch = scm.create_patch()
    573571        self.assertTrue(re.search(r'\nliteral 0\n', patch))
     
    575573
    576574        # Check if we can apply the created patch.
    577         run(['git', 'rm', '-f', test_file_name])
     575        run_command(['git', 'rm', '-f', test_file_name])
    578576        self._setup_webkittools_scripts_symlink(scm)
    579577        self.scm.apply_patch(self._create_patch(patch))
     
    582580        # Check if we can create a patch from a local commit.
    583581        write_into_file_at_path(test_file_path, file_contents)
    584         run(['git', 'add', test_file_name])
    585         run(['git', 'commit', '-m', 'binary diff'])
     582        run_command(['git', 'add', test_file_name])
     583        run_command(['git', 'commit', '-m', 'binary diff'])
    586584        patch_from_local_commit = scm.create_patch_from_local_commit('HEAD')
    587585        self.assertTrue(re.search(r'\nliteral 0\n', patch_from_local_commit))
  • trunk/WebKitTools/Scripts/modules/workqueue.py

    r51622 r51888  
    3636
    3737from modules.logging import log, OutputTee
    38 from modules.scm import ScriptError
     38from modules.processutils import ScriptError
    3939from modules.statusbot import StatusBot
    4040
  • trunk/WebKitTools/Scripts/modules/workqueue_unittest.py

    r51277 r51888  
    3333import unittest
    3434
    35 from modules.scm import ScriptError
     35from modules.processutils import ScriptError
    3636from modules.workqueue import WorkQueue, WorkQueueDelegate
    3737
Note: See TracChangeset for help on using the changeset viewer.