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

📄 schedule_tests.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 2 页
字号:
#!/usr/bin/env python##  schedule_tests.py:  testing working copy scheduling#                      (adds, deletes, reversion)##  Subversion is a tool for revision control. #  See http://subversion.tigris.org for more information.#    # ====================================================================# Copyright (c) 2000-2004 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, shutil# Our testing moduleimport svntestfrom svntest import SVNAnyOutput# (abbreviation)Skip = svntest.testcase.SkipXFail = svntest.testcase.XFailItem = svntest.wc.StateItem####################################################################### Tests##   Each test must return on success or raise on failure.#########################################################################  Stage I - Schedules and modifications, verified with `svn status'##  These tests make schedule changes and local mods, and verify that status#  output is as expected.  In a second stage, reversion of these changes is#  tested.  Potentially, a third stage could test committing these same#  changes.##  NOTE: these tests are run within the Stage II tests, not on their own.#def add_files(sbox):  "schedule: add some files"  sbox.build()  wc_dir = sbox.wc_dir  # Create some files, then schedule them for addition  delta_path = os.path.join(wc_dir, 'delta')  zeta_path = os.path.join(wc_dir, 'A', 'B', 'zeta')  epsilon_path = os.path.join(wc_dir, 'A', 'D', 'G', 'epsilon')    svntest.main.file_append(delta_path, "This is the file 'delta'.")  svntest.main.file_append(zeta_path, "This is the file 'zeta'.")  svntest.main.file_append(epsilon_path, "This is the file 'epsilon'.")    svntest.main.run_svn(None, 'add', delta_path, zeta_path, epsilon_path)    # Make sure the adds show up as such in status  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.add({    'delta' : Item(status='A ', wc_rev=0),    'A/B/zeta' : Item(status='A ', wc_rev=0),    'A/D/G/epsilon' : Item(status='A ', wc_rev=0),    })  svntest.actions.run_and_verify_status(wc_dir, expected_status)#----------------------------------------------------------------------def add_directories(sbox):  "schedule: add some directories"  sbox.build()  wc_dir = sbox.wc_dir  # Create some directories, then schedule them for addition  X_path = os.path.join(wc_dir, 'X')  Y_path = os.path.join(wc_dir, 'A', 'C', 'Y')  Z_path = os.path.join(wc_dir, 'A', 'D', 'H', 'Z')    os.mkdir(X_path)  os.mkdir(Y_path)  os.mkdir(Z_path)    svntest.main.run_svn(None, 'add', X_path, Y_path, Z_path)    # Make sure the adds show up as such in status  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.add({    'X' : Item(status='A ', wc_rev=0),    'A/C/Y' : Item(status='A ', wc_rev=0),    'A/D/H/Z' : Item(status='A ', wc_rev=0),    })  svntest.actions.run_and_verify_status(wc_dir, expected_status)#----------------------------------------------------------------------def nested_adds(sbox):  "schedule: add some nested files and directories"  sbox.build()  wc_dir = sbox.wc_dir  # Create some directories then schedule them for addition  X_path = os.path.join(wc_dir, 'X')  Y_path = os.path.join(wc_dir, 'A', 'C', 'Y')  Z_path = os.path.join(wc_dir, 'A', 'D', 'H', 'Z')  os.mkdir(X_path)  os.mkdir(Y_path)  os.mkdir(Z_path)  # Now, create some files and directories to put into our newly added  # directories  P_path = os.path.join(X_path, 'P')  Q_path = os.path.join(Y_path, 'Q')  R_path = os.path.join(Z_path, 'R')  os.mkdir(P_path)  os.mkdir(Q_path)  os.mkdir(R_path)    delta_path = os.path.join(X_path, 'delta')  epsilon_path = os.path.join(Y_path, 'epsilon')  upsilon_path = os.path.join(Y_path, 'upsilon')  zeta_path = os.path.join(Z_path, 'zeta')  svntest.main.file_append(delta_path, "This is the file 'delta'.")  svntest.main.file_append(epsilon_path, "This is the file 'epsilon'.")  svntest.main.file_append(upsilon_path, "This is the file 'upsilon'.")  svntest.main.file_append(zeta_path, "This is the file 'zeta'.")  # Finally, let's try adding our new files and directories  svntest.main.run_svn(None, 'add', X_path, Y_path, Z_path)      # Make sure the adds show up as such in status  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.add({    'X' : Item(status='A ', wc_rev=0),    'A/C/Y' : Item(status='A ', wc_rev=0),    'A/D/H/Z' : Item(status='A ', wc_rev=0),    'X/P' : Item(status='A ', wc_rev=0),    'A/C/Y/Q' : Item(status='A ', wc_rev=0),    'A/D/H/Z/R' : Item(status='A ', wc_rev=0),    'X/delta' : Item(status='A ', wc_rev=0),    'A/C/Y/epsilon' : Item(status='A ', wc_rev=0),    'A/C/Y/upsilon' : Item(status='A ', wc_rev=0),    'A/D/H/Z/zeta' : Item(status='A ', wc_rev=0),    })  svntest.actions.run_and_verify_status(wc_dir, expected_status)#----------------------------------------------------------------------def add_executable(sbox):  "schedule: add some executable files"  sbox.build()  def runTest(wc_dir, fileName, perm, executable):    fileName = os.path.join(wc_dir, fileName)    if executable:      expected_out = ["*\n"]    else:      expected_out = []    f = open(fileName,"w")    f.close()    os.chmod(fileName,perm)    svntest.main.run_svn(None, 'add', fileName)    svntest.actions.run_and_verify_svn(None, expected_out, [],                                       'propget', "svn:executable", fileName)      test_cases = [    ("all_exe",   0777, 1),    ("none_exe",  0666, 0),    ("user_exe",  0766, 1),    ("group_exe", 0676, 0),    ("other_exe", 0667, 0),    ]  for test_case in test_cases:    runTest(sbox.wc_dir, *test_case)#----------------------------------------------------------------------def delete_files(sbox):  "schedule: delete some files"  sbox.build()  wc_dir = sbox.wc_dir  # Schedule some files for deletion  iota_path = os.path.join(wc_dir, 'iota')  mu_path = os.path.join(wc_dir, 'A', 'mu')  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')  omega_path = os.path.join(wc_dir, 'A', 'D', 'H', 'omega')    svntest.main.run_svn(None, 'del', iota_path, mu_path, rho_path, omega_path)      # Make sure the deletes show up as such in status  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.tweak('iota', 'A/mu', 'A/D/G/rho', 'A/D/H/omega',                        status='D ')  svntest.actions.run_and_verify_status(wc_dir, expected_status)#----------------------------------------------------------------------def delete_dirs(sbox):  "schedule: delete some directories"  sbox.build()  wc_dir = sbox.wc_dir  # Schedule some directories for deletion (this is recursive!)  E_path = os.path.join(wc_dir, 'A', 'B', 'E')  F_path = os.path.join(wc_dir, 'A', 'B', 'F')  H_path = os.path.join(wc_dir, 'A', 'D', 'H')  alpha_path = os.path.join(E_path, 'alpha')  beta_path  = os.path.join(E_path, 'beta')  chi_path   = os.path.join(H_path, 'chi')  omega_path = os.path.join(H_path, 'omega')  psi_path   = os.path.join(H_path, 'psi')    # Now, delete (recursively) the directories.  svntest.main.run_svn(None, 'del', E_path, F_path, H_path)      # Make sure the deletes show up as such in status  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.tweak('A/B/E', 'A/B/E/alpha', 'A/B/E/beta',                        'A/B/F',                        'A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi',                        status='D ')  svntest.actions.run_and_verify_status(wc_dir, expected_status)########################################################################  Stage II - Reversion of changes made in Stage I##  Each test in Stage II calls the corresponding Stage I test#  and then also tests reversion of those changes.#def check_reversion(files, output):  expected_output = []  for file in files:    expected_output = expected_output + ["Reverted '" + file + "'\n"]  output.sort()  expected_output.sort()  if output != expected_output:    print "Expected output:", expected_output    print "Actual output:  ", output    raise svntest.Failure    #----------------------------------------------------------------------def revert_add_files(sbox):  "revert: add some files"  add_files(sbox)  wc_dir = sbox.wc_dir  # Revert our changes recursively from wc_dir.  delta_path = os.path.join(wc_dir, 'delta')  zeta_path = os.path.join(wc_dir, 'A', 'B', 'zeta')  epsilon_path = os.path.join(wc_dir, 'A', 'D', 'G', 'epsilon')  files = [delta_path, zeta_path, epsilon_path]  output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                   'revert',                                                   '--recursive', wc_dir)  check_reversion(files, output)#----------------------------------------------------------------------def revert_add_directories(sbox):  "revert: add some directories"  add_directories(sbox)  wc_dir = sbox.wc_dir  # Revert our changes recursively from wc_dir.  X_path = os.path.join(wc_dir, 'X')  Y_path = os.path.join(wc_dir, 'A', 'C', 'Y')  Z_path = os.path.join(wc_dir, 'A', 'D', 'H', 'Z')  files = [X_path, Y_path, Z_path]    output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                   'revert',                                                   '--recursive', wc_dir)  check_reversion(files, output)#----------------------------------------------------------------------def revert_nested_adds(sbox):  "revert: add some nested files and directories"  nested_adds(sbox)  wc_dir = sbox.wc_dir  # Revert our changes recursively from wc_dir.  X_path = os.path.join(wc_dir, 'X')  Y_path = os.path.join(wc_dir, 'A', 'C', 'Y')  Z_path = os.path.join(wc_dir, 'A', 'D', 'H', 'Z')  files = [X_path, Y_path, Z_path]  output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                   'revert',                                                   '--recursive', wc_dir)  check_reversion(files, output)  #----------------------------------------------------------------------def revert_add_executable(sbox):  "revert: add some executable files"  add_executable(sbox)  wc_dir = sbox.wc_dir  

⌨️ 快捷键说明

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