aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorodaira <odaira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-07 23:22:49 +0000
committerodaira <odaira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-07 23:22:49 +0000
commit2e10eb8f666e0b2611f6267cab474ca2a12f3add (patch)
tree565d028d4b78428e7f2ab9fed3a03e2b773094b7
parenteea1895cf20621300ae48f04b61c656f0f1c45ef (diff)
downloadruby-2e10eb8f666e0b2611f6267cab474ca2a12f3add.tar.gz
* test/net/imap/test_imap.rb (test_idle_timeout): Because of the
timeout specified in "imap.idle(0.2)", there is no gurantee that the server thread has done all the work before the client thread performs the assertions. It depends on the thread scheduling. Add checks to avoid false positives (on AIX, particularly). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--test/net/imap/test_imap.rb32
2 files changed, 30 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index cc8c2dbd55..a1ce83ada2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Mar 8 08:13:01 2016 Rei Odaira <Rei.Odaira@gmail.com>
+
+ * test/net/imap/test_imap.rb (test_idle_timeout): Because of the
+ timeout specified in "imap.idle(0.2)", there is no gurantee that
+ the server thread has done all the work before the client thread
+ performs the assertions. It depends on the thread scheduling.
+ Add checks to avoid false positives (on AIX, particularly).
+
Tue Mar 8 00:42:22 2016 NAKAMURA Usaku <usa@ruby-lang.org>
* ruby.c (warn_cr_in_shebang): meaningless check on DOSISH platforms.
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb
index 3476b66c79..cdd9323c10 100644
--- a/test/net/imap/test_imap.rb
+++ b/test/net/imap/test_imap.rb
@@ -310,19 +310,31 @@ class IMAPTest < Test::Unit::TestCase
begin
imap = Net::IMAP.new(SERVER_ADDR, :port => port)
responses = []
- Thread.pass
+ Thread.pass
imap.idle(0.2) do |res|
responses.push(res)
end
- assert_equal(3, responses.length)
- assert_instance_of(Net::IMAP::ContinuationRequest, responses[0])
- assert_equal("EXISTS", responses[1].name)
- assert_equal(3, responses[1].data)
- assert_equal("EXPUNGE", responses[2].name)
- assert_equal(2, responses[2].data)
- assert_equal(2, requests.length)
- assert_equal("RUBY0001 IDLE\r\n", requests[0])
- assert_equal("DONE\r\n", requests[1])
+ # There is no gurantee that this thread has received all the responses,
+ # so check the response length.
+ if responses.length > 0
+ assert_instance_of(Net::IMAP::ContinuationRequest, responses[0])
+ if responses.length > 1
+ assert_equal("EXISTS", responses[1].name)
+ assert_equal(3, responses[1].data)
+ if responses.length > 2
+ assert_equal("EXPUNGE", responses[2].name)
+ assert_equal(2, responses[2].data)
+ end
+ end
+ end
+ # Also, there is no gurantee that the server thread has stored
+ # all the requests into the array, so check the length.
+ if requests.length > 0
+ assert_equal("RUBY0001 IDLE\r\n", requests[0])
+ if requests.length > 1
+ assert_equal("DONE\r\n", requests[1])
+ end
+ end
imap.logout
ensure
imap.disconnect if imap