Skip to content

Commit

Permalink
Re-green due to java thread work (with a pend to be worked out)
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Jan 5, 2023
1 parent 2cff7be commit be88ae1
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions test/jruby/test_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,40 +365,36 @@ def test_inspect_and_to_s
end

def test_thread_name
pend 'java.lang.Thread.native_thread is not implemented'
Thread.new do
assert_match(/\#\<Thread\:0x\h+( ([A-Z]:)?[\w\/\.\-_]+\:\d+)?\srun\>/, Thread.current.inspect)
# Thread.current on Windows: "#<Thread:0x11aa8f4@D:/a/jruby/jruby/test/jruby/test_thread.rb:371 run>"
# TODO? currently in JIT file comes as "" and line as 0
assert_match(/Ruby\-\d+\-Thread\-\d+\:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current))
end.join

Thread.new do
Thread.current.name = 'foo'
assert_match(/\#\<Thread\:0x\h+@foo( ([A-Z]:)?[\w\/\.\-_]+\:\d+)?\srun\>/, Thread.current.inspect)
assert_match(/Ruby\-\d+\-Thread\-\d+\@foo:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current))

Thread.current.name = 'bar'
assert_match(/\#\<Thread\:0x\h+@bar( ([A-Z]:)?[\w\/\.\-_]+\:\d+)?\srun\>/, Thread.current.inspect)
assert_match(/Ruby\-\d+\-Thread\-\d+\@bar:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current))

Thread.current.name = nil
assert_match(/\#\<Thread\:0x\h+( ([A-Z]:)?[\w\/\.\-_]+\:\d+)?\srun\>/, Thread.current.inspect)
assert_match(/Ruby\-\d+\-Thread\-\d+\:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current))
end.join


Thread.new do
Thread.current.to_java.native_thread.name = 'user-set-native-thread-name'
my_name = 'user-set-native-thread-name'
Thread.current.to_java.native_thread.name = my_name
Thread.current.name = 'foo'

assert Thread.current.inspect.index('@foo')
assert_equal 'user-set-native-thread-name', native_thread_name(Thread.current) if defined? JRUBY_VERSION
assert_equal my_name, Thread.current.to_java.native_thread.name

Thread.current.name = nil
assert ! Thread.current.inspect.index('@foo')
assert_equal 'user-set-native-thread-name', native_thread_name(Thread.current) if defined? JRUBY_VERSION
assert_equal my_name, Thread.current.to_java.native_thread.name
end.join
end if defined? JRUBY_VERSION
end

def test_status_after_raise
(ENV['STATUS_TIMES'] || ENV['TIMES'] || 1000).to_i.times do
Expand Down Expand Up @@ -455,10 +451,4 @@ def test_count_down_latch
end
end

private

def native_thread_name(thread)
thread.to_java.native_thread.name
end

end

0 comments on commit be88ae1

Please sign in to comment.