Skip to content

Commit e7a4fb9

Browse files
committed
[GR-16877] Fix specs to never use an arbitrary timeout for joining threads.
PullRequest: truffleruby/926
2 parents 78eb6cc + c7954ab commit e7a4fb9

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

spec/ruby/core/thread/value_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,14 @@
1818
t = Thread.new { Thread.current.exit }
1919
t.value.should == nil
2020
end
21+
22+
it "returns when the thread finished" do
23+
q = Queue.new
24+
t = Thread.new {
25+
q.pop
26+
}
27+
-> { t.value }.should block_caller
28+
q.push :result
29+
t.value.should == :result
30+
end
2131
end

spec/ruby/library/socket/socket/accept_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656

5757
client.connect(@server_addr)
5858

59-
thread.join(5)
6059
value = thread.value
6160
begin
6261
value.should be_an_instance_of(Array)

spec/ruby/library/socket/socket/sysaccept_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959

6060
@client.connect(@server_addr)
6161

62-
thread.join(5)
63-
6462
thread.value.should be_an_instance_of(Array)
6563
end
6664
end

spec/ruby/library/socket/socket/tcp_server_loop_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# At this point the connection has been set up but the thread may not yet
4646
# have returned, thus we'll need to wait a little longer for it to
4747
# complete.
48-
thread.join(2)
48+
thread.join
4949

5050
@sock.should be_an_instance_of(Socket)
5151
addr.should be_an_instance_of(Addrinfo)

spec/ruby/library/socket/socket/unix_server_loop_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
end
4949
end
5050

51-
thread.join(2)
51+
thread.join
5252

5353
@sock.should be_an_instance_of(Socket)
5454
addr.should be_an_instance_of(Addrinfo)

spec/ruby/optional/capi/thread_spec.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,7 @@ def call_capi_rb_thread_wakeup
117117
# Wake it up, causing the unblock function to be run.
118118
thr.wakeup
119119

120-
# Make sure it stopped
121-
thr.join(1).should_not be_nil
122-
123-
# And we got a proper value
120+
# Make sure it stopped and we got a proper value
124121
thr.value.should be_true
125122
end
126123

@@ -139,10 +136,7 @@ def call_capi_rb_thread_wakeup
139136
# Wake it up, causing the unblock function to be run.
140137
thr.wakeup
141138

142-
# Make sure it stopped
143-
thr.join(1).should_not be_nil
144-
145-
# And we got a proper value
139+
# Make sure it stopped and we got a proper value
146140
thr.value.should be_true
147141
end
148142
end

0 commit comments

Comments
 (0)