Skip to content

Commit

Permalink
Fix: TypeError: can't convert ImageOptim::Timer into Float
Browse files Browse the repository at this point in the history
  • Loading branch information
yahonda committed Oct 2, 2021
1 parent 03fa8a7 commit a2fddbd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit a2fddbd

Please sign in to comment.