reimplement tests and minor fixes.

This commit is contained in:
Denis Knauf 2021-12-12 18:19:34 +01:00
parent 3542837d7f
commit 5b390b2083
3 changed files with 11 additions and 5 deletions

View file

@ -1,2 +1,9 @@
require "bundler/gem_tasks" require "bundler/gem_tasks"
task :default => :spec task :default => :spec
require 'rake/testtask'
Rake::TestTask.new :test do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end

View file

@ -1,5 +1,6 @@
require 'rubygems' require 'rubygems'
require 'bundler' require 'bundler'
begin begin
Bundler.setup(:default, :development) Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e rescue Bundler::BundlerError => e
@ -7,6 +8,7 @@ rescue Bundler::BundlerError => e
$stderr.puts "Run `bundle install` to install missing gems" $stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code exit e.status_code
end end
require 'test/unit' require 'test/unit'
require 'shoulda' require 'shoulda'
@ -14,9 +16,6 @@ require 'timeout'
require 'benchmark' require 'benchmark'
require 'ffi/libc' require 'ffi/libc'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'timeout_interrupt' require 'timeout_interrupt'
class Test::Unit::TestCase class Test::Unit::TestCase

View file

@ -4,7 +4,7 @@ class TestRubyTimeoutInterrupt < Test::Unit::TestCase
def blocking def blocking
t = FFI::LibC.fopen '/dev/ptmx', 'r' t = FFI::LibC.fopen '/dev/ptmx', 'r'
b = FFI::LibC.malloc 1025 b = FFI::LibC.malloc 1025
s = FFI::LibC.fread b, 1, 1024, t FFI::LibC.fread b, 1, 1024, t
ensure ensure
FFI::LibC.fclose t if t FFI::LibC.fclose t if t
FFI::LibC.free b if b FFI::LibC.free b if b
@ -114,7 +114,7 @@ class TestRubyTimeoutInterrupt < Test::Unit::TestCase
called = false called = false
prepared.call do prepared.call do
assert_raise TimeoutInterrupt::Error, 'It should time out after one second, but it did not.' do assert_raise TimeoutInterrupt::Error, 'It should time out after one second, but it did not.' do
prepared.call { 2; sleep 2 } prepared.call { _ = 2; sleep 2 }
end end
called = true called = true
end end