diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-06-11 11:13:26 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-06-11 23:15:46 +0900 |
commit | c4cbaef216ffcc9bda70cc328a805ad679ccaa8c (patch) | |
tree | c9070910a461abca183c4d0fceea7cc922e149d2 /test/ruby/test_io.rb | |
parent | 42f0a8fd6f7e1f4afcb17aeb34e9f8ddf8d66b9b (diff) | |
download | ruby-c4cbaef216ffcc9bda70cc328a805ad679ccaa8c.tar.gz |
assert_cpu_usage_low with timeout scale
* test/lib/test/unit/assertions.rb (assert_cpu_usage_low): apply
the timeout scale to measuring period. this assertion is very
runtime environment dependent.
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 7f407647ec..4f66685f9b 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -567,11 +567,8 @@ class TestIO < Test::Unit::TestCase msg = 'r58534 [ruby-core:80969] [Backport #13533]' IO.pipe do |r,w| r.nonblock = true - assert_cpu_usage_low(msg) do - th = Thread.new { IO.copy_stream(r, IO::NULL) } - sleep 0.1 - w.close - th.join + assert_cpu_usage_low(msg, stop: ->{w.close}) do + IO.copy_stream(r, IO::NULL) end end end |