diff --git a/more_core_extensions.gemspec b/more_core_extensions.gemspec index 22c1212..b60523f 100644 --- a/more_core_extensions.gemspec +++ b/more_core_extensions.gemspec @@ -27,7 +27,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake" spec.add_development_dependency "rspec", ">= 3.0" spec.add_development_dependency "simplecov" - spec.add_development_dependency "sys-proctable", "~> 1.2.2" spec.add_development_dependency "timecop" spec.add_runtime_dependency "activesupport" diff --git a/spec/core_ext/process/pause_resume_spec.rb b/spec/core_ext/process/pause_resume_spec.rb index 47265c4..1cc4f29 100644 --- a/spec/core_ext/process/pause_resume_spec.rb +++ b/spec/core_ext/process/pause_resume_spec.rb @@ -1,15 +1,6 @@ -require 'sys-proctable' - RSpec.describe Process do - let(:linux) { Gem::Platform.local.os == 'linux' } - def get_process_status(pid) - process = Sys::ProcTable.ps(:pid => pid, :smaps => false, :cgroup => false) - linux ? process.state : process.status - end - - def paused_status - linux ? 'T' : 4 + `ps -p #{pid} -o stat=`[0] end context ".alive?" do @@ -28,16 +19,15 @@ def paused_status end it "can pause a running process" do - expect(get_process_status(@pid)).not_to eql(paused_status) + expect(get_process_status(@pid)).not_to eq('T') expect(Process.pause(@pid)).to eql(1) - sleep 0.5 # Give the kernel a chance to update the status - expect(get_process_status(@pid)).to eql(paused_status) + expect(get_process_status(@pid)).to eq('T') end it "is a no-op if the process is already paused" do - expect(Process.pause(@pid)).to eql(1) + expect(Process.pause(@pid)).to eq(1) expect { Process.pause(@pid) }.not_to raise_error - expect(Process.pause(@pid)).to eql(1) + expect(Process.pause(@pid)).to eq(1) end it "returns nil if the process is not running" do @@ -56,16 +46,15 @@ def paused_status end it "can resume a paused process" do - expect(get_process_status(@pid)).to eql(paused_status) + expect(get_process_status(@pid)).to eq('T') Process.resume(@pid) - sleep 0.5 # Give the kernel a chance to update the status - expect(get_process_status(@pid)).not_to eql(paused_status) + expect(get_process_status(@pid)).not_to eq('T') end it "is a no-op if the process is already running" do - expect(Process.resume(@pid)).to eql(1) + expect(Process.resume(@pid)).to eq(1) expect { Process.resume(@pid) }.not_to raise_error - expect(Process.resume(@pid)).to eql(1) + expect(Process.resume(@pid)).to eq(1) end it "returns nil if the process is not running" do