📄 commit_tests.py
字号:
def commit_inclusive_dir(sbox): "commit wc_dir/A/D -- includes D. (anchor=A, tgt=D)" sbox.build() wc_dir = sbox.wc_dir # Make standard slew of changes to working copy. make_standard_slew_of_changes(wc_dir) # Create expected output tree. D_path = os.path.join(wc_dir, 'A', 'D') pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi') rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho') gloo_path = os.path.join(wc_dir, 'A', 'D', 'H', 'gloo') chi_path = os.path.join(wc_dir, 'A', 'D', 'H', 'chi') omega_path = os.path.join(wc_dir, 'A', 'D', 'H', 'omega') gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma') expected_output = svntest.wc.State(wc_dir, { 'A/D' : Item(verb='Sending'), 'A/D/G/pi' : Item(verb='Sending'), 'A/D/G/rho' : Item(verb='Deleting'), 'A/D/H/gloo' : Item(verb='Adding'), 'A/D/H/chi' : Item(verb='Replacing'), 'A/D/H/omega' : Item(verb='Sending'), 'A/D/gamma' : Item(verb='Deleting'), }) # Created expected status tree. expected_status = get_standard_state(wc_dir) # pre-commit status expected_status.remove('A/D/G/rho', 'A/D/gamma') expected_status.tweak('A/D', 'A/D/G/pi', 'A/D/H/omega', wc_rev=2, status=' ') expected_status.tweak('A/D/H/chi', 'A/D/H/gloo', wc_rev=2, status=' ') # Commit the one file. svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, D_path)#----------------------------------------------------------------------def commit_top_dir(sbox): "commit wc_dir -- (anchor=wc_dir, tgt={})" sbox.build() wc_dir = sbox.wc_dir # Make standard slew of changes to working copy. make_standard_slew_of_changes(wc_dir) # Create expected output tree. top_path = wc_dir Q_path = os.path.join(wc_dir, 'Q') floo_path = os.path.join(wc_dir, 'Q', 'floo') E_path = os.path.join(wc_dir, 'A', 'B', 'E') bloo_path = os.path.join(wc_dir, 'A', 'B', 'E', 'bloo') lambda_path = os.path.join(wc_dir, 'A', 'B', 'lambda') C_path = os.path.join(wc_dir, 'A', 'C') D_path = os.path.join(wc_dir, 'A', 'D') pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi') rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho') gloo_path = os.path.join(wc_dir, 'A', 'D', 'H', 'gloo') chi_path = os.path.join(wc_dir, 'A', 'D', 'H', 'chi') omega_path = os.path.join(wc_dir, 'A', 'D', 'H', 'omega') gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma') expected_output = svntest.wc.State(wc_dir, { '' : Item(verb='Sending'), 'Q' : Item(verb='Adding'), 'Q/floo' : Item(verb='Adding'), 'A/B/E' : Item(verb='Replacing'), 'A/B/E/bloo' : Item(verb='Adding'), 'A/B/lambda' : Item(verb='Sending'), 'A/C' : Item(verb='Deleting'), 'A/D' : Item(verb='Sending'), 'A/D/G/pi' : Item(verb='Sending'), 'A/D/G/rho' : Item(verb='Deleting'), 'A/D/H/gloo' : Item(verb='Adding'), 'A/D/H/chi' : Item(verb='Replacing'), 'A/D/H/omega' : Item(verb='Sending'), 'A/D/gamma' : Item(verb='Deleting'), }) # Created expected status tree. expected_status = get_standard_state(wc_dir) # pre-commit status expected_status.remove('A/D/G/rho', 'A/D/gamma', 'A/C', 'A/B/E/alpha', 'A/B/E/beta') expected_status.tweak('A/D', 'A/D/G/pi', 'A/D/H/omega', 'Q/floo', '', wc_rev=2, status=' ') expected_status.tweak('A/D/H/chi', 'Q', 'A/B/E', 'A/B/E/bloo', 'A/B/lambda', 'A/D/H/gloo', wc_rev=2, status=' ') # Commit the one file. svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir)#----------------------------------------------------------------------# Regression test for bug reported by Jon Trowbridge:# # From: Jon Trowbridge <trow@ximian.com># Subject: svn segfaults if you commit a file that hasn't been added# To: dev@subversion.tigris.org# Date: 17 Jul 2001 03:20:55 -0500# Message-Id: <995358055.16975.5.camel@morimoto># # The problem is that report_single_mod in libsvn_wc/adm_crawler.c is# called with its entry parameter as NULL, but the code doesn't# check that entry is non-NULL before trying to dereference it.## This bug never had an issue number.#def commit_unversioned_thing(sbox): "committing unversioned object produces error" sbox.build() wc_dir = sbox.wc_dir # Create an unversioned file in the wc. svntest.main.file_append(os.path.join(wc_dir, 'blorg'), "nothing to see") # Commit a non-existent file and *expect* failure: svntest.actions.run_and_verify_commit (wc_dir, None, None, "is not under version control", None, None, None, None, os.path.join(wc_dir,'blorg')) #----------------------------------------------------------------------# regression test for bug #391def nested_dir_replacements(sbox): "replace two nested dirs, verify empty contents" sbox.build() wc_dir = sbox.wc_dir # Delete and re-add A/D (a replacement), and A/D/H (another replace). svntest.main.run_svn(None, 'rm', os.path.join(wc_dir, 'A', 'D')) svntest.main.run_svn(None, 'add', '-N', os.path.join(wc_dir, 'A', 'D')) svntest.main.run_svn(None, 'add', '-N', os.path.join(wc_dir, 'A', 'D', 'H')) # For kicks, add new file A/D/bloo. svntest.main.file_append(os.path.join(wc_dir, 'A', 'D', 'bloo'), "hi") svntest.main.run_svn(None, 'add', os.path.join(wc_dir, 'A', 'D', 'bloo')) # Verify pre-commit status: # # - A/D and A/D/H should both be scheduled as "R" at rev 1 # (rev 1 because they both existed before at rev 1) # # - A/D/bloo scheduled as "A" at rev 0 # (rev 0 because it did not exist before) # # - ALL other children of A/D scheduled as "D" at rev 1 expected_status = svntest.actions.get_virginal_state(wc_dir, 1) expected_status.tweak('A/D', 'A/D/H', status='R ', wc_rev=1) expected_status.add({ 'A/D/bloo' : Item(status='A ', wc_rev=0), }) expected_status.tweak('A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi', 'A/D/gamma', status='D ') svntest.actions.run_and_verify_status(wc_dir, expected_status) # Build expected post-commit trees: # Create expected output tree. expected_output = svntest.wc.State(wc_dir, { 'A/D' : Item(verb='Replacing'), 'A/D/H' : Item(verb='Adding'), 'A/D/bloo' : Item(verb='Adding'), }) # Created expected status tree. expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.tweak('A/D', 'A/D/H', wc_rev=2) expected_status.add({ 'A/D/bloo' : Item(status=' ', wc_rev=2), }) expected_status.remove('A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi', 'A/D/gamma') # Commit from the top of the working copy and verify output & status. svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir)#----------------------------------------------------------------------# Testing part 1 of the "Greg Hudson" problem -- specifically, that# our use of the "existence=deleted" flag is working properly in cases# where the parent directory's revision lags behind a deleted child's# revision.def hudson_part_1(sbox): "hudson prob 1.0: delete file, commit, update" sbox.build() wc_dir = sbox.wc_dir # Remove gamma from the working copy. gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma') svntest.main.run_svn(None, 'rm', gamma_path) # Create expected commit output. expected_output = svntest.wc.State(wc_dir, { 'A/D/gamma' : Item(verb='Deleting'), }) # After committing, status should show no sign of gamma. expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.remove('A/D/gamma') # Commit the deletion of gamma and verify. svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) # Now gamma should be marked as `deleted' under the hood. When we # update, we should no output, and a perfect, virginal status list # at revision 2. (The `deleted' entry should be removed.) # Expected output of update: nothing. expected_output = svntest.wc.State(wc_dir, {}) # Expected disk tree: everything but gamma expected_disk = svntest.main.greek_state.copy() expected_disk.remove('A/D/gamma') # Expected status after update: totally clean revision 2, minus gamma. expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.remove('A/D/gamma') svntest.actions.run_and_verify_update(wc_dir, expected_output, expected_disk, expected_status)#----------------------------------------------------------------------# Testing part 1 of the "Greg Hudson" problem -- variation on previous# test, removing a directory instead of a file this time.def hudson_part_1_variation_1(sbox): "hudson prob 1.1: delete dir, commit, update" sbox.build() wc_dir = sbox.wc_dir # Remove H from the working copy. H_path = os.path.join(wc_dir, 'A', 'D', 'H') svntest.main.run_svn(None, 'rm', H_path) # Create expected commit output. expected_output = svntest.wc.State(wc_dir, { 'A/D/H' : Item(verb='Deleting'), }) # After committing, status should show no sign of H or its contents expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.remove('A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi') # Commit the deletion of H and verify. svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) # Now H should be marked as `deleted' under the hood. When we # update, we should no see output, and a perfect, virginal status # list at revision 2. (The `deleted' entry should be removed.) # Expected output of update: H gets a no-op deletion. expected_output = svntest.wc.State(wc_dir, {}) # Expected disk tree: everything except files in H expected_disk = svntest.main.greek_state.copy() expected_disk.remove('A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi') # Expected status after update: totally clean revision 2, minus H. expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.remove('A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi') svntest.actions.run_and_verify_update(wc_dir, expected_output, expected_disk, expected_status)#----------------------------------------------------------------------# Testing part 1 of the "Greg Hudson" problem -- variation 2. In this# test, we make sure that a file that is BOTH `deleted' and scheduled# for addition can be correctly committed & merged.def hudson_part_1_variation_2(sbox): "hudson prob 1.2: delete, commit, re-add, commit" sbox.build() wc_dir = sbox.wc_dir # Remove gamma from the working copy. gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma') svntest.main.run_svn(None, 'rm', gamma_path) # Create expected commit output. expected_output = svntest.wc.State(wc_dir, { 'A/D/gamma' : Item(verb='Deleting'), }) # After committing, status should show no sign of gamma. expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.tweak(wc_rev=1) expected_status.remove('A/D/gamma') # Commit the deletion of gamma and verify.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -