⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trans_tests.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 2 页
字号:
# Regression test for bug discovered by Vladmir Prus <ghost@cs.msu.csu>.# This is a slight rewrite of his test, to use the run_and_verify_* API.# This is for issue #631.def do_nothing(x, y):  return 0def update_modified_with_translation(sbox):  "update modified file with eol-style 'native'"  sbox.build()  wc_dir = sbox.wc_dir  # Replace contents of rho and set eol translation to 'native'  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')  f = open(rho_path, "w")  f.write("1\n2\n3\n4\n5\n6\n7\n8\n9\n")  f.close()  svntest.actions.run_and_verify_svn(None, None, [],                                     'propset', 'svn:eol-style', 'native',                                     rho_path)  # Create expected output and status trees of a commit.  expected_output = svntest.wc.State(wc_dir, {    'A/D/G/rho' : Item(verb='Sending'),    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.tweak(wc_rev=1)  # rho has props  expected_status.tweak('A/D/G/rho', wc_rev=2, status='  ')  # Commit revision 2:  it has the new rho.  svntest.actions.run_and_verify_commit (wc_dir,                                         expected_output,                                         expected_status,                                         None, None, None, None, None,                                         rho_path)  # Change rho again  f = open(rho_path, "w")  f.write("1\n2\n3\n4\n4.5\n5\n6\n7\n8\n9\n")  f.close()  # Commit revision 3   expected_status = svntest.actions.get_virginal_state(wc_dir, 3)  expected_status.tweak(wc_rev=1)  expected_status.tweak('A/D/G/rho', wc_rev=3, status='  ')  svntest.actions.run_and_verify_commit (wc_dir,                                         expected_output,                                         expected_status,                                         None, None, None, None, None,                                         rho_path)  # Locally modify rho again.  f = open(rho_path, "w")  f.write("1\n2\n3\n4\n4.5\n5\n6\n7\n8\n9\n10\n")  f.close()  # Prepare trees for an update to rev 1.  expected_output = svntest.wc.State(wc_dir, {    'A/D/G/rho' : Item(status='CU'),    })  expected_disk = svntest.main.greek_state.copy()  expected_disk.tweak('A/D/G/rho', contents="""<<<<<<< .mine12344.55678910=======This is the file 'rho'.>>>>>>> .r1""")  # Updating back to revision 1 should not error; the merge should  # work, with eol-translation turned on.  svntest.actions.run_and_verify_update(wc_dir,                                        expected_output,                                        expected_disk,                                        None, None,                                        do_nothing, None,                                        None, None,                                        0, '-r', '1', wc_dir)#----------------------------------------------------------------------# Regression test for issue #1085, whereby setting the eol-style to a# fixed platform-incorrect value on a file whose line endings are# platform-correct causes repository insanity (the eol-style prop# claims one line ending style, the file is in another).  This test# assumes that this can be testing by verifying that a) new file# contents are transmitted to the server during commit, and b) that# after the commit, the file and its text-base have been changed to# have the new line-ending style.def eol_change_is_text_mod(sbox):  "committing eol-style change forces text send"    sbox.build()  wc_dir = sbox.wc_dir  # add a new file to the working copy.  foo_path = os.path.join(wc_dir, 'foo')  f = open(foo_path, 'wb')  if svntest.main.windows:    f.write("1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n")  else:    f.write("1\n2\n3\n4\n5\n6\n7\n8\n9\n")  f.close()  # commit the file  svntest.actions.run_and_verify_svn(None, None, [], 'add', foo_path)  svntest.actions.run_and_verify_svn(None, None, [], 'ci', '-m', 'log msg',                                     foo_path)    if svntest.main.windows:    svntest.actions.run_and_verify_svn(None, None, [], 'propset',                                       'svn:eol-style', 'LF', foo_path)  else:    svntest.actions.run_and_verify_svn(None, None, [], 'propset',                                       'svn:eol-style', 'CRLF', foo_path)  # check 1: did new contents get transmitted?  expected_output = ["Sending        " + foo_path + "\n",                     "Transmitting file data .\n",                     "Committed revision 3.\n"]  svntest.actions.run_and_verify_svn(None, expected_output, [],                                     'ci', '-m', 'log msg', foo_path)  # check 2: do the files have the right contents now?  f = open(foo_path, 'rb')  contents = f.read()  f.close()  if svntest.main.windows:    if contents != "1\n2\n3\n4\n5\n6\n7\n8\n9\n":      raise svntest.Failure  else:    if contents != "1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n":      raise svntest.Failure  f = open(os.path.join(wc_dir, svntest.main.get_admin_name(),                        'text-base', 'foo.svn-base'), 'rb')  base_contents = f.read()  f.close()  if contents != base_contents:    raise svntest.Failure  #----------------------------------------------------------------------# Regression test for issue #1151.  A single file in a directory# didn't get keywords expanded on checkout.def keyword_expanded_on_checkout(sbox):  "keyword expansion for lone file in directory"  sbox.build()  wc_dir = sbox.wc_dir  # The bug didn't occur if there were multiple files in the  # directory, so setup an empty directory.  Z_path = os.path.join(wc_dir, 'Z')  svntest.actions.run_and_verify_svn (None, None, [], 'mkdir', Z_path)    # Add the file that has the keyword to be expanded  url_path = os.path.join(Z_path, 'url')  svntest.main.file_append (url_path, "$URL$")  svntest.actions.run_and_verify_svn (None, None, [], 'add', url_path)  keywords_on(url_path)  svntest.actions.run_and_verify_svn(None, None, [],                                     'ci', '-m', 'log msg', wc_dir)  other_wc_dir = sbox.add_wc_path('other')  other_url_path = os.path.join(other_wc_dir, 'Z', 'url')  svntest.actions.run_and_verify_svn (None, None, [], 'checkout',                                      '--username', svntest.main.wc_author,                                      '--password', svntest.main.wc_passwd,                                      svntest.main.current_repo_url,                                      other_wc_dir)  # Check keyword got expanded (and thus the mkdir, add, ps, commit  # etc. worked)  fp = open(other_url_path, 'r')  lines = fp.readlines()  if not ((len(lines) == 1)          and (re.match("\$URL: (http|file|svn|svn\\+ssh)://", lines[0]))):    print "URL expansion failed for", other_url_path    raise svntest.Failure  fp.close()#----------------------------------------------------------------------def cat_keyword_expansion(sbox):  "keyword expanded on cat"  sbox.build()  wc_dir = sbox.wc_dir  mu_path = os.path.join(wc_dir, 'A', 'mu')  lambda_path = os.path.join(wc_dir, 'A', 'B', 'lambda')  # Set up A/mu to do $Rev$ keyword expansion  svntest.main.file_append (mu_path , "$Rev$\n$Author$")  svntest.actions.run_and_verify_svn(None, None, [],                                     'propset', 'svn:keywords', 'Rev Author',                                     mu_path)  expected_output = wc.State(wc_dir, {    'A/mu' : Item(verb='Sending'),    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.tweak(wc_rev=1)  expected_status.tweak('A/mu', wc_rev=2)  svntest.actions.run_and_verify_commit (wc_dir,                                         expected_output, expected_status,                                         None, None, None, None, None,                                         wc_dir)  # Change the author to value which will get truncated on expansion  full_author = "x" * 400   key_author = "x" * 244  svntest.actions.enable_revprop_changes(svntest.main.current_repo_dir)  svntest.actions.run_and_verify_svn("", None, [],                                     'propset', '--revprop', '-r2',                                     'svn:author', full_author,                                     sbox.wc_dir)  svntest.actions.run_and_verify_svn("", [ full_author ], [],                                     'propget', '--revprop', '-r2',                                     'svn:author', '--strict',                                     sbox.wc_dir)  # Make another commit so that the last changed revision for A/mu is  # not HEAD.  svntest.actions.run_and_verify_svn(None, None, [],                                     'propset', 'foo', 'bar', lambda_path)  expected_output = wc.State(wc_dir, {    'A/B/lambda' : Item(verb='Sending'),    })  expected_status.tweak('A/B/lambda', wc_rev=3)  svntest.actions.run_and_verify_commit (wc_dir,                                         expected_output, expected_status,                                         None, None, None, None, None,                                         wc_dir)  # At one stage the keywords were expanded to values for the requested  # revision, not to those committed revision  svntest.actions.run_and_verify_svn (None,                                      [ "This is the file 'mu'.\n",                                        "$Rev: 2 $\n",                                        "$Author: " + key_author + " $"], [],                                      'cat', '-r', 'HEAD', mu_path)  #----------------------------------------------------------------------def copy_propset_commit(sbox):  "copy, propset svn:eol-style, commit"  sbox.build()  wc_dir = sbox.wc_dir  mu_path = os.path.join(wc_dir, 'A', 'mu')  mu2_path = os.path.join(wc_dir, 'A', 'mu2')  # Copy and propset  svntest.actions.run_and_verify_svn(None, None, [], 'copy', mu_path, mu2_path)  svntest.actions.run_and_verify_svn(None, None, [],                                     'propset', 'svn:eol-style', 'native',                                     mu2_path)  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.add({    'A/mu2' : Item(status='A ', wc_rev='-', copied='+')    })  svntest.actions.run_and_verify_status(wc_dir, expected_status)  # Commit, at one stage this dumped core  expected_output = wc.State(wc_dir, {    'A/mu2' : Item(verb='Adding'),    })  expected_status.tweak('A/mu2', status='  ', wc_rev=2, copied=None)  svntest.actions.run_and_verify_commit (wc_dir,                                         expected_output, expected_status,                                         None, None, None, None, None,                                         wc_dir)#----------------------------------------------------------------------#      Create a greek tree, commit a keyword into one file,#      then commit a keyword property (i.e., turn on keywords), then#      try to check out head somewhere else.#      This should not cause seg faultdef propset_commit_checkout_nocrash(sbox):  "propset, commit, check out into another wc"  sbox.build()  wc_dir = sbox.wc_dir  mu_path = os.path.join(wc_dir, 'A', 'mu')  # Put a keyword in A/mu, commit  svntest.main.file_append (mu_path, "$Rev$")  expected_output = wc.State(wc_dir, {    'A/mu' : Item(verb='Sending'),    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.tweak(wc_rev=1)  expected_status.tweak('A/mu', wc_rev=2)  svntest.actions.run_and_verify_commit(wc_dir,                                        expected_output, expected_status,                                        None, None, None, None, None,                                        wc_dir)  # Set property to do keyword expansion on A/mu, commit.  svntest.actions.run_and_verify_svn(None, None, [],                                     'propset', 'svn:keywords', 'Rev', mu_path)  expected_output = wc.State(wc_dir, {    'A/mu' : Item(verb='Sending'),    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 3)  expected_status.tweak(wc_rev=1)  expected_status.tweak('A/mu', wc_rev=3)  svntest.actions.run_and_verify_commit(wc_dir,                                        expected_output, expected_status,                                        None, None, None, None, None,                                        wc_dir)  # Check out into another wc dir  other_wc_dir = sbox.add_wc_path('other')  mu_other_path = os.path.join(other_wc_dir, 'A', 'mu')    svntest.actions.run_and_verify_svn (None, None, [], 'checkout',                                      '--username', svntest.main.wc_author,                                      '--password', svntest.main.wc_passwd,                                      svntest.main.current_repo_url,                                      other_wc_dir)  mu_other_contents = open(mu_other_path).read()  if mu_other_contents != "This is the file 'mu'.\n$Rev: 3 $":    print "'%s' does not have the expected contents" % mu_other_path    raise svntest.Failure  #----------------------------------------------------------------------#      Add the keyword property to a file, svn revert the file#      This should not display any error messagedef propset_revert_noerror(sbox):  "propset, revert"  sbox.build()  wc_dir = sbox.wc_dir  mu_path = os.path.join(wc_dir, 'A', 'mu')  # Set the Rev keyword for the mu file  # could use the keywords_on()/keywords_off() functions to  # set/del all svn:keywords  svntest.actions.run_and_verify_svn(None, None, [],                                     'propset', 'svn:keywords', 'Rev', mu_path)  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.tweak('A/mu', status=' M')  svntest.actions.run_and_verify_status(wc_dir, expected_status)  # Revert the propset  svntest.actions.run_and_verify_svn(None, None, [], 'revert', mu_path)  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  svntest.actions.run_and_verify_status(wc_dir, expected_status)  ######################################################################### Run the tests# list all tests here, starting with None:test_list = [ None,              keywords_from_birth,              # enable_translation,              # checkout_translated,              # disable_translation,              update_modified_with_translation,              eol_change_is_text_mod,              keyword_expanded_on_checkout,              cat_keyword_expansion,              copy_propset_commit,              propset_commit_checkout_nocrash,              propset_revert_noerror,              ]if __name__ == '__main__':  svntest.main.run_tests(test_list)  # NOTREACHED### End of file.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -