Changeset 48027 in webkit
- Timestamp:
- Sep 3, 2009 12:07:21 PM (15 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r48009 r48027 1 2009-09-02 David Kilzer <ddkilzer@apple.com> 2 3 <http://webkit.org/b/28880> svn-apply --force doesn't actually work 4 5 Reviewed by Eric Seidel. 6 7 This fixes "svn-apply --force" and adds unit tests for the 8 scm.apply_patch() method which uses this script. 9 10 * Scripts/svn-apply: Created $globalExitCode variable that 11 defaults to 0. Exit with a value of $globalExitCode when the 12 script is finished. 13 (applyPatch): Ignore a non-zero $exitCode if $force is true, but 14 set $globalExitCode to $exitCode so that svn-apply exits with a 15 non-zero status if any patches did not apply cleanly. Also 16 print out the actual patch command if $force was not true. 17 18 * Scripts/modules/scm.py: 19 (scripts_directory): Added. Extracted from script_path(). 20 (script_path): Extracted scripts_directory(). 21 * Scripts/modules/scm_unittest.py: Import urllib. 22 (SVNTestRepository.setup): Save the original working directory 23 in test_object since this represents the WebKit repository from 24 where the unit tests are run. 25 (SCMTest): Created new super class to hold utility methods. 26 (SCMTest._create_patch): Creates a patch file on disk and a 27 dictionary for use with scm.svn_apply(). 28 (SCMTest._setup_webkittools_scripts_symlink): Sets up a symlink 29 back to WebKitTools/Scripts in the test repository so that 30 scm.apply_patch() is able to find the svn-apply script. 31 (SVNTest): Inherit from SCMTest instead of unittest.TestCase. 32 (SVNTest.tearDown): Make sure to change directories back to the 33 original_path before the next test. 34 (SVNTest.test_apply_svn_patch): New test case for applying an 35 svn patch with scm.apply_patch(). 36 (SVNTest.test_apply_svn_patch_force): New test case for applying 37 an svn patch with scm.apply_patch() that conflicts. 38 (GitTest): Inherit from SCMTest instead of unittest.TestCase. 39 (GitTest.tearDown): Make sure to change directories back to the 40 original_path before the next test. 41 (GitTest.test_apply_git_patch): New test case for applying a git 42 patch with scm.apply_patch(). 43 (GitTest.test_apply_git_patch_force): New test case for applying 44 a git patch with scm.apply_patch() that conflicts. 45 1 46 2009-09-02 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> 2 47 -
trunk/WebKitTools/Scripts/modules/scm.py
r47953 r48027 100 100 return output 101 101 102 def scripts_directory(self): 103 return os.path.join(self.checkout_root, "WebKitTools", "Scripts") 104 102 105 def script_path(self, script_name): 103 return os.path.join(self. checkout_root, "WebKitTools", "Scripts", script_name)106 return os.path.join(self.scripts_directory(), script_name) 104 107 105 108 def ensure_clean_working_directory(self, force): -
trunk/WebKitTools/Scripts/modules/scm_unittest.py
r47953 r48027 1 1 # Copyright (C) 2009 Google Inc. All rights reserved. 2 # Copyright (C) 2009 Apple Inc. All rights reserved. 2 3 # 3 4 # Redistribution and use in source and binary forms, with or without … … 32 33 import tempfile 33 34 import unittest 35 import urllib 34 36 from modules.scm import detect_scm_system, SCM, ScriptError 35 37 … … 83 85 @classmethod 84 86 def setup(cls, test_object): 87 test_object.original_path = os.path.abspath('.') 88 85 89 # Create an test SVN repository 86 90 test_object.svn_repo_path = tempfile.mkdtemp(suffix="svn_test_repo") … … 102 106 103 107 104 class SVNTest(unittest.TestCase): 108 class SCMTest(unittest.TestCase): 109 def _create_patch(self, patch_contents): 110 patch_path = os.path.join(self.svn_checkout_path, 'patch.diff') 111 write_into_file_at_path(patch_path, patch_contents) 112 patch = {} 113 patch['reviewer'] = 'Joe Cool' 114 patch['bug_id'] = '12345' 115 patch['url'] = 'file://%s' % urllib.pathname2url(patch_path) 116 return patch 117 118 def _setup_webkittools_scripts_symlink(self, local_scm): 119 webkit_scm = detect_scm_system(self.original_path) 120 webkit_scripts_directory = webkit_scm.scripts_directory() 121 local_scripts_directory = local_scm.scripts_directory() 122 os.mkdir(os.path.dirname(local_scripts_directory)) 123 os.symlink(webkit_scripts_directory, local_scripts_directory) 124 125 126 class SVNTest(SCMTest): 105 127 106 128 def setUp(self): … … 110 132 def tearDown(self): 111 133 SVNTestRepository.tear_down(self) 134 os.chdir(self.original_path) 112 135 113 136 def test_create_patch_is_full_patch(self): … … 138 161 self.assertEqual(scm.supports_local_commits(), False) 139 162 140 class GitTest(unittest.TestCase): 163 def test_apply_svn_patch(self): 164 scm = detect_scm_system(self.svn_checkout_path) 165 patch = self._create_patch(run(['svn', 'diff', '-r4:3'])) 166 self._setup_webkittools_scripts_symlink(scm) 167 scm.apply_patch(patch) 168 169 def test_apply_svn_patch_force(self): 170 scm = detect_scm_system(self.svn_checkout_path) 171 patch = self._create_patch(run(['svn', 'diff', '-r2:4'])) 172 self._setup_webkittools_scripts_symlink(scm) 173 self.assertRaises(ScriptError, scm.apply_patch, patch, force=True) 174 175 class GitTest(SCMTest): 141 176 142 177 def _setup_git_clone_of_svn_repository(self): … … 156 191 SVNTestRepository.tear_down(self) 157 192 self._tear_down_git_clone_of_svn_repository() 193 os.chdir(self.original_path) 158 194 159 195 def test_detection(self): … … 205 241 self.assertEqual(actual_commits, expected_commits) 206 242 243 def test_apply_git_patch(self): 244 scm = detect_scm_system(self.git_checkout_path) 245 patch = self._create_patch(run(['git', 'diff', 'HEAD..HEAD^'])) 246 self._setup_webkittools_scripts_symlink(scm) 247 scm.apply_patch(patch) 248 249 def test_apply_git_patch_force(self): 250 scm = detect_scm_system(self.git_checkout_path) 251 patch = self._create_patch(run(['git', 'diff', 'HEAD~2..HEAD'])) 252 self._setup_webkittools_scripts_symlink(scm) 253 self.assertRaises(ScriptError, scm.apply_patch, patch, force=True) 254 207 255 208 256 if __name__ == '__main__': -
trunk/WebKitTools/Scripts/svn-apply
r47945 r48027 122 122 ); 123 123 124 my $globalExitCode = 0; 125 124 126 my $pathScriptWasRunFrom = Cwd::getcwd(); 125 127 my $pathForRepositoryRoot = determineVCSRoot(); … … 196 198 removeDirectoriesIfNeeded(); 197 199 198 exit 0;200 exit $globalExitCode; 199 201 200 202 sub addDirectoriesIfNeeded($) … … 240 242 241 243 my $exitCode = $? >> 8; 242 if ($exitCode != 0) { 243 print "patch -p0 \"$fullPath\" returned $exitCode. Pass --force to ignore patch failures.\n"; 244 exit($exitCode); 244 if ($exitCode) { 245 if (!$force) { 246 print "$command \"$fullPath\" returned $exitCode. Pass --force to ignore patch failures.\n"; 247 exit $exitCode; 248 } 249 $globalExitCode = $exitCode; 245 250 } 246 251 }
Note: See TracChangeset
for help on using the changeset viewer.