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

📄 stat_tests.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 3 页
字号:
#!/usr/bin/env python##  stat_tests.py:  testing the svn stat command##  Subversion is a tool for revision control. #  See http://subversion.tigris.org for more information.#    # ====================================================================# Copyright (c) 2000-2006 CollabNet.  All rights reserved.## This software is licensed as described in the file COPYING, which# you should have received as part of this distribution.  The terms# are also available at http://subversion.tigris.org/license-1.html.# If newer versions of this license are posted there, you may use a# newer version instead, at your option.######################################################################## General modulesimport string, sys, os.path, re, time# Our testing moduleimport svntestfrom svntest import wc# (abbreviation)Skip = svntest.testcase.SkipXFail = svntest.testcase.XFailItem = svntest.wc.StateItem####################################################################### Tests##   Each test must return on success or raise on failure.#----------------------------------------------------------------------def status_unversioned_file_in_current_dir(sbox):  "status on unversioned file in current directory"  sbox.build()  wc_dir = sbox.wc_dir  was_cwd = os.getcwd()  try:    os.chdir(wc_dir)    svntest.main.file_append('foo', 'a new file')    svntest.actions.run_and_verify_svn(None, [ "?      foo\n" ], [],                                       'stat', 'foo')  finally:    os.chdir(was_cwd)#----------------------------------------------------------------------# Regression for issue #590def status_update_with_nested_adds(sbox):  "run 'status -u' when nested additions are pending"  sbox.build()  wc_dir = sbox.wc_dir  # Make a backup copy of the working copy  wc_backup = sbox.add_wc_path('backup')  svntest.actions.duplicate_dir(wc_dir, wc_backup)    # Create newdir and newfile  newdir_path = os.path.join(wc_dir, 'newdir')  newfile_path = os.path.join(wc_dir, 'newdir', 'newfile')  os.makedirs(newdir_path)  svntest.main.file_append (newfile_path, 'new text')  # Schedule newdir and newfile for addition (note that the add is recursive)  svntest.main.run_svn(None, 'add', newdir_path)  # Created expected output tree for commit  expected_output = svntest.wc.State(wc_dir, {    'newdir' : Item(verb='Adding'),    'newdir/newfile' : Item(verb='Adding'),    })  # Create expected status tree; all local revisions should be at 1,  # but newdir and newfile should be at revision 2.  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.tweak(wc_rev=1)  expected_status.add({    'newdir' : Item(status='  ', wc_rev=2),    'newdir/newfile' : Item(status='  ', wc_rev=2),    })  # Commit.  svntest.actions.run_and_verify_commit (wc_dir, expected_output,                                         expected_status, None,                                         None, None, None, None, wc_dir)  # Now we go to the backup working copy, still at revision 1.  # We will run 'svn st -u', and make sure that newdir/newfile is reported  # as a nonexistent (but pending) path.  # Create expected status tree; all local revisions should be at 1,  # but newdir and newfile should be present with 'blank' attributes.  expected_status = svntest.actions.get_virginal_state(wc_backup, 2)  expected_status.tweak(wc_rev=1)  # Verify status.  Notice that we're running status *without* the  # --quiet flag, so the unversioned items will appear.  # Unfortunately, the regexp that we currently use to parse status  # output is unable to parse a line that has no working revision!  If  # an error happens, we'll catch it here.  So that's a good enough  # regression test for now.  Someday, though, it would be nice to  # positively match the mostly-empty lines.  svntest.actions.run_and_verify_unquiet_status(wc_backup,                                                expected_status)  #----------------------------------------------------------------------# svn status -vN should include all entries in a directorydef status_shows_all_in_current_dir(sbox):  "status -vN shows all items in current directory"  sbox.build()  wc_dir = sbox.wc_dir  was_cwd = os.getcwd()  os.chdir(wc_dir)  try:    output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                     'stat', '-vN')    if (len(output) != len(os.listdir("."))):      raise svntest.Failure  finally:    os.chdir(was_cwd)#----------------------------------------------------------------------def status_missing_file(sbox):  "status with a versioned file missing"  sbox.build()  wc_dir = sbox.wc_dir    was_cwd = os.getcwd()    os.chdir(wc_dir)  try:    os.remove('iota')    output, err = svntest.actions.run_and_verify_svn(None, None, [], 'status')    for line in output:      if not re.match("! +iota", line):        raise svntest.Failure    # This invocation is for issue #2127.    output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                     'status', '-u', 'iota')    found_it = 0    for line in output:      if re.match("! +1 +iota", line):        found_it = 1    if not found_it:      raise svntest.Failure  finally:    os.chdir(was_cwd)#----------------------------------------------------------------------def status_type_change(sbox):  "status on versioned items whose type has changed"  sbox.build()  wc_dir = sbox.wc_dir  was_cwd = os.getcwd()  os.chdir(wc_dir)  try:    # First replace a versioned dir with a file and a versioned file    # with a versioned dir.    os.rename('iota', 'was_iota')    os.rename('A', 'iota')    os.rename('was_iota', 'A')    output, err = svntest.actions.run_and_verify_svn(None, None, [], 'status')    if len(output) != 2:      raise svntest.Failure    for line in output:      if not re.match("~ +(iota|A)", line):        raise svntest.Failure    # Now change the file that is obstructing the versioned dir into an    # unversioned dir.    os.remove('A')    os.mkdir('A')    output, err = svntest.actions.run_and_verify_svn(None, None, [], 'status')    if len(output) != 2:      raise svntest.Failure    for line in output:      if not re.match("~ +(iota|A)", line):        raise svntest.Failure    # Now change the versioned dir that is obstructing the file into an    # unversioned dir.    svntest.main.safe_rmtree('iota')    os.mkdir('iota')    output, err = svntest.actions.run_and_verify_svn(None, None, [], 'status')    if len(output) != 2:      raise svntest.Failure    for line in output:      if not re.match("~ +(iota|A)", line):        raise svntest.Failure  finally:    os.chdir(was_cwd)#----------------------------------------------------------------------def status_type_change_to_symlink(sbox):  "status on versioned items replaced by symlinks"  sbox.build()  wc_dir = sbox.wc_dir    was_cwd = os.getcwd()  os.chdir(wc_dir)  try:    # "broken" symlinks    os.remove('iota')    os.symlink('foo', 'iota')    svntest.main.safe_rmtree('A/D')    os.symlink('bar', 'A/D')    output, err = svntest.actions.run_and_verify_svn(None, None, [], 'status')    if len(output) != 2:      raise svntest.Failure    for line in output:      if not re.match("~ +(iota|A/D)", line):        raise svntest.Failure    # "valid" symlinks    os.remove('iota')    os.remove('A/D')    os.symlink('A/mu', 'iota')    os.symlink('C', 'A/D')    output, err = svntest.actions.run_and_verify_svn(None, None, [], 'status')    if len(output) != 2:      raise svntest.Failure    for line in output:      if not re.match("~ +(iota|A/D)", line):        raise svntest.Failure  finally:    os.chdir(was_cwd)#----------------------------------------------------------------------# Regression test for revision 3686.def status_with_new_files_pending(sbox):  "status -u with new files in the repository"  sbox.build()  wc_dir = sbox.wc_dir    was_cwd = os.getcwd()  os.chdir(wc_dir)  try:    svntest.main.file_append('newfile', 'this is a new file')    svntest.main.run_svn(None, 'add', 'newfile')    svntest.main.run_svn(None, 'ci', '-m', 'logmsg')    svntest.main.run_svn(None, 'up', '-r', '1')    output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                     'status', '-u')    # The bug fixed in revision 3686 was a seg fault.  We don't have a    # reliable way to detect a seg fault here, since we haven't dealt    # with the popen2{Popen3,Popen4} mess in Python yet (the latter two    # are classes within the first, which is a module, and the Popen3    # class is not the same as os.popen3().  Got that?)  See the Python    # docs for details; in the meantime, no output means there was a    # problem.    for line in output:      if line.find('newfile') != -1:        break    else:      raise svntest.Failure  finally:    os.chdir(was_cwd)#----------------------------------------------------------------------def status_for_unignored_file(sbox):  "status for unignored file and directory"  sbox.build()  wc_dir = sbox.wc_dir    was_cwd = os.getcwd()  os.chdir(wc_dir)  try:    # use a temp file to set properties with wildcards in their values    # otherwise Win32/VS2005 will expand them    svntest.main.file_append ('proptmp', 'new*')    svntest.main.file_append('newfile', 'this is a new file')    os.makedirs('newdir')    svntest.main.run_svn(None, 'propset', 'svn:ignore', '-F', 'proptmp', '.')    os.remove('proptmp')    # status on the directory with --no-ignore    svntest.actions.run_and_verify_svn(None,                                       ['I      newdir\n',                                        'I      newfile\n',                                        ' M     .\n'],                                       [],                                       'status', '--no-ignore', '.')    # status specifying the file explicitly on the command line    svntest.actions.run_and_verify_svn(None,                                       ['I      newdir\n',                                        'I      newfile\n'],                                       [],                                       'status', 'newdir', 'newfile')    finally:    os.chdir(was_cwd)#----------------------------------------------------------------------def status_for_nonexistent_file(sbox):  "status on missing and unversioned file"  sbox.build()  wc_dir = sbox.wc_dir  was_cwd = os.getcwd()  os.chdir(wc_dir)  try:    output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                     'status',                                                     'nonexistent-file')    # there should *not* be a status line printed for the nonexistent file     for line in output:      if re.match(" +nonexistent-file", line):        raise svntest.Failure    finally:    os.chdir(was_cwd)#----------------------------------------------------------------------def status_file_needs_update(sbox):  "status -u indicates out-of-dateness"  # See this thread:  #  #    http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=27975  #  # Basically, Andreas was seeing inconsistent results depending on  # whether or not he accompanied 'svn status -u' with '-v':  #  #    % svn st -u  #    Head revision:     67  #    %  #  # ...and yet...  #   #    % svn st -u -v  #                   56        6          k   cron-daily.pl  #           *       56       44          k   crontab.root  #                   56        6          k   gmls-lR.pl  #    Head revision:     67  #    %  #  # The first status should show the asterisk, too.  There was never  # any issue for this bug, so this comment and the thread are your  # audit trail :-).  sbox.build()  wc_dir = sbox.wc_dir    other_wc = sbox.add_wc_path('other')  svntest.actions.duplicate_dir(wc_dir, other_wc)  was_cwd = os.getcwd()  os.chdir(wc_dir)  svntest.main.file_append('crontab.root', 'New file crontab.root.\n')  svntest.main.run_svn(None, 'add', 'crontab.root')  svntest.main.run_svn(None, 'ci', '-m', 'log msg')  os.chdir(was_cwd)

⌨️ 快捷键说明

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