about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-10-24 08:18:21 +0000
committerEric Wong <normalperson@yhbt.net>2012-10-24 08:19:36 +0000
commitfe0d54c5be260fd1ff5e175869001052a3d379fa (patch)
treec2924aa3cf43a3785aa2db97f47297c5e75022e9
parent2ce0b4a31bfae0b632d7ca031a52b24db7cc1b26 (diff)
downloadmogilefs-client-fe0d54c5be260fd1ff5e175869001052a3d379fa.tar.gz
Tests fail anyways on uncaught exceptions, so
assert_nothing_raised only makes it harder to debug the problem
by swallowing the backtrace.
-rw-r--r--test/fresh.rb13
-rw-r--r--test/socket_test.rb12
-rw-r--r--test/test_backend.rb8
-rw-r--r--test/test_db_backend.rb2
-rw-r--r--test/test_mogilefs.rb8
-rw-r--r--test/test_mogilefs_integration.rb37
-rw-r--r--test/test_mogtool_bigfile.rb6
-rw-r--r--test/test_mysql.rb2
8 files changed, 29 insertions, 59 deletions
diff --git a/test/fresh.rb b/test/fresh.rb
index 749673f..4db1e2c 100644
--- a/test/fresh.rb
+++ b/test/fresh.rb
@@ -90,17 +90,14 @@ EOF
     @admin.create_domain(domain)
     yield_for_monitor_update { @admin.get_domains.include?(domain) and break }
 
-    assert_nothing_raised do
-      @admin.create_class(domain, "klassy", 1)
-    end
+    @admin.create_class(domain, "klassy", 1)
+
     assert_raises(MogileFS::Backend::ClassExistsError) do
       @admin.create_class(domain, "klassy", 1)
     end
 
-    assert_nothing_raised do
-      @admin.update_class(domain, "klassy",
-                          :mindevcount => 1, :replpolicy => "MultipleHosts(1)")
-    end
+    @admin.update_class(domain, "klassy",
+                        :mindevcount => 1, :replpolicy => "MultipleHosts(1)")
 
     tmp = nil
     yield_for_monitor_update do
@@ -110,7 +107,7 @@ EOF
     assert tmp, "domain did not show up"
     assert_equal 1, tmp["mindevcount"]
     assert_equal "MultipleHosts(1)", tmp["replpolicy"]
-    assert_nothing_raised { @admin.update_class(domain, "klassy", 2) }
+    @admin.update_class(domain, "klassy", 2)
     ensure
       @admin.delete_class(domain, "klassy") rescue nil
   end
diff --git a/test/socket_test.rb b/test/socket_test.rb
index e217da5..7818506 100644
--- a/test/socket_test.rb
+++ b/test/socket_test.rb
@@ -11,11 +11,9 @@ module SocketTest
   def test_start
     sock = MogileFS::Socket.start(@host, @port)
     assert_instance_of MogileFS::Socket, sock, sock.inspect
-    assert_nothing_raised do
-      begin
-        sock.write_nonblock("a")
-      rescue Errno::EAGAIN
-      end
+    begin
+      sock.write_nonblock("a")
+    rescue Errno::EAGAIN
     end
     thr = Thread.new { @srv.accept }
     accepted = thr.value
@@ -26,9 +24,7 @@ module SocketTest
   def test_new
     sock = MogileFS::Socket.tcp(@host, @port)
     assert_instance_of MogileFS::Socket, sock, sock.inspect
-    assert_nothing_raised do
-      sock.write_nonblock("a")
-    end
+    sock.write_nonblock("a")
     thr = Thread.new { @srv.accept }
     accepted = thr.value
     assert_instance_of TCPSocket, accepted, accepted.inspect
diff --git a/test/test_backend.rb b/test/test_backend.rb
index 2259201..2078e9b 100644
--- a/test/test_backend.rb
+++ b/test/test_backend.rb
@@ -59,9 +59,6 @@ class TestBackend < Test::Unit::TestCase
     assert_equal MogileFS::Error, @backend.error('PebKacError').superclass
     assert MogileFS::Backend.const_defined?('PebKacError')
 
-    assert_nothing_raised do
-      MogileFS::Backend::OMFGWTFBBQError
-    end
     assert_equal MogileFS::Error, MogileFS::Backend::OMFGWTFBBQError.superclass
     assert_raises(NameError) do
       MogileFS::Backend::FailFailFail
@@ -146,10 +143,7 @@ class TestBackend < Test::Unit::TestCase
         client.write("OK 1 foo=bar\r\n")
         client
       end
-      rv = nil
-      assert_nothing_raised do
-        rv = @backend.do_request('test', { "all" => "ALL" })
-      end
+      rv = @backend.do_request('test', { "all" => "ALL" })
       accepted = thr.value
       assert_equal "test all=ALL\r\n", accepted.readpartial(666)
       assert_equal({"foo"=>"bar"}, rv)
diff --git a/test/test_db_backend.rb b/test/test_db_backend.rb
index d67a400..754d4a8 100644
--- a/test/test_db_backend.rb
+++ b/test/test_db_backend.rb
@@ -66,7 +66,7 @@ class TestMogileFS__DbBackend < Test::Unit::TestCase
   end
 
   def test_sleep
-    assert_nothing_raised { assert_equal({}, @mg.sleep(1)) }
+    assert_equal({}, @mg.sleep(1))
   end
 
 end
diff --git a/test/test_mogilefs.rb b/test/test_mogilefs.rb
index 6000781..dbaddf3 100644
--- a/test/test_mogilefs.rb
+++ b/test/test_mogilefs.rb
@@ -166,9 +166,7 @@ class TestMogileFS__MogileFS < TestMogileFS
 
   def test_delete_existing
     @backend.delete = { }
-    assert_nothing_raised do
-      @client.delete 'no_such_key'
-    end
+    @client.delete 'no_such_key'
   end
 
   def test_delete_nonexisting
@@ -855,9 +853,7 @@ class TestMogileFS__MogileFS < TestMogileFS
 
   def test_sleep
     @backend.sleep = {}
-    assert_nothing_raised do
-      assert_equal({}, @client.sleep(2))
-    end
+    assert_equal({}, @client.sleep(2))
   end
 
   private
diff --git a/test/test_mogilefs_integration.rb b/test/test_mogilefs_integration.rb
index 4882cce..3c79308 100644
--- a/test/test_mogilefs_integration.rb
+++ b/test/test_mogilefs_integration.rb
@@ -47,10 +47,8 @@ class TestMogileFSIntegration < TestMogIntegration
       w.close
     end
     assert_equal data.size, @client.store_file("pipe", nil, r)
-    assert_nothing_raised do
-      r.close
-      th.join
-    end
+    r.close
+    th.join
     assert_equal(data, @client.get_file_data("pipe"))
 
     cbk = MogileFS::Util::StoreContent.new(nil) do |write_callback|
@@ -177,19 +175,19 @@ class TestMogileFSIntegration < TestMogIntegration
 
   def test_new_file_no_block
     rv = @client.new_file("no_block")
-    assert_nothing_raised { rv.write "HELLO" }
+    rv.write "HELLO"
     assert_nil rv.close
     assert_equal "HELLO", @client.get_file_data("no_block")
   end
 
   def test_new_file_known_content_length
     rv = @client.new_file("a", :content_length => 5)
-    assert_nothing_raised { rv.write "HELLO" }
+    rv.write "HELLO"
     assert_nil rv.close
     assert_equal "HELLO", @client.get_file_data("a")
 
     rv = @client.new_file("a", :content_length => 6)
-    assert_nothing_raised { rv.write "GOOD" }
+    rv.write "GOOD"
     assert_raises(MogileFS::SizeMismatchError) { rv.close }
     assert_equal "HELLO", @client.get_file_data("a")
 
@@ -204,19 +202,18 @@ class TestMogileFSIntegration < TestMogIntegration
     r, w = IO.pipe
     b64digest = [ Digest::MD5.digest("HELLO") ].pack('m').strip
     rv = @client.new_file("a", :content_md5 => b64digest, :content_length => 5)
-    assert_nothing_raised { rv.write "HELLO" }
+    rv.write "HELLO"
     assert_nil rv.close
     assert_equal "HELLO", @client.get_file_data("a")
 
-    assert_nothing_raised { w.write "HIHI"; w.close }
+    w.write "HIHI"
+    w.close
     assert_raises(ArgumentError) do
       @client.new_file("a", :content_md5 => b64digest) { |f| f.big_io = r }
     end
     assert_equal "HELLO", @client.get_file_data("a")
 
-    assert_nothing_raised do
-      @client.new_file("a", :content_md5 => :trailer) { |f| f.big_io = r }
-    end
+    @client.new_file("a", :content_md5 => :trailer) { |f| f.big_io = r }
     assert_equal "HIHI", @client.get_file_data("a")
 
     # legacy, in case anybody used it
@@ -241,9 +238,7 @@ class TestMogileFSIntegration < TestMogIntegration
 
   def test_store_content_opts
     b64digest = [ Digest::MD5.digest("HELLO") ].pack('m').strip
-    assert_nothing_raised do
-      @client.store_content("c", nil, "HELLO", :content_md5 => b64digest)
-    end
+    @client.store_content("c", nil, "HELLO", :content_md5 => b64digest)
     assert_raises(MogileFS::SizeMismatchError) do
       @client.store_content("c", nil, "GOODBYE", :content_length => 2)
     end
@@ -253,9 +248,7 @@ class TestMogileFSIntegration < TestMogIntegration
   def test_store_file_opts
     b64digest = [ Digest::MD5.digest("HELLO") ].pack('m').strip
     io = StringIO.new("HELLO")
-    assert_nothing_raised do
-      @client.store_file("c", nil, io, :content_md5 => b64digest)
-    end
+    @client.store_file("c", nil, io, :content_md5 => b64digest)
 
     io = StringIO.new("GOODBYE")
     assert_raises(MogileFS::SizeMismatchError) do
@@ -271,9 +264,7 @@ class TestMogileFSIntegration < TestMogIntegration
       [ Digest::MD5.digest("HELLO") ].pack('m').strip
     end
     io = StringIO.new("HELLO")
-    assert_nothing_raised do
-      @client.store_file("c", nil, io, :content_md5 => expect_md5)
-    end
+    @client.store_file("c", nil, io, :content_md5 => expect_md5)
 
     assert_equal true, checked, "expect_md5 lambda called"
   end
@@ -284,9 +275,7 @@ class TestMogileFSIntegration < TestMogIntegration
     tmp.sync = true
     tmp.write "HIHI"
     tmp.rewind
-    assert_nothing_raised do
-      @client.store_file("unlinked", nil, tmp)
-    end
+    @client.store_file("unlinked", nil, tmp)
 
     assert_equal "HIHI", @client.get_file_data("unlinked")
   end
diff --git a/test/test_mogtool_bigfile.rb b/test/test_mogtool_bigfile.rb
index 05769cd..e424def 100644
--- a/test/test_mogtool_bigfile.rb
+++ b/test/test_mogtool_bigfile.rb
@@ -51,7 +51,7 @@ class TestMogtoolBigfile < TestMogIntegration
 
     # corrupt the existing data in part1
     @client.store_content(part1, nil, "HELLO")
-    assert_nothing_raised { @client.get_uris(part1) }
+    @client.get_uris(part1)
 
     # corruption is detected on verify
     junk = tmpfile("junk")
@@ -61,9 +61,7 @@ class TestMogtoolBigfile < TestMogIntegration
 
     # corruption is NOT detected on verify
     junk = tmpfile("junk")
-    assert_nothing_raised do
-      @client.bigfile_write("_big_info:#@big_uuid", junk, :verify => false)
-    end
+    @client.bigfile_write("_big_info:#@big_uuid", junk, :verify => false)
 
     # restoring no-corrupted data succeeds!
     @client.store_file(part1, nil, tmp.path)
diff --git a/test/test_mysql.rb b/test/test_mysql.rb
index afc845f..d0117f0 100644
--- a/test/test_mysql.rb
+++ b/test/test_mysql.rb
@@ -120,7 +120,7 @@ class TestMogileFS__Mysql < Test::Unit::TestCase
   end
 
   def test_sleep
-    assert_nothing_raised { assert_equal({}, @mg.sleep(:duration => 1)) }
+    assert_equal({}, @mg.sleep(:duration => 1))
   end
 
 end