📄 basic_tests.py
字号:
raise svntest.Failure
# Deleting unversioned file explicitly
foo_path = os.path.join(wc_dir, 'foo')
svntest.main.file_append(foo_path, 'unversioned foo')
svntest.actions.run_and_verify_svn(None, None, [],
'rm', '--force', foo_path)
verify_file_deleted("Failed to remove unversioned file foo", foo_path)
# Deleting non-existant unversioned item
svntest.actions.run_and_verify_svn(None, None, [],
'rm', '--force', foo_path)
# At one stage deleting an URL dumped core
iota_URL = svntest.main.current_repo_url + '/iota'
svntest.actions.run_and_verify_svn(None,
["\n", "Committed revision 2.\n"], None,
'rm', '-m', 'delete iota URL',
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd,
iota_URL)
#----------------------------------------------------------------------
def basic_checkout_deleted(sbox):
"checkout a path no longer in HEAD"
sbox.build()
wc_dir = sbox.wc_dir
# Delete A/D and commit.
D_path = os.path.join(wc_dir, 'A', 'D')
svntest.actions.run_and_verify_svn("error scheduling A/D for deletion",
None, [], 'rm', '--force', D_path)
expected_output = wc.State(wc_dir, {
'A/D' : Item(verb='Deleting'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.tweak(wc_rev=1)
expected_status.remove('A/D', 'A/D/G', 'A/D/G/rho', 'A/D/G/pi', 'A/D/G/tau',
'A/D/H', 'A/D/H/chi', 'A/D/H/psi', 'A/D/H/omega',
'A/D/gamma')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output, expected_status,
None, None, None, None, None,
wc_dir)
# Now try to checkout revision 1 of A/D.
url = svntest.main.current_repo_url + '/A/D'
wc2 = os.path.join (sbox.wc_dir, 'new_D')
svntest.actions.run_and_verify_svn("error checking out r1 of A/D",
None, [], 'co', '-r', '1',
'--username',
svntest.main.wc_author,
'--password',
svntest.main.wc_passwd,
url, wc2)
#----------------------------------------------------------------------
# Issue 846, changing a deleted file to an added directory is not
# supported.
def basic_node_kind_change(sbox):
"attempt to change node kind"
sbox.build()
wc_dir = sbox.wc_dir
# Schedule a file for deletion
gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
svntest.main.run_svn(None, 'rm', gamma_path)
# Status shows deleted file
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D/gamma', status='D ')
svntest.actions.run_and_verify_status(wc_dir, expected_status)
# Try and fail to create a directory (file scheduled for deletion)
svntest.actions.run_and_verify_svn('Cannot change node kind',
None, SVNAnyOutput,
'mkdir', gamma_path)
# Status is unchanged
svntest.actions.run_and_verify_status(wc_dir, expected_status)
# Commit file deletion
expected_output = wc.State(wc_dir, {
'A/D/gamma' : Item(verb='Deleting'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.tweak(wc_rev=1)
expected_status.remove('A/D/gamma')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output, expected_status,
None, None, None, None, None,
wc_dir)
# Try and fail to create a directory (file deleted)
svntest.actions.run_and_verify_svn('Cannot change node kind',
None, SVNAnyOutput,
'mkdir', gamma_path)
# Status is unchanged
svntest.actions.run_and_verify_status(wc_dir, expected_status)
# Update to finally get rid of file
svntest.actions.run_and_verify_svn(None, None, [], 'up', wc_dir)
# mkdir should succeed
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', gamma_path)
expected_status.tweak(wc_rev=2)
expected_status.add({
'A/D/gamma' : Item(status='A ', wc_rev=0, repos_rev=2),
})
svntest.actions.run_and_verify_status(wc_dir, expected_status)
#----------------------------------------------------------------------
def basic_import(sbox):
"basic import of single new file"
sbox.build()
wc_dir = sbox.wc_dir
# create a new directory with files of various permissions
new_path = os.path.join(wc_dir, 'new_file')
svntest.main.file_append(new_path, "some text")
# import new files into repository
url = svntest.main.current_repo_url + "/dirA/dirB/new_file"
output, errput = svntest.actions.run_and_verify_svn(
'Cannot change node kind', None, [], 'import',
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd,
'-m', 'Log message for new import', new_path, url)
lastline = string.strip(output.pop())
cm = re.compile ("(Committed|Imported) revision [0-9]+.")
match = cm.search (lastline)
if not match:
### we should raise a less generic error here. which?
raise svntest.Failure
# remove (uncontrolled) local file
os.remove(new_path)
# Create expected disk tree for the update (disregarding props)
expected_disk = svntest.main.greek_state.copy()
expected_disk.add({
'dirA/dirB/new_file' : Item('some text'),
})
# Create expected status tree for the update (disregarding props).
# Newly imported file should be at revision 2.
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.add({
'dirA' : Item(status=' ', wc_rev=2, repos_rev=2),
'dirA/dirB' : Item(status=' ', wc_rev=2, repos_rev=2),
'dirA/dirB/new_file' : Item(status=' ', wc_rev=2, repos_rev=2),
})
# Create expected output tree for the update.
expected_output = svntest.wc.State(wc_dir, {
'dirA' : Item(status='A '),
'dirA/dirB' : Item(status='A '),
'dirA/dirB/new_file' : Item(status='A '),
})
# do update and check three ways
svntest.actions.run_and_verify_update(wc_dir,
expected_output,
expected_disk,
expected_status,
None, None, None,
None, None, 1)
#----------------------------------------------------------------------
# this test should be SKIPped on systems without the executable bit
def basic_import_executable(sbox):
"basic import of executable files"
sbox.build()
wc_dir = sbox.wc_dir
# create a new directory with files of various permissions
xt_path = os.path.join(wc_dir, "XT")
os.makedirs(xt_path)
all_path = os.path.join(wc_dir, "XT/all_exe")
none_path = os.path.join(wc_dir, "XT/none_exe")
user_path = os.path.join(wc_dir, "XT/user_exe")
group_path = os.path.join(wc_dir, "XT/group_exe")
other_path = os.path.join(wc_dir, "XT/other_exe")
for path in [all_path, none_path, user_path, group_path, other_path]:
svntest.main.file_append(path, "some text")
# set executable bits
os.chmod(all_path, 0777)
os.chmod(none_path, 0666)
os.chmod(user_path, 0766)
os.chmod(group_path, 0676)
os.chmod(other_path, 0667)
# import new files into repository
url = svntest.main.current_repo_url
output, errput = svntest.actions.run_and_verify_svn(
None, None, [], 'import',
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd,
'-m', 'Log message for new import', xt_path, url)
lastline = string.strip(output.pop())
cm = re.compile ("(Committed|Imported) revision [0-9]+.")
match = cm.search (lastline)
if not match:
### we should raise a less generic error here. which?
raise svntest.Failure
# remove (uncontrolled) local files
svntest.main.safe_rmtree(xt_path)
# Create expected disk tree for the update (disregarding props)
expected_disk = svntest.main.greek_state.copy()
expected_disk.add({
'all_exe' : Item('some text', props={'svn:executable' : ''}),
'none_exe' : Item('some text'),
'user_exe' : Item('some text', props={'svn:executable' : ''}),
'group_exe' : Item('some text'),
'other_exe' : Item('some text'),
})
# Create expected status tree for the update (disregarding props).
# Newly imported file should be at revision 2.
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.add({
'all_exe' : Item(status=' ', wc_rev=2, repos_rev=2),
'none_exe' : Item(status=' ', wc_rev=2, repos_rev=2),
'user_exe' : Item(status=' ', wc_rev=2, repos_rev=2),
'group_exe' : Item(status=' ', wc_rev=2, repos_rev=2),
'other_exe' : Item(status=' ', wc_rev=2, repos_rev=2),
})
# Create expected output tree for the update.
expected_output = svntest.wc.State(wc_dir, {
'all_exe' : Item(status='A '),
'none_exe' : Item(status='A '),
'user_exe' : Item(status='A '),
'group_exe' : Item(status='A '),
'other_exe' : Item(status='A '),
})
# do update and check three ways
svntest.actions.run_and_verify_update(wc_dir,
expected_output,
expected_disk,
expected_status,
None, None, None,
None, None, 1)
#----------------------------------------------------------------------
def basic_cat(sbox):
"basic cat of files"
sbox.build()
wc_dir = sbox.wc_dir
mu_path = os.path.join(wc_dir, 'A', 'mu')
# Get repository text even if wc is modified
svntest.main.file_append(mu_path, "some text")
svntest.actions.run_and_verify_svn(None, ["This is the file 'mu'."],
None, 'cat',
###TODO is user/pass really necessary?
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd,
mu_path)
#----------------------------------------------------------------------
def basic_ls(sbox):
'basic ls'
sbox.build()
wc_dir = sbox.wc_dir
# Even on Windows, the output will use forward slashes, so that's
# what we expect below.
cwd = os.getcwd()
try:
os.chdir(wc_dir)
svntest.actions.run_and_verify_svn("ls implicit current directory",
["A/\n", "iota\n"],
None, 'ls',
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd)
finally:
os.chdir(cwd)
svntest.actions.run_and_verify_svn('ls the root of working copy',
['A/\n', 'iota\n'],
None, 'ls',
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd,
wc_dir)
svntest.actions.run_and_verify_svn('ls a working copy directory',
['B/\n', 'C/\n', 'D/\n', 'mu\n'],
None, 'ls',
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd,
os.path.join(wc_dir, 'A'))
svntest.actions.run_and_verify_svn('ls working copy directory with -r BASE',
['B/\n', 'C/\n', 'D/\n', 'mu\n'],
None, 'ls', '-r', 'BASE',
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd,
os.path.join(wc_dir, 'A'))
svntest.actions.run_and_verify_svn('ls a single file',
['mu\n'],
None, 'ls',
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd,
os.path.join(wc_dir, 'A', 'mu'))
#----------------------------------------------------------------------
def nonexistent_repository(sbox):
"'svn log file:///nonexistent_path' should fail"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -