Skip to content

Commit

Permalink
WIP: more shorten
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1 committed Oct 11, 2023
1 parent a4f79ca commit 0c35896
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ test-sample: test-basic # backward compatibility for mswin-build
test-short: btest-ruby $(DOT_WAIT) test-knownbug $(DOT_WAIT) test-basic
test: test-short

yes-test-all-precheck: programs encs exts PHONY $(DOT_WAIT)
yes-test-all-precheck: programs PHONY $(DOT_WAIT)

# $ make test-all TESTOPTS="--help" displays more detail
# for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name"
Expand Down
39 changes: 4 additions & 35 deletions test/ruby/test_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ def self.new(*)
end

def setup
STDERR.puts "\n\n!!! setup #{self.instance_variable_get(:@__name__)}"

Thread::Threads.clear
end

def teardown
STDERR.puts "\n\n!!! teardown #{self.instance_variable_get(:@__name__)}"

Thread::Threads.each do |t|
t.kill if t.alive?
begin
Expand Down Expand Up @@ -84,41 +88,6 @@ def obj.hash
assert(obj[:visited], "obj.hash was not called")
end

def test_handle_interrupt_invalid_argument
assert_raise(ArgumentError) {
Thread.handle_interrupt(RuntimeError => :immediate) # no block
}
assert_raise(ArgumentError) {
Thread.handle_interrupt(RuntimeError => :xyzzy) {}
}
assert_raise(TypeError) {
Thread.handle_interrupt([]) {} # array
}
end

def test_handle_interrupt_blocking
r = nil
q = Thread::Queue.new
e = Class.new(Exception)
th_s = Thread.current
th = Thread.start {
assert_raise(RuntimeError) {
Thread.handle_interrupt(Object => :on_blocking){
begin
q.pop
Thread.current.raise RuntimeError, "will raise in sleep"
r = :ok
sleep
ensure
th_s.raise e, "raise from ensure", $@
end
}
}
}
assert_raise(e) {q << true; th.join}
assert_equal(:ok, r)
end

def invoke_rec script, vm_stack_size, machine_stack_size, use_length = true
env = {}
env['RUBY_THREAD_VM_STACK_SIZE'] = vm_stack_size.to_s if vm_stack_size
Expand Down

0 comments on commit 0c35896

Please sign in to comment.