[#3228] Core support for Gems, and namespace — "Luke A. Kanies" <luke@...>

Hi all,

21 messages 2004/07/27
[#3230] Re: Core support for Gems, and namespace — Austin Ziegler <halostatue@...> 2004/07/27

On Tue, 27 Jul 2004 11:39:08 +0900, Luke A. Kanies <luke@madstop.com> wrote:

[#3234] Re: Core support for Gems, and namespace — "Luke A. Kanies" <luke@...> 2004/07/27

On Tue, 27 Jul 2004, Austin Ziegler wrote:

[#3238] Re: Core support for Gems, and namespace — Austin Ziegler <halostatue@...> 2004/07/27

On Wed, 28 Jul 2004 00:14:29 +0900, Luke A. Kanies <luke@madstop.com> wrote:

assert_timeout for Test::Unit::Assertions

From: "Kirill A. Shutemov" <kirya85@...>
Date: 2004-07-03 09:20:28 UTC
List: ruby-core #3116
I write subj. Patch in attachment.

-- 
Kirill A. Shutemov
E-mail: kirya85@mail.ru
JID: kas@altlinux.org
ICQ: 152302675

Attachments (1)

timeout.diff (553 Bytes, text/x-diff)
--- assertions.rb.orig	2004-06-03 13:38:24 +0300
+++ assertions.rb	2004-06-03 13:40:12 +0300
@@ -340,6 +340,18 @@
         end
       end
 
+      def assert_timeout(timeout, message='Timeout exceeded!',&block)
+	time = Time.now.to_f
+	thread = Thread.new{block.call};
+
+	while Time.now.to_f - time < timeout
+	  break unless thread.alive?
+	  sleep 0.01
+	end
+								
+	assert_block(message){ not thread.alive? }	    
+      end
+
       public
       def build_message(head, template=nil, *arguments) # :nodoc:
         template &&= template.chomp

In This Thread

Prev Next