test/rake_test_setup.rb in drake-0.8.4.1.1.0 vs test/rake_test_setup.rb in drake-0.8.4.1.2.0
- old
+ new
@@ -5,10 +5,11 @@
gem 'flexmock'
rescue LoadError
# got no gems
end
+require 'thread'
require 'flexmock/test_unit'
if RUBY_VERSION >= "1.9.0"
class Test::Unit::TestCase
# def passed?
@@ -18,7 +19,27 @@
end
module TestMethods
def assert_exception(ex, msg=nil, &block)
assert_raise(ex, msg, &block)
+ end
+end
+
+class SerializedArray
+ def initialize
+ @mutex = Mutex.new
+ @array = Array.new
+ end
+
+ Array.public_instance_methods.each do |method_name|
+ unless method_name =~ %r!\A__! or method_name =~ %r!\A(object_)?id\Z!
+ # TODO: jettison 1.8.6; use define_method with |&block|
+ eval %{
+ def #{method_name}(*args, &block)
+ @mutex.synchronize {
+ @array.send('#{method_name}', *args, &block)
+ }
+ end
+ }
+ end
end
end