aboutsummaryrefslogtreecommitdiff
path: root/vcs_test.rb
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-12-09 21:21:25 +0100
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-12-09 21:21:25 +0100
commit9086b9e841bd64beed3003c9d5b3ec98525f2df7 (patch)
tree6644f6bf2680919b1880cc6028219e8cf825c95a /vcs_test.rb
parent4096ec5f0c8b81a491fa188a09f25f848f71f076 (diff)
git support added (bzr was to slow)
Diffstat (limited to 'vcs_test.rb')
-rw-r--r--vcs_test.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/vcs_test.rb b/vcs_test.rb
new file mode 100644
index 0000000..c0dc235
--- /dev/null
+++ b/vcs_test.rb
@@ -0,0 +1,60 @@
+if __FILE__ == $0
+require "test/unit"
+require "pp"
+require ARGV[0]
+require "benchmark"
+
+class VCS_test < Test::Unit::TestCase
+ def setup
+ @data = ["foo","bar","baz","spam","ham","egg"]
+ @history = ["aaa","bbb","ccc","ddd","eee","fff"]
+ @repo = "/tmp/vcs_test_#{rand(10000)}"
+ Dir.mkdir(@repo)
+ Dir.chdir(@repo)
+ VCS.init
+ File.open("data.txt","w").close
+ VCS.add("data.txt")
+ @data.each_index{|i|
+ File.open("data.txt","w"){|f| f << @data[i] }
+ VCS.commit(@history[i])
+ }
+ @b = 0
+ @t = ""
+ end
+ def teardown
+ Dir.chdir("/")
+ `rm -rf #{@repo}`
+ puts "#{@t}: #{@b}"
+ end
+ def test_cat
+ @data.each_with_index{|item,revnominusone|
+ result = ""
+ @b += Benchmark.measure{
+ result = VCS.cat(revnominusone+1,"data.txt")
+ }.total
+ assert_equal(item,result,"revno: #{revnominusone+1}")
+ }
+ @t = "cat"
+ end
+ def test_revno
+ r = -1
+ @b += Benchmark.measure{
+ r = VCS.revno
+ }.total
+ assert_equal(@data.size,r)
+ @t = "revno"
+ end
+ def test_history
+ l = nil
+ @b += Benchmark.measure{
+ l = VCS.history
+ }.total
+ assert_equal(@data.size,l.size)
+ @history.each_with_index{|h,revminusone|
+ assert_equal(h,l[revminusone+1].comment)
+ }
+
+ @t = "history"
+ end
+end
+end