Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: TypeError: can't convert ImageOptim::Timer into Float #194

Merged
merged 2 commits into from Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.markdown
Expand Up @@ -3,6 +3,7 @@
## unreleased

* Add support for Oxipng [#167](https://github.com/toy/image_optim/issues/167) [#190](https://github.com/toy/image_optim/pull/190) [@oblakeerickson](https://github.com/oblakeerickson)
* Fix `TypeError: can't convert ImageOptim::Timer into Float` with Ruby 3 [#194](https://github.com/toy/image_optim/pull/194) [@yahonda](https://github.com/yahonda)

## v0.30.0 (2021-05-11)

Expand Down
2 changes: 1 addition & 1 deletion lib/image_optim/cmd.rb
Expand Up @@ -17,7 +17,7 @@ def run(*args)
pid = Process.spawn(*args)

waiter = Process.detach(pid)
if waiter.join(timeout)
if waiter.join(timeout.to_f)
status = waiter.value

check_status!(status)
Expand Down
6 changes: 6 additions & 0 deletions spec/image_optim/cmd_spec.rb
Expand Up @@ -2,6 +2,7 @@

require 'spec_helper'
require 'image_optim/cmd'
require 'image_optim/timer'

describe ImageOptim::Cmd do
before do
Expand Down Expand Up @@ -48,6 +49,11 @@ def expect_int_exception(&block)
expect(Cmd.run('sh -c "exit 66"', timeout: 1)).to eq(false)
end

it 'returns process success status when timeout is instance of ImageOptim::Timer' do
timeout = ImageOptim::Timer.new(1.0)
expect(Cmd.run('sh -c "exit 0"', timeout: timeout)).to eq(true)
end

it 'raises SignalException if process terminates after signal', skip: SkipConditions[:signals_support] do
expect_int_exception do
Cmd.run('kill -s INT $$', timeout: 1)
Expand Down