Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/ruby/test/test_wc.rb view on Meta::CPAN
Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
access.copy(path1, file3)
assert(File.exist?(path3))
access.delete(path1)
assert(!File.exist?(path1))
FileUtils.touch(path4)
access.add(path4)
assert(File.exist?(path4))
access.add_repos_file2(path5, path2, {})
assert_equal(source, File.open(path5) {|f| f.read})
status = access.status(path2)
assert_equal(Svn::Wc::STATUS_MISSING, status.text_status)
access.remove_from_revision_control(file2)
status = access.status(path2)
assert_equal(Svn::Wc::STATUS_NONE, status.text_status)
end
end
end
def test_delete
source = "source"
file = "file"
path = File.join(@wc_path, file)
log = "sample log"
make_context(log) do |ctx|
File.open(path, "w") {|f| f.print(source)}
ctx.add(path)
ctx.ci(@wc_path).revision
assert(File.exists?(path))
Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
access.delete(path)
end
assert(!File.exists?(path))
ctx.revert(path)
assert(File.exists?(path))
Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
access.delete(path, nil, nil, true)
end
assert(File.exists?(path))
end
end
def test_locked
assert(!Svn::Wc.locked?(@wc_path))
Svn::Wc::AdmAccess.open(nil, @wc_path, true, -1) do |access|
assert(Svn::Wc.locked?(@wc_path))
end
assert(!Svn::Wc.locked?(@wc_path))
Svn::Wc::AdmAccess.open(nil, @wc_path, false, -1) do |access|
assert(!Svn::Wc.locked?(@wc_path))
end
assert(!Svn::Wc.locked?(@wc_path))
end
def assert_translated_eol(method_name)
src_file = "src"
crlf_file = "crlf"
cr_file = "cr"
lf_file = "lf"
src_path = File.join(@wc_path, src_file)
crlf_path = File.join(@wc_path, crlf_file)
cr_path = File.join(@wc_path, cr_file)
lf_path = File.join(@wc_path, lf_file)
source = "a\n"
crlf_source = source.gsub(/\n/, "\r\n")
cr_source = source.gsub(/\n/, "\r")
lf_source = source.gsub(/\n/, "\n")
File.open(crlf_path, "w") {}
File.open(cr_path, "w") {}
File.open(lf_path, "w") {}
log = "log"
make_context(log) do |ctx|
ctx.add(crlf_path)
ctx.add(cr_path)
ctx.add(lf_path)
ctx.prop_set("svn:eol-style", "CRLF", crlf_path)
ctx.prop_set("svn:eol-style", "CR", cr_path)
ctx.prop_set("svn:eol-style", "LF", lf_path)
ctx.ci(crlf_path)
ctx.ci(cr_path)
ctx.ci(lf_path)
Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
_my_assert_block do
File.open(src_path, "wb") {|f| f.print(source)}
args = [method_name, src_path, crlf_path, Svn::Wc::TRANSLATE_FROM_NF]
result = yield(access.send(*args), source)
result ||= File.open(src_path, "rb") {|f| f.read}
assert_equal(crlf_source, result)
File.open(src_path, "wb") {|f| f.print(source)}
args = [method_name, src_path, cr_path, Svn::Wc::TRANSLATE_FROM_NF]
result = yield(access.send(*args), source)
result ||= File.open(src_path, "rb") {|f| f.read}
assert_equal(cr_source, result)
File.open(src_path, "wb") {|f| f.print(source)}
args = [method_name, src_path, lf_path, Svn::Wc::TRANSLATE_FROM_NF]
result = yield(access.send(*args), source)
result ||= File.open(src_path, "rb") {|f| f.read}
assert_equal(lf_source, result)
end
end
end
end
def test_translated_file_eol
assert_translated_eol(:translated_file) do |name, source|
File.open(name, "rb") {|f| f.read}
end
end
def test_translated_file2_eol
assert_translated_eol(:translated_file2) do |file, source|
result = file.read
file.close
result
end
end
def test_translated_stream_eol
assert_translated_eol(:translated_stream) do |stream, source|
if source
stream.write(source)
stream.close
nil
else
stream.read
end
end
end
def assert_translated_keyword(method_name)
src_file = "$Revision$"
revision_file = "revision_file"
src_path = File.join(@wc_path, src_file)
revision_path = File.join(@wc_path, revision_file)
source = "$Revision$\n"
revision_source = source.gsub(/\$Revision\$/, "$Revision: 1 $")
File.open(revision_path, "w") {}
log = "log"
make_context(log) do |ctx|
ctx.add(revision_path)
ctx.prop_set("svn:keywords", "Revision", revision_path)
ctx.ci(revision_path)
Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
File.open(src_path, "wb") {|f| f.print(source)}
args = [method_name, src_path, revision_path, Svn::Wc::TRANSLATE_FROM_NF]
result = yield(access.send(*args), source)
result ||= File.open(src_path, "rb") {|f| f.read}
assert_equal(revision_source, result)
File.open(src_path, "wb") {|f| f.print(source)}
args = [method_name, src_path, revision_path, Svn::Wc::TRANSLATE_TO_NF]
assert_equal(source, yield(access.send(*args)))
end
end
end
def test_translated_file_keyword
assert_translated_keyword(:translated_file) do |name, source|
File.open(name, "rb") {|f| f.read}
end
end
def test_translated_file2_keyword
assert_translated_keyword(:translated_file2) do |file, source|
file.read
end
end
def test_translated_stream_keyword
assert_translated_keyword(:translated_stream) do |stream, source|
if source
stream.write(source)
stream.close
nil
else
( run in 0.709 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )