Home | History | Annotate | Download | only in webkitpy

Lines Matching full:self

120     def setUp(self):
121 self.dev_null = open(os.devnull, "w") # Used to make our Popen calls quiet.
123 def tearDown(self):
124 self.dev_null.close()
126 def test_run_command_with_pipe(self):
127 input_process = subprocess.Popen(['echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null)
128 self.assertEqual(run_command(['grep', 'bar'], input=input_process.stdout), "bar\n")
131 self.assertEqual(run_command(['grep', 'bar'], input="foo\nbar"), "bar\n")
135 input_process = subprocess.Popen(command_returns_non_zero, stdout=subprocess.PIPE, stderr=self.dev_null)
136 self.assertTrue(input_process.poll() != 0)
137 self.assertRaises(ScriptError, run_command, ['grep', 'bar'], input=input_process.stdout)
140 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.
141 self.assertRaises(ScriptError, run_command, command_returns_non_zero, input=input_process.stdout)
143 def test_error_handlers(self):
150 self.assertRaises(OSError, run_command, command_does_not_exist)
151 self.assertRaises(OSError, run_command, command_does_not_exist, error_handler=Executive.ignore_error)
154 self.assertRaises(ScriptError, run_command, command_returns_non_zero)
156 self.assertTrue(run_command(command_returns_non_zero, error_handler=Executive.ignore_error))
158 self.assertRaises(CheckoutNeedsUpdate, commit_error_handler, ScriptError(output=git_failure_message))
159 self.assertRaises(CheckoutNeedsUpdate, commit_error_handler, ScriptError(output=svn_failure_message))
160 self.assertRaises(ScriptError, commit_error_handler, ScriptError(output='blah blah blah'))
165 def _create_patch(self, patch_contents):
166 patch_path = os.path.join(self.svn_checkout_path, 'patch.diff')
174 def _setup_webkittools_scripts_symlink(self, local_scm):
183 def _shared_test_commit_with_message(self):
185 commit_text = self.scm.commit_with_message('another test commit')
186 self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '5')
188 self.scm.dryrun = True
190 commit_text = self.scm.commit_with_message('yet another test commit')
191 self.assertEqual(self.scm.svn_revision_from_commit_text(commit_text), '0')
193 def _shared_test_reverse_diff(self):
194 self._setup_webkittools_scripts_symlink(self.scm) # Git's apply_reverse_diff uses resolve-ChangeLogs
196 self.scm.apply_reverse_diff('4')
197 self.assertEqual(read_from_path('test_file'), "test1test2test3\n")
199 def _shared_test_diff_for_revision(self):
201 r3_patch = self.scm.diff_for_revision(3)
202 self.assertTrue(re.search('test3', r3_patch))
203 self.assertFalse(re.search('test4', r3_patch))
204 self.assertTrue(re.search('test2', r3_patch))
205 self.assertTrue(re.search('test2', self.scm.diff_for_revision(2)))
207 def _shared_test_svn_apply_git_patch(self):
208 self._setup_webkittools_scripts_symlink(self.scm)
230 self.scm.apply_patch(self._create_patch(git_binary_addition))
232 self.assertEqual(512, len(added))
233 self.assertTrue(added.startswith('GIF89a'))
234 self.assertTrue('fizzbuzz7.gif' in self.scm.changed_files())
237 self.assertRaises(ScriptError, self.scm.apply_patch, self._create_patch(git_binary_addition))
258 self.scm.apply_patch(self._create_patch(git_binary_modification))
260 self.assertEqual('foobar\n', modified)
261 self.assertTrue('fizzbuzz7.gif' in self.scm.changed_files())
264 self.assertRaises(ScriptError, self.scm.apply_patch, self._create_patch(git_binary_modification))
277 self.scm.apply_patch(self._create_patch(git_binary_deletion))
278 self.assertFalse(os.path.exists('fizzbuzz7.gif'))
279 self.assertFalse('fizzbuzz7.gif' in self.scm.changed_files())
282 self.assertRaises(ScriptError, self.scm.apply_patch, self._create_patch(git_binary_deletion))
294 def test_svn_apply(self):
376 self._setup_webkittools_scripts_symlink(self.scm)
377 self.scm.apply_patch(self._create_patch(one_line_overlap_patch))
378 expected_changelog_contents = "%s\n%s" % (self._set_date_and_reviewer(one_line_overlap_entry), changelog_contents)
379 self.assertEquals(read_from_path('ChangeLog'), expected_changelog_contents)
381 self.scm.revert_files(['ChangeLog'])
382 self.scm.apply_patch(self._create_patch(two_line_overlap_patch))
383 expected_changelog_contents = "%s\n%s" % (self
384 self.assertEquals(read_from_path('ChangeLog'), expected_changelog_contents)
386 def setUp(self):
387 SVNTestRepository.setup(self)
388 os.chdir(self.svn_checkout_path)
389 self.scm = detect_scm_system(self.svn_checkout_path)
391 def tearDown(self):
392 SVNTestRepository.tear_down(self)
394 def test_create_patch_is_full_patch(self):
395 test_dir_path = os.path.join(self.svn_checkout_path, 'test_dir')
402 scripts_path = os.path.join(self.svn_checkout_path, 'WebKitTools', 'Scripts')
411 self.assertEqual(scm.checkout_root, self.svn_checkout_path) # Sanity check that detection worked right.
414 self.assertEqual("%s\n" % os.path.realpath(scm.checkout_root), patch_contents) # Add a \n because echo adds a \n.
416 def test_detection(self):
417 scm = detect_scm_system(self.svn_checkout_path)
418 self.assertEqual(scm.display_name(), "svn")
419 self.assertEqual(scm.supports_local_commits(), False)
421 def test_apply_small_binary_patch(self):
436 self._setup_webkittools_scripts_symlink(self.scm)
437 patch_file = self._create_patch(patch_contents)
438 self.scm.apply_patch(patch_file)
440 self.assertEqual(actual_contents, expected_contents)
442 def test_apply_svn_patch(self):
443 scm = detect_scm_system(self.svn_checkout_path)
444 patch = self._create_patch(run_command(['svn', 'diff', '-r4:3']))
445 self._setup_webkittools_scripts_symlink(scm)
448 def test_apply_svn_patch_force(self):
449 scm = detect_scm_system(self.svn_checkout_path)
450 patch = self._create_patch(run_command(['svn', 'diff', '-r2:4']))
451 self._setup_webkittools_scripts_symlink(scm)
452 self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)
454 def test_commit_logs(self):
456 self.assertTrue(re.search('fourth commit', self.scm.last_svn_commit_log()))
457 self.assertTrue(re.search('second commit', self.scm.svn_commit_log(2)))
459 def test_commit_text_parsing(self):
460 self._shared_test_commit_with_message()
462 def test_reverse_diff(self):
463 self._shared_test_reverse_diff()
465 def test_diff_for_revision(self):
466 self._shared_test_diff_for_revision()
468 def test_svn_apply_git_patch(self):
469 self._shared_test_svn_apply_git_patch()
473 def _setup_git_clone_of_svn_repository(self):
474 self.git_checkout_path = tempfile.mkdtemp(suffix="git_test_checkout")
476 run_silent(['git', 'svn', '--quiet', 'clone', self.svn_repo_url, self.git_checkout_path])
478 def _tear_down_git_clone_of_svn_repository(self):
479 run_command(['rm', '-rf', self.git_checkout_path])
481 def setUp(self):
482 SVNTestRepository.setup(self)
483 self._setup_git_clone_of_svn_repository()
484 os.chdir(self.git_checkout_path)
485 self.scm = detect_scm_system(self.git_checkout_path)
487 def tearDown(self):
488 SVNTestRepository.tear_down(self)
489 self._tear_down_git_clone_of_svn_repository()
491 def test_detection(self):
492 scm = detect_scm_system(self.git_checkout_path)
493 self.assertEqual(scm.display_name(), "git")
494 self.assertEqual(scm.supports_local_commits(), True)
496 def test_rebase_in_progress(self):
497 svn_test_file = os.path.join(self.svn_checkout_path, 'test_file')
499 run_command(['svn', 'commit', '--message', 'commit to conflict with git commit'], cwd=self.svn_checkout_path)
501 git_test_file = os.path.join(self.git_checkout_path, 'test_file')
506 self.assertRaises(ScriptError, run_silent, ['git', 'svn', '--quiet', 'rebase']) # Will fail due to a conflict leaving us mid-rebase.
508 scm = detect_scm_system(self.git_checkout_path)
509 self.assertTrue(scm.rebase_in_progress())
513 self.assertFalse(scm.rebase_in_progress())
518 def test_commitish_parsing(self):
519 scm = detect_scm_system(self.git_checkout_path)
522 self.assertEqual(len(scm.commit_ids_from_commitish_arguments(['HEAD~2'])), 1)
523 self.assertEqual(len(scm.commit_ids_from_commitish_arguments(['HEAD', 'HEAD~2'])), 2)
526 self.assertRaises(ScriptError, scm.commit_ids_from_commitish_arguments, ['trunk...HEAD'])
528 def test_commitish_order(self):
529 scm = detect_scm_system(self.git_checkout_path)
537 self.assertEqual(actual_commits, expected_commits)
539 def test_apply_git_patch(self):
540 scm = detect_scm_system(self.git_checkout_path)
541 patch = self._create_patch(run_command(['git', 'diff', 'HEAD..HEAD^']))
542 self._setup_webkittools_scripts_symlink(scm)
545 def test_apply_git_patch_force(self):
546 scm = detect_scm_system(self.git_checkout_path)
547 patch = self._create_patch(run_command(['git', 'diff', 'HEAD~2..HEAD']))
548 self._setup_webkittools_scripts_symlink(scm)
549 self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)
551 def test_commit_text_parsing(self):
552 self._shared_test_commit_with_message()
554 def test_reverse_diff(self):
555 self._shared_test_reverse_diff()
557 def test_diff_for_revision(self):
558 self._shared_test_diff_for_revision()
560 def test_svn_apply_git_patch(self):
561 self._shared_test_svn_apply_git_patch()
563 def test_create_binary_patch(self):
565 scm = detect_scm_system(self.git_checkout_path)
567 test_file_path = os.path.join(self.git_checkout_path, test_file_name)
572 self.assertTrue(re.search(r'\nliteral 0\n', patch))
573 self.assertTrue(re.search(r'\nliteral 256\n', patch))
577 self._setup_webkittools_scripts_symlink(scm)
578 self.scm.apply_patch(self._create_patch(patch))
579 self.assertEqual(file_contents, read_from_path(test_file_path))
586 self.assertTrue(re.search(r'\nliteral 0\n', patch_from_local_commit))
587 self.assertTrue(re.search(r'\nliteral 256\n', patch_from_local_commit))
589 self.assertTrue(re.search(r'\nliteral 0\n', patch_since_local_commit))
590 self.assertTrue(re.search(r'\nliteral 256\n', patch_since_local_commit))
591 self.assertEqual(patch_from_local_commit, patch_since_local_commit)