Hi,
In <20060613.041306.59474475.nori1@dolphin.c.u-tokyo.ac.jp>
"Re: [PATCH] Add a new method, Svn::Core::LogChangedPath#copied? for the SWIG/Ruby bindings." on Tue, 13 Jun 2006 04:13:06 +0900 (JST),
Kobayashi Noritada <nori1@dolphin.c.u-tokyo.ac.jp> wrote:
> > > Here is a patch to add a new method, Svn::Core::LogChangedPath#copied?
> > > implemented with Svn::Util.copy?.
> >
> > +1
> > I'm very happy if you add a test case for your patch.
> > Anyway, please commit, nori.
>
> Thank you for reviewing my patch.
> I've written a test case.
> Here attached a new patch with a test case.
I found some codings I don't like in your test case. What
about the following my idea?
Thanks,
--
kou
Index: subversion/bindings/swig/ruby/test/my-assertions.rb
===================================================================
--- subversion/bindings/swig/ruby/test/my-assertions.rb (revision 20075)
+++ subversion/bindings/swig/ruby/test/my-assertions.rb (working copy)
@@ -16,7 +16,14 @@
assert_equal(false, boolean, message)
end
end
-
+
+ def assert_nested_sorted_array(expected, actual, message=nil)
+ _wrap_assertion do
+ assert_equal(expected.collect {|elem| elem.sort},
+ actual.collect {|elem| elem.sort},
+ message)
+ end
+ end
end
end
end
Index: subversion/bindings/swig/ruby/test/test_client.rb
===================================================================
--- subversion/bindings/swig/ruby/test/test_client.rb (revision 20075)
+++ subversion/bindings/swig/ruby/test/test_client.rb (working copy)
@@ -558,6 +558,75 @@
end
def test_log
+ log1 = "sample log1"
+ log2 = "sample log2"
+ log3 = "sample log3"
+ src1 = "source1\n"
+ src2 = "source2\n"
+ src3 = "source3\n"
+ file1 = "sample1.txt"
+ file2 = "sample2.txt"
+ file3 = "sample3.txt"
+ path1 = File.join(@wc_path, file1)
+ path2 = File.join(@wc_path, file2)
+ path3 = File.join(@wc_path, file3)
+ abs_path1 = File.join('', file1)
+ abs_path2 = File.join('', file2)
+ abs_path3 = File.join('', file3)
+
+ ctx = make_context(log1)
+ File.open(path1, "w") {|f| f.print(src1)}
+ ctx.add(path1)
+ rev1 = ctx.ci(@wc_path).revision
+
+ ctx = make_context(log2)
+ ctx.cp(path1, path2)
+ rev2 = ctx.ci(@wc_path).revision
+
+ ctx = make_context(log3)
+ ctx.cp(path1, path3)
+ File.open(path1, "w") {|f| f.print(src2)}
+ File.open(path3, "w") {|f| f.print(src3)}
+ rev3 = ctx.ci(@wc_path).revision
+
+ changed_paths_lists = {}
+ revs = {}
+ messages = {}
+ keys = [@wc_path, path1, path2, path3]
+ keys.each do |key|
+ revs[key] = []
+ changed_paths_lists[key] = []
+ messages[key] = []
+ args = [key, 1, "HEAD", 0, true, nil]
+ ctx.log(*args) do |changed_paths, rev, author, date, message|
+ revs[key] << rev
+ changed_paths_lists[key] << changed_paths
+ messages[key] << message
+ end
+ end
+ changed_paths_list = changed_paths_lists[@wc_path]
+
+ assert_equal([rev1, rev2, rev3], revs[@wc_path])
+ assert_equal([rev1, rev3], revs[path1])
+ assert_equal([rev1, rev2], revs[path2])
+ assert_equal([rev1, rev3], revs[path3])
+ assert_equal([log1, log2, log3], messages[@wc_path])
+
+ expected = [[abs_path1], [abs_path2], [abs_path1, abs_path3]]
+ actual = changed_paths_list.collect {|changed_paths| changed_paths.keys}
+ assert_nested_sorted_array(expected, actual)
+
+ assert_equal('A', changed_paths_list[0][abs_path1].action)
+ assert_false(changed_paths_list[0][abs_path1].copied?)
+ assert_equal('A', changed_paths_list[1][abs_path2].action)
+ assert_true(changed_paths_list[1][abs_path2].copied?)
+ assert_equal(abs_path1, changed_paths_list[1][abs_path2].copyfrom_path)
+ assert_equal(rev1, changed_paths_list[1][abs_path2].copyfrom_rev)
+ assert_equal('M', changed_paths_list[2][abs_path1].action)
+ assert_equal('A', changed_paths_list[2][abs_path3].action)
+ end
+
+ def test_log_message
log = "sample log"
file = "hello.txt"
path = File.join(@wc_path, file)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Jun 13 14:52:24 2006