diff options
Diffstat (limited to 'spec/ruby/core/process')
40 files changed, 360 insertions, 260 deletions
diff --git a/spec/ruby/core/process/_fork_spec.rb b/spec/ruby/core/process/_fork_spec.rb index 6f711ad2dd..620f243ce5 100644 --- a/spec/ruby/core/process/_fork_spec.rb +++ b/spec/ruby/core/process/_fork_spec.rb @@ -1,24 +1,24 @@ require_relative '../../spec_helper' -ruby_version_is "3.1" do - describe "Process._fork" do - it "for #respond_to? returns the same as Process.respond_to?(:fork)" do - Process.respond_to?(:_fork).should == Process.respond_to?(:fork) - end +describe "Process._fork" do + it "for #respond_to? returns the same as Process.respond_to?(:fork)" do + Process.respond_to?(:_fork).should == Process.respond_to?(:fork) + end - guard_not -> { Process.respond_to?(:fork) } do - it "raises a NotImplementedError when called" do - -> { Process._fork }.should raise_error(NotImplementedError) - end + # Using respond_to? in a guard here is OK because the correct semantics + # are that _fork is implemented if and only if fork is (see above). + guard_not -> { Process.respond_to?(:fork) } do + it "raises a NotImplementedError when called" do + -> { Process._fork }.should.raise(NotImplementedError) end + end - guard -> { Process.respond_to?(:fork) } do - it "is called by Process#fork" do - Process.should_receive(:_fork).once.and_return(42) + guard -> { Process.respond_to?(:fork) } do + it "is called by Process#fork" do + Process.should_receive(:_fork).once.and_return(42) - pid = Process.fork {} - pid.should equal(42) - end + pid = Process.fork {} + pid.should.equal?(42) end end end diff --git a/spec/ruby/core/process/argv0_spec.rb b/spec/ruby/core/process/argv0_spec.rb index f5aba719e9..4c7a2c9ecb 100644 --- a/spec/ruby/core/process/argv0_spec.rb +++ b/spec/ruby/core/process/argv0_spec.rb @@ -2,7 +2,7 @@ require_relative '../../spec_helper' describe "Process.argv0" do it "returns a String" do - Process.argv0.should be_kind_of(String) + Process.argv0.should.is_a?(String) end it "is the path given as the main script and the same as __FILE__" do @@ -13,10 +13,8 @@ describe "Process.argv0" do end end - ruby_bug "#19597", ""..."3.3" do - it "returns a frozen object" do - Process.argv0.should.frozen? - end + it "returns a frozen object" do + Process.argv0.should.frozen? end it "returns every time the same object" do diff --git a/spec/ruby/core/process/clock_gettime_spec.rb b/spec/ruby/core/process/clock_gettime_spec.rb index 6c1a52f21e..88158904e1 100644 --- a/spec/ruby/core/process/clock_gettime_spec.rb +++ b/spec/ruby/core/process/clock_gettime_spec.rb @@ -4,31 +4,31 @@ require_relative 'fixtures/clocks' describe "Process.clock_gettime" do ProcessSpecs.clock_constants.each do |name, value| it "can be called with Process::#{name}" do - Process.clock_gettime(value).should be_an_instance_of(Float) + Process.clock_gettime(value).should.instance_of?(Float) end end describe 'time units' do it 'handles a fixed set of time units' do [:nanosecond, :microsecond, :millisecond, :second].each do |unit| - Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should be_kind_of(Integer) + Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should.is_a?(Integer) end [:float_microsecond, :float_millisecond, :float_second].each do |unit| - Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should.instance_of?(Float) end end it 'raises an ArgumentError for an invalid time unit' do - -> { Process.clock_gettime(Process::CLOCK_MONOTONIC, :bad) }.should raise_error(ArgumentError) + -> { Process.clock_gettime(Process::CLOCK_MONOTONIC, :bad) }.should.raise(ArgumentError) end it 'defaults to :float_second' do t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC) t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second) - t1.should be_an_instance_of(Float) - t2.should be_an_instance_of(Float) + t1.should.instance_of?(Float) + t2.should.instance_of?(Float) t2.should be_close(t1, TIME_TOLERANCE) end @@ -36,116 +36,116 @@ describe "Process.clock_gettime" do t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC, nil) t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second) - t1.should be_an_instance_of(Float) - t2.should be_an_instance_of(Float) + t1.should.instance_of?(Float) + t2.should.instance_of?(Float) t2.should be_close(t1, TIME_TOLERANCE) end end describe "supports the platform clocks mentioned in the documentation" do it "CLOCK_REALTIME" do - Process.clock_gettime(Process::CLOCK_REALTIME).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_REALTIME).should.instance_of?(Float) end it "CLOCK_MONOTONIC" do - Process.clock_gettime(Process::CLOCK_MONOTONIC).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC).should.instance_of?(Float) end # These specs need macOS 10.12+ / darwin 16+ guard -> { platform_is_not(:darwin) or kernel_version_is '16' } do platform_is :linux, :openbsd, :darwin do it "CLOCK_PROCESS_CPUTIME_ID" do - Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID).should.instance_of?(Float) end end platform_is :linux, :freebsd, :openbsd, :darwin do it "CLOCK_THREAD_CPUTIME_ID" do - Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID).should.instance_of?(Float) end end platform_is :linux, :darwin do it "CLOCK_MONOTONIC_RAW" do - Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW).should.instance_of?(Float) end end platform_is :darwin do it "CLOCK_MONOTONIC_RAW_APPROX" do - Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW_APPROX).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW_APPROX).should.instance_of?(Float) end it "CLOCK_UPTIME_RAW and CLOCK_UPTIME_RAW_APPROX" do - Process.clock_gettime(Process::CLOCK_UPTIME_RAW).should be_an_instance_of(Float) - Process.clock_gettime(Process::CLOCK_UPTIME_RAW_APPROX).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_UPTIME_RAW).should.instance_of?(Float) + Process.clock_gettime(Process::CLOCK_UPTIME_RAW_APPROX).should.instance_of?(Float) end end end platform_is :freebsd do it "CLOCK_VIRTUAL" do - Process.clock_gettime(Process::CLOCK_VIRTUAL).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_VIRTUAL).should.instance_of?(Float) end it "CLOCK_PROF" do - Process.clock_gettime(Process::CLOCK_PROF).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_PROF).should.instance_of?(Float) end end platform_is :freebsd, :openbsd do it "CLOCK_UPTIME" do - Process.clock_gettime(Process::CLOCK_UPTIME).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_UPTIME).should.instance_of?(Float) end end platform_is :freebsd do it "CLOCK_REALTIME_FAST and CLOCK_REALTIME_PRECISE" do - Process.clock_gettime(Process::CLOCK_REALTIME_FAST).should be_an_instance_of(Float) - Process.clock_gettime(Process::CLOCK_REALTIME_PRECISE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_REALTIME_FAST).should.instance_of?(Float) + Process.clock_gettime(Process::CLOCK_REALTIME_PRECISE).should.instance_of?(Float) end it "CLOCK_MONOTONIC_FAST and CLOCK_MONOTONIC_PRECISE" do - Process.clock_gettime(Process::CLOCK_MONOTONIC_FAST).should be_an_instance_of(Float) - Process.clock_gettime(Process::CLOCK_MONOTONIC_PRECISE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_FAST).should.instance_of?(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_PRECISE).should.instance_of?(Float) end it "CLOCK_UPTIME_FAST and CLOCK_UPTIME_PRECISE" do - Process.clock_gettime(Process::CLOCK_UPTIME_FAST).should be_an_instance_of(Float) - Process.clock_gettime(Process::CLOCK_UPTIME_PRECISE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_UPTIME_FAST).should.instance_of?(Float) + Process.clock_gettime(Process::CLOCK_UPTIME_PRECISE).should.instance_of?(Float) end it "CLOCK_SECOND" do - Process.clock_gettime(Process::CLOCK_SECOND).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_SECOND).should.instance_of?(Float) end end guard -> { platform_is :linux and kernel_version_is '2.6.32' } do it "CLOCK_REALTIME_COARSE" do - Process.clock_gettime(Process::CLOCK_REALTIME_COARSE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_REALTIME_COARSE).should.instance_of?(Float) end it "CLOCK_MONOTONIC_COARSE" do - Process.clock_gettime(Process::CLOCK_MONOTONIC_COARSE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_COARSE).should.instance_of?(Float) end end guard -> { platform_is :linux and kernel_version_is '2.6.39' } do it "CLOCK_BOOTTIME" do skip "No Process::CLOCK_BOOTTIME" unless defined?(Process::CLOCK_BOOTTIME) - Process.clock_gettime(Process::CLOCK_BOOTTIME).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_BOOTTIME).should.instance_of?(Float) end end guard -> { platform_is "x86_64-linux" and kernel_version_is '3.0' } do it "CLOCK_REALTIME_ALARM" do skip "No Process::CLOCK_REALTIME_ALARM" unless defined?(Process::CLOCK_REALTIME_ALARM) - Process.clock_gettime(Process::CLOCK_REALTIME_ALARM).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_REALTIME_ALARM).should.instance_of?(Float) end it "CLOCK_BOOTTIME_ALARM" do skip "No Process::CLOCK_BOOTTIME_ALARM" unless defined?(Process::CLOCK_BOOTTIME_ALARM) - Process.clock_gettime(Process::CLOCK_BOOTTIME_ALARM).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_BOOTTIME_ALARM).should.instance_of?(Float) end end end diff --git a/spec/ruby/core/process/constants_spec.rb b/spec/ruby/core/process/constants_spec.rb index 57cacadef2..62e8f2ee4a 100644 --- a/spec/ruby/core/process/constants_spec.rb +++ b/spec/ruby/core/process/constants_spec.rb @@ -20,8 +20,8 @@ describe "Process::Constants" do RLIMIT_NPROC RLIMIT_NOFILE ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -33,8 +33,8 @@ describe "Process::Constants" do RLIM_SAVED_CUR RLIMIT_AS ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -61,8 +61,8 @@ describe "Process::Constants" do RLIM_SAVED_MAX RLIM_SAVED_CUR ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -73,8 +73,8 @@ describe "Process::Constants" do RLIMIT_SBSIZE RLIMIT_AS ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -84,8 +84,8 @@ describe "Process::Constants" do %i[ RLIMIT_NPTS ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -107,7 +107,7 @@ describe "Process::Constants" do RLIM_SAVED_MAX RLIM_SAVED_CUR ].each do |const| - Process.const_defined?(const).should be_false + Process.const_defined?(const).should == false end end end diff --git a/spec/ruby/core/process/daemon_spec.rb b/spec/ruby/core/process/daemon_spec.rb index 20b0d743b9..9b7eba1411 100644 --- a/spec/ruby/core/process/daemon_spec.rb +++ b/spec/ruby/core/process/daemon_spec.rb @@ -112,7 +112,7 @@ platform_is :windows do it "raises a NotImplementedError" do -> { Process.daemon - }.should raise_error(NotImplementedError) + }.should.raise(NotImplementedError) end end end diff --git a/spec/ruby/core/process/detach_spec.rb b/spec/ruby/core/process/detach_spec.rb index f13bda1f5d..33c674394e 100644 --- a/spec/ruby/core/process/detach_spec.rb +++ b/spec/ruby/core/process/detach_spec.rb @@ -5,7 +5,7 @@ describe "Process.detach" do it "returns a thread" do pid = Process.fork { Process.exit! } thr = Process.detach(pid) - thr.should be_kind_of(Thread) + thr.should.is_a?(Thread) thr.join end @@ -15,7 +15,7 @@ describe "Process.detach" do thr.join status = thr.value - status.should be_kind_of(Process::Status) + status.should.is_a?(Process::Status) status.pid.should == pid end @@ -23,7 +23,7 @@ describe "Process.detach" do it "reaps the child process's status automatically" do pid = Process.fork { Process.exit! } Process.detach(pid).join - -> { Process.waitpid(pid) }.should raise_error(Errno::ECHILD) + -> { Process.waitpid(pid) }.should.raise(Errno::ECHILD) end end @@ -52,12 +52,12 @@ describe "Process.detach" do # Command `kill 0 pid`: # - returns "1" if a process exists and # - raises Errno::ESRCH otherwise - -> { Process.kill(0, pid_not_existing) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid_not_existing) }.should.raise(Errno::ESRCH) thr = Process.detach(pid_not_existing) thr.join - thr.should be_kind_of(Thread) + thr.should.is_a?(Thread) end it "calls #to_int to implicitly convert non-Integer pid to Integer" do @@ -68,14 +68,14 @@ describe "Process.detach" do end it "raises TypeError when pid argument does not have #to_int method" do - -> { Process.detach(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into Integer") + -> { Process.detach(Object.new) }.should.raise(TypeError, "no implicit conversion of Object into Integer") end it "raises TypeError when #to_int returns non-Integer value" do pid = MockObject.new('mock-enumerable') pid.should_receive(:to_int).and_return(:symbol) - -> { Process.detach(pid) }.should raise_error(TypeError, "can't convert MockObject to Integer (MockObject#to_int gives Symbol)") + -> { Process.detach(pid) }.should raise_consistent_error(TypeError, "can't convert MockObject into Integer (MockObject#to_int gives Symbol)") end end end diff --git a/spec/ruby/core/process/egid_spec.rb b/spec/ruby/core/process/egid_spec.rb index a67b623d5c..69c86bebe2 100644 --- a/spec/ruby/core/process/egid_spec.rb +++ b/spec/ruby/core/process/egid_spec.rb @@ -2,7 +2,7 @@ require_relative '../../spec_helper' describe "Process.egid" do it "returns the effective group ID for this process" do - Process.egid.should be_kind_of(Integer) + Process.egid.should.is_a?(Integer) end it "also goes by Process::GID.eid" do @@ -18,7 +18,7 @@ describe "Process.egid=" do platform_is_not :windows do it "raises TypeError if not passed an Integer or String" do - -> { Process.egid = Object.new }.should raise_error(TypeError) + -> { Process.egid = Object.new }.should.raise(TypeError) end it "sets the effective group id to its own gid if given the username corresponding to its own gid" do @@ -33,12 +33,12 @@ describe "Process.egid=" do as_user do it "raises Errno::ERPERM if run by a non superuser trying to set the root group id" do - -> { Process.egid = 0 }.should raise_error(Errno::EPERM) + -> { Process.egid = 0 }.should.raise(Errno::EPERM) end platform_is :linux do it "raises Errno::ERPERM if run by a non superuser trying to set the group id from group name" do - -> { Process.egid = "root" }.should raise_error(Errno::EPERM) + -> { Process.egid = "root" }.should.raise(Errno::EPERM) end end end diff --git a/spec/ruby/core/process/euid_spec.rb b/spec/ruby/core/process/euid_spec.rb index c1ec4171d0..da76f06e59 100644 --- a/spec/ruby/core/process/euid_spec.rb +++ b/spec/ruby/core/process/euid_spec.rb @@ -2,7 +2,7 @@ require_relative '../../spec_helper' describe "Process.euid" do it "returns the effective user ID for this process" do - Process.euid.should be_kind_of(Integer) + Process.euid.should.is_a?(Integer) end it "also goes by Process::UID.eid" do @@ -18,7 +18,7 @@ describe "Process.euid=" do platform_is_not :windows do it "raises TypeError if not passed an Integer" do - -> { Process.euid = Object.new }.should raise_error(TypeError) + -> { Process.euid = Object.new }.should.raise(TypeError) end it "sets the effective user id to its own uid if given the username corresponding to its own uid" do @@ -33,11 +33,11 @@ describe "Process.euid=" do as_user do it "raises Errno::ERPERM if run by a non superuser trying to set the superuser id" do - -> { Process.euid = 0 }.should raise_error(Errno::EPERM) + -> { Process.euid = 0 }.should.raise(Errno::EPERM) end it "raises Errno::ERPERM if run by a non superuser trying to set the superuser id from username" do - -> { Process.euid = "root" }.should raise_error(Errno::EPERM) + -> { Process.euid = "root" }.should.raise(Errno::EPERM) end end diff --git a/spec/ruby/core/process/exec_spec.rb b/spec/ruby/core/process/exec_spec.rb index 0f371b39c8..a48d461b02 100644 --- a/spec/ruby/core/process/exec_spec.rb +++ b/spec/ruby/core/process/exec_spec.rb @@ -2,35 +2,35 @@ require_relative '../../spec_helper' describe "Process.exec" do it "raises Errno::ENOENT for an empty string" do - -> { Process.exec "" }.should raise_error(Errno::ENOENT) + -> { Process.exec "" }.should.raise(Errno::ENOENT) end it "raises Errno::ENOENT for a command which does not exist" do - -> { Process.exec "bogus-noent-script.sh" }.should raise_error(Errno::ENOENT) + -> { Process.exec "bogus-noent-script.sh" }.should.raise(Errno::ENOENT) end it "raises an ArgumentError if the command includes a null byte" do - -> { Process.exec "\000" }.should raise_error(ArgumentError) + -> { Process.exec "\000" }.should.raise(ArgumentError) end unless File.executable?(__FILE__) # Some FS (e.g. vboxfs) locate all files executable platform_is_not :windows do it "raises Errno::EACCES when the file does not have execute permissions" do - -> { Process.exec __FILE__ }.should raise_error(Errno::EACCES) + -> { Process.exec __FILE__ }.should.raise(Errno::EACCES) end end platform_is :windows do it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do - -> { Process.exec __FILE__ }.should raise_error(SystemCallError) { |e| - [Errno::EACCES, Errno::ENOEXEC].should include(e.class) + -> { Process.exec __FILE__ }.should.raise(SystemCallError) { |e| + [Errno::EACCES, Errno::ENOEXEC].should.include?(e.class) } end end end it "raises Errno::EACCES when passed a directory" do - -> { Process.exec __dir__ }.should raise_error(Errno::EACCES) + -> { Process.exec __dir__ }.should.raise(Errno::EACCES) end it "runs the specified command, replacing current process" do @@ -171,9 +171,9 @@ describe "Process.exec" do end it "raises an ArgumentError if the Array does not have exactly two elements" do - -> { Process.exec([]) }.should raise_error(ArgumentError) - -> { Process.exec([:a]) }.should raise_error(ArgumentError) - -> { Process.exec([:a, :b, :c]) }.should raise_error(ArgumentError) + -> { Process.exec([]) }.should.raise(ArgumentError) + -> { Process.exec([:a]) }.should.raise(ArgumentError) + -> { Process.exec([:a, :b, :c]) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/process/fixtures/clocks.rb b/spec/ruby/core/process/fixtures/clocks.rb index f043f6ac1f..5757e280be 100644 --- a/spec/ruby/core/process/fixtures/clocks.rb +++ b/spec/ruby/core/process/fixtures/clocks.rb @@ -2,7 +2,7 @@ module ProcessSpecs def self.clock_constants clocks = [] - platform_is_not :windows, :solaris do + platform_is_not :windows do clocks += Process.constants.select { |c| c.to_s.start_with?('CLOCK_') } # These require CAP_WAKE_ALARM and are not documented in diff --git a/spec/ruby/core/process/getpriority_spec.rb b/spec/ruby/core/process/getpriority_spec.rb index a35e5956a5..53fe7bfe20 100644 --- a/spec/ruby/core/process/getpriority_spec.rb +++ b/spec/ruby/core/process/getpriority_spec.rb @@ -5,19 +5,19 @@ describe "Process.getpriority" do it "coerces arguments to Integers" do ret = Process.getpriority mock_int(Process::PRIO_PROCESS), mock_int(0) - ret.should be_kind_of(Integer) + ret.should.is_a?(Integer) end it "gets the scheduling priority for a specified process" do - Process.getpriority(Process::PRIO_PROCESS, 0).should be_kind_of(Integer) + Process.getpriority(Process::PRIO_PROCESS, 0).should.is_a?(Integer) end it "gets the scheduling priority for a specified process group" do - Process.getpriority(Process::PRIO_PGRP, 0).should be_kind_of(Integer) + Process.getpriority(Process::PRIO_PGRP, 0).should.is_a?(Integer) end it "gets the scheduling priority for a specified user" do - Process.getpriority(Process::PRIO_USER, 0).should be_kind_of(Integer) + Process.getpriority(Process::PRIO_USER, 0).should.is_a?(Integer) end end end diff --git a/spec/ruby/core/process/getrlimit_spec.rb b/spec/ruby/core/process/getrlimit_spec.rb index 883b8fac48..d36d8c3335 100644 --- a/spec/ruby/core/process/getrlimit_spec.rb +++ b/spec/ruby/core/process/getrlimit_spec.rb @@ -16,8 +16,8 @@ describe "Process.getrlimit" do it "returns a two-element Array of Integers" do result = Process.getrlimit Process::RLIMIT_CORE result.size.should == 2 - result.first.should be_kind_of(Integer) - result.last.should be_kind_of(Integer) + result.first.should.is_a?(Integer) + result.last.should.is_a?(Integer) end context "when passed an Object" do @@ -36,7 +36,7 @@ describe "Process.getrlimit" do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - -> { Process.getrlimit(obj) }.should raise_error(TypeError) + -> { Process.getrlimit(obj) }.should.raise(TypeError) end end @@ -49,7 +49,7 @@ describe "Process.getrlimit" do end it "raises ArgumentError when passed an unknown resource" do - -> { Process.getrlimit(:FOO) }.should raise_error(ArgumentError) + -> { Process.getrlimit(:FOO) }.should.raise(ArgumentError) end end @@ -62,7 +62,7 @@ describe "Process.getrlimit" do end it "raises ArgumentError when passed an unknown resource" do - -> { Process.getrlimit("FOO") }.should raise_error(ArgumentError) + -> { Process.getrlimit("FOO") }.should.raise(ArgumentError) end end @@ -91,10 +91,10 @@ describe "Process.getrlimit" do platform_is :windows do it "is not implemented" do - Process.respond_to?(:getrlimit).should be_false + Process.respond_to?(:getrlimit).should == false -> do Process.getrlimit(nil) - end.should raise_error NotImplementedError + end.should.raise NotImplementedError end end end diff --git a/spec/ruby/core/process/gid_spec.rb b/spec/ruby/core/process/gid_spec.rb index 07221da420..ca935ed520 100644 --- a/spec/ruby/core/process/gid_spec.rb +++ b/spec/ruby/core/process/gid_spec.rb @@ -3,8 +3,8 @@ require_relative '../../spec_helper' describe "Process.gid" do platform_is_not :windows do it "returns the correct gid for the user executing this process" do - current_gid_according_to_unix = `id -gr`.to_i - Process.gid.should == current_gid_according_to_unix + current_gid_according_to_unix = `id -gr`.to_i + Process.gid.should == current_gid_according_to_unix end end diff --git a/spec/ruby/core/process/groups_spec.rb b/spec/ruby/core/process/groups_spec.rb index 33e0f9d7b3..fa916671a4 100644 --- a/spec/ruby/core/process/groups_spec.rb +++ b/spec/ruby/core/process/groups_spec.rb @@ -50,7 +50,7 @@ describe "Process.groups=" do Process.groups.should == [ Process.gid ] supplementary = groups - [ Process.gid ] if supplementary.length > 0 - -> { Process.groups = supplementary }.should raise_error(Errno::EPERM) + -> { Process.groups = supplementary }.should.raise(Errno::EPERM) end end end @@ -59,7 +59,7 @@ describe "Process.groups=" do it "raises Errno::EPERM" do -> { Process.groups = [0] - }.should raise_error(Errno::EPERM) + }.should.raise(Errno::EPERM) end end end diff --git a/spec/ruby/core/process/initgroups_spec.rb b/spec/ruby/core/process/initgroups_spec.rb index ffc7f282b6..d9f31936cb 100644 --- a/spec/ruby/core/process/initgroups_spec.rb +++ b/spec/ruby/core/process/initgroups_spec.rb @@ -14,7 +14,7 @@ describe "Process.initgroups" do Process.groups.sort.should == augmented_groups.sort Process.groups = groups else - -> { Process.initgroups(name, gid) }.should raise_error(Errno::EPERM) + -> { Process.initgroups(name, gid) }.should.raise(Errno::EPERM) end end end diff --git a/spec/ruby/core/process/kill_spec.rb b/spec/ruby/core/process/kill_spec.rb index af9c9e6deb..885c2bf2b7 100644 --- a/spec/ruby/core/process/kill_spec.rb +++ b/spec/ruby/core/process/kill_spec.rb @@ -9,18 +9,18 @@ describe "Process.kill" do end it "raises an ArgumentError for unknown signals" do - -> { Process.kill("FOO", @pid) }.should raise_error(ArgumentError) + -> { Process.kill("FOO", @pid) }.should.raise(ArgumentError) end it "raises an ArgumentError if passed a lowercase signal name" do - -> { Process.kill("term", @pid) }.should raise_error(ArgumentError) + -> { Process.kill("term", @pid) }.should.raise(ArgumentError) end it "raises an ArgumentError if signal is not an Integer or String" do signal = mock("process kill signal") signal.should_not_receive(:to_int) - -> { Process.kill(signal, @pid) }.should raise_error(ArgumentError) + -> { Process.kill(signal, @pid) }.should.raise(ArgumentError) end it "raises Errno::ESRCH if the process does not exist" do @@ -29,7 +29,7 @@ describe "Process.kill" do Process.wait(pid) -> { Process.kill("SIGKILL", pid) - }.should raise_error(Errno::ESRCH) + }.should.raise(Errno::ESRCH) end it "checks for existence and permissions to signal a process, but does not actually signal it, when using signal 0" do diff --git a/spec/ruby/core/process/last_status_spec.rb b/spec/ruby/core/process/last_status_spec.rb index 2372f2aae3..1bd8adf798 100644 --- a/spec/ruby/core/process/last_status_spec.rb +++ b/spec/ruby/core/process/last_status_spec.rb @@ -13,6 +13,6 @@ describe 'Process#last_status' do end it 'raises an ArgumentError if any arguments are provided' do - -> { Process.last_status(1) }.should raise_error(ArgumentError) + -> { Process.last_status(1) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/process/maxgroups_spec.rb b/spec/ruby/core/process/maxgroups_spec.rb index 2549a7a971..895b384bd0 100644 --- a/spec/ruby/core/process/maxgroups_spec.rb +++ b/spec/ruby/core/process/maxgroups_spec.rb @@ -3,7 +3,7 @@ require_relative '../../spec_helper' platform_is_not :windows do describe "Process.maxgroups" do it "returns the maximum number of gids allowed in the supplemental group access list" do - Process.maxgroups.should be_kind_of(Integer) + Process.maxgroups.should.is_a?(Integer) end it "sets the maximum number of gids allowed in the supplemental group access list" do diff --git a/spec/ruby/core/process/pid_spec.rb b/spec/ruby/core/process/pid_spec.rb index 2d008bc4b7..42b0b918b9 100644 --- a/spec/ruby/core/process/pid_spec.rb +++ b/spec/ruby/core/process/pid_spec.rb @@ -3,7 +3,7 @@ require_relative '../../spec_helper' describe "Process.pid" do it "returns the process id of this process" do pid = Process.pid - pid.should be_kind_of(Integer) + pid.should.is_a?(Integer) Process.pid.should == pid end end diff --git a/spec/ruby/core/process/set_proctitle_spec.rb b/spec/ruby/core/process/set_proctitle_spec.rb index d022f2021c..28a0fa6cee 100644 --- a/spec/ruby/core/process/set_proctitle_spec.rb +++ b/spec/ruby/core/process/set_proctitle_spec.rb @@ -17,7 +17,7 @@ describe 'Process.setproctitle' do title = 'rubyspec-proctitle-test' Process.setproctitle(title).should == title - `ps -ocommand= -p#{$$}`.should include(title) + `ps -ocommand= -p#{$$}`.should.include?(title) end end end diff --git a/spec/ruby/core/process/setrlimit_spec.rb b/spec/ruby/core/process/setrlimit_spec.rb index b92f98fd40..f02ab46fca 100644 --- a/spec/ruby/core/process/setrlimit_spec.rb +++ b/spec/ruby/core/process/setrlimit_spec.rb @@ -9,200 +9,196 @@ describe "Process.setrlimit" do end it "calls #to_int to convert resource to an Integer" do - Process.setrlimit(mock_int(@resource), @limit, @max).should be_nil + Process.setrlimit(mock_int(@resource), @limit, @max).should == nil end it "raises a TypeError if #to_int for resource does not return an Integer" do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - -> { Process.setrlimit(obj, @limit, @max) }.should raise_error(TypeError) + -> { Process.setrlimit(obj, @limit, @max) }.should.raise(TypeError) end it "calls #to_int to convert the soft limit to an Integer" do - Process.setrlimit(@resource, mock_int(@limit), @max).should be_nil + Process.setrlimit(@resource, mock_int(@limit), @max).should == nil end it "raises a TypeError if #to_int for resource does not return an Integer" do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - -> { Process.setrlimit(@resource, obj, @max) }.should raise_error(TypeError) + -> { Process.setrlimit(@resource, obj, @max) }.should.raise(TypeError) end it "calls #to_int to convert the hard limit to an Integer" do - Process.setrlimit(@resource, @limit, mock_int(@max)).should be_nil + Process.setrlimit(@resource, @limit, mock_int(@max)).should == nil end it "raises a TypeError if #to_int for resource does not return an Integer" do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - -> { Process.setrlimit(@resource, @limit, obj) }.should raise_error(TypeError) + -> { Process.setrlimit(@resource, @limit, obj) }.should.raise(TypeError) end end context "when passed a Symbol" do platform_is_not :openbsd do it "coerces :AS into RLIMIT_AS" do - Process.setrlimit(:AS, *Process.getrlimit(Process::RLIMIT_AS)).should be_nil + Process.setrlimit(:AS, *Process.getrlimit(Process::RLIMIT_AS)).should == nil end end it "coerces :CORE into RLIMIT_CORE" do - Process.setrlimit(:CORE, *Process.getrlimit(Process::RLIMIT_CORE)).should be_nil + Process.setrlimit(:CORE, *Process.getrlimit(Process::RLIMIT_CORE)).should == nil end it "coerces :CPU into RLIMIT_CPU" do - Process.setrlimit(:CPU, *Process.getrlimit(Process::RLIMIT_CPU)).should be_nil + Process.setrlimit(:CPU, *Process.getrlimit(Process::RLIMIT_CPU)).should == nil end it "coerces :DATA into RLIMIT_DATA" do - Process.setrlimit(:DATA, *Process.getrlimit(Process::RLIMIT_DATA)).should be_nil + Process.setrlimit(:DATA, *Process.getrlimit(Process::RLIMIT_DATA)).should == nil end it "coerces :FSIZE into RLIMIT_FSIZE" do - Process.setrlimit(:FSIZE, *Process.getrlimit(Process::RLIMIT_FSIZE)).should be_nil + Process.setrlimit(:FSIZE, *Process.getrlimit(Process::RLIMIT_FSIZE)).should == nil end it "coerces :NOFILE into RLIMIT_NOFILE" do - Process.setrlimit(:NOFILE, *Process.getrlimit(Process::RLIMIT_NOFILE)).should be_nil + Process.setrlimit(:NOFILE, *Process.getrlimit(Process::RLIMIT_NOFILE)).should == nil end it "coerces :STACK into RLIMIT_STACK" do - Process.setrlimit(:STACK, *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil + Process.setrlimit(:STACK, *Process.getrlimit(Process::RLIMIT_STACK)).should == nil end - platform_is_not :solaris, :aix do + platform_is_not :aix do it "coerces :MEMLOCK into RLIMIT_MEMLOCK" do - Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil + Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should == nil end end - platform_is_not :solaris do - it "coerces :NPROC into RLIMIT_NPROC" do - Process.setrlimit(:NPROC, *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil - end + it "coerces :NPROC into RLIMIT_NPROC" do + Process.setrlimit(:NPROC, *Process.getrlimit(Process::RLIMIT_NPROC)).should == nil + end - it "coerces :RSS into RLIMIT_RSS" do - Process.setrlimit(:RSS, *Process.getrlimit(Process::RLIMIT_RSS)).should be_nil - end + it "coerces :RSS into RLIMIT_RSS" do + Process.setrlimit(:RSS, *Process.getrlimit(Process::RLIMIT_RSS)).should == nil end platform_is :netbsd, :freebsd do it "coerces :SBSIZE into RLIMIT_SBSIZE" do - Process.setrlimit(:SBSIZE, *Process.getrlimit(Process::RLIMIT_SBSIZE)).should be_nil + Process.setrlimit(:SBSIZE, *Process.getrlimit(Process::RLIMIT_SBSIZE)).should == nil end end platform_is :linux do it "coerces :RTPRIO into RLIMIT_RTPRIO" do - Process.setrlimit(:RTPRIO, *Process.getrlimit(Process::RLIMIT_RTPRIO)).should be_nil + Process.setrlimit(:RTPRIO, *Process.getrlimit(Process::RLIMIT_RTPRIO)).should == nil end guard -> { defined?(Process::RLIMIT_RTTIME) } do it "coerces :RTTIME into RLIMIT_RTTIME" do - Process.setrlimit(:RTTIME, *Process.getrlimit(Process::RLIMIT_RTTIME)).should be_nil + Process.setrlimit(:RTTIME, *Process.getrlimit(Process::RLIMIT_RTTIME)).should == nil end end it "coerces :SIGPENDING into RLIMIT_SIGPENDING" do - Process.setrlimit(:SIGPENDING, *Process.getrlimit(Process::RLIMIT_SIGPENDING)).should be_nil + Process.setrlimit(:SIGPENDING, *Process.getrlimit(Process::RLIMIT_SIGPENDING)).should == nil end it "coerces :MSGQUEUE into RLIMIT_MSGQUEUE" do - Process.setrlimit(:MSGQUEUE, *Process.getrlimit(Process::RLIMIT_MSGQUEUE)).should be_nil + Process.setrlimit(:MSGQUEUE, *Process.getrlimit(Process::RLIMIT_MSGQUEUE)).should == nil end it "coerces :NICE into RLIMIT_NICE" do - Process.setrlimit(:NICE, *Process.getrlimit(Process::RLIMIT_NICE)).should be_nil + Process.setrlimit(:NICE, *Process.getrlimit(Process::RLIMIT_NICE)).should == nil end end it "raises ArgumentError when passed an unknown resource" do - -> { Process.setrlimit(:FOO, 1, 1) }.should raise_error(ArgumentError) + -> { Process.setrlimit(:FOO, 1, 1) }.should.raise(ArgumentError) end end context "when passed a String" do platform_is_not :openbsd do it "coerces 'AS' into RLIMIT_AS" do - Process.setrlimit("AS", *Process.getrlimit(Process::RLIMIT_AS)).should be_nil + Process.setrlimit("AS", *Process.getrlimit(Process::RLIMIT_AS)).should == nil end end it "coerces 'CORE' into RLIMIT_CORE" do - Process.setrlimit("CORE", *Process.getrlimit(Process::RLIMIT_CORE)).should be_nil + Process.setrlimit("CORE", *Process.getrlimit(Process::RLIMIT_CORE)).should == nil end it "coerces 'CPU' into RLIMIT_CPU" do - Process.setrlimit("CPU", *Process.getrlimit(Process::RLIMIT_CPU)).should be_nil + Process.setrlimit("CPU", *Process.getrlimit(Process::RLIMIT_CPU)).should == nil end it "coerces 'DATA' into RLIMIT_DATA" do - Process.setrlimit("DATA", *Process.getrlimit(Process::RLIMIT_DATA)).should be_nil + Process.setrlimit("DATA", *Process.getrlimit(Process::RLIMIT_DATA)).should == nil end it "coerces 'FSIZE' into RLIMIT_FSIZE" do - Process.setrlimit("FSIZE", *Process.getrlimit(Process::RLIMIT_FSIZE)).should be_nil + Process.setrlimit("FSIZE", *Process.getrlimit(Process::RLIMIT_FSIZE)).should == nil end it "coerces 'NOFILE' into RLIMIT_NOFILE" do - Process.setrlimit("NOFILE", *Process.getrlimit(Process::RLIMIT_NOFILE)).should be_nil + Process.setrlimit("NOFILE", *Process.getrlimit(Process::RLIMIT_NOFILE)).should == nil end it "coerces 'STACK' into RLIMIT_STACK" do - Process.setrlimit("STACK", *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil + Process.setrlimit("STACK", *Process.getrlimit(Process::RLIMIT_STACK)).should == nil end - platform_is_not :solaris, :aix do + platform_is_not :aix do it "coerces 'MEMLOCK' into RLIMIT_MEMLOCK" do - Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil + Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should == nil end end - platform_is_not :solaris do - it "coerces 'NPROC' into RLIMIT_NPROC" do - Process.setrlimit("NPROC", *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil - end + it "coerces 'NPROC' into RLIMIT_NPROC" do + Process.setrlimit("NPROC", *Process.getrlimit(Process::RLIMIT_NPROC)).should == nil + end - it "coerces 'RSS' into RLIMIT_RSS" do - Process.setrlimit("RSS", *Process.getrlimit(Process::RLIMIT_RSS)).should be_nil - end + it "coerces 'RSS' into RLIMIT_RSS" do + Process.setrlimit("RSS", *Process.getrlimit(Process::RLIMIT_RSS)).should == nil end platform_is :netbsd, :freebsd do it "coerces 'SBSIZE' into RLIMIT_SBSIZE" do - Process.setrlimit("SBSIZE", *Process.getrlimit(Process::RLIMIT_SBSIZE)).should be_nil + Process.setrlimit("SBSIZE", *Process.getrlimit(Process::RLIMIT_SBSIZE)).should == nil end end platform_is :linux do it "coerces 'RTPRIO' into RLIMIT_RTPRIO" do - Process.setrlimit("RTPRIO", *Process.getrlimit(Process::RLIMIT_RTPRIO)).should be_nil + Process.setrlimit("RTPRIO", *Process.getrlimit(Process::RLIMIT_RTPRIO)).should == nil end guard -> { defined?(Process::RLIMIT_RTTIME) } do it "coerces 'RTTIME' into RLIMIT_RTTIME" do - Process.setrlimit("RTTIME", *Process.getrlimit(Process::RLIMIT_RTTIME)).should be_nil + Process.setrlimit("RTTIME", *Process.getrlimit(Process::RLIMIT_RTTIME)).should == nil end end it "coerces 'SIGPENDING' into RLIMIT_SIGPENDING" do - Process.setrlimit("SIGPENDING", *Process.getrlimit(Process::RLIMIT_SIGPENDING)).should be_nil + Process.setrlimit("SIGPENDING", *Process.getrlimit(Process::RLIMIT_SIGPENDING)).should == nil end it "coerces 'MSGQUEUE' into RLIMIT_MSGQUEUE" do - Process.setrlimit("MSGQUEUE", *Process.getrlimit(Process::RLIMIT_MSGQUEUE)).should be_nil + Process.setrlimit("MSGQUEUE", *Process.getrlimit(Process::RLIMIT_MSGQUEUE)).should == nil end it "coerces 'NICE' into RLIMIT_NICE" do - Process.setrlimit("NICE", *Process.getrlimit(Process::RLIMIT_NICE)).should be_nil + Process.setrlimit("NICE", *Process.getrlimit(Process::RLIMIT_NICE)).should == nil end end it "raises ArgumentError when passed an unknown resource" do - -> { Process.setrlimit("FOO", 1, 1) }.should raise_error(ArgumentError) + -> { Process.setrlimit("FOO", 1, 1) }.should.raise(ArgumentError) end end @@ -217,7 +213,7 @@ describe "Process.setrlimit" do obj.should_receive(:to_str).and_return("CORE") obj.should_not_receive(:to_int) - Process.setrlimit(obj, @limit, @max).should be_nil + Process.setrlimit(obj, @limit, @max).should == nil end it "calls #to_int if #to_str does not return a String" do @@ -225,17 +221,17 @@ describe "Process.setrlimit" do obj.should_receive(:to_str).and_return(nil) obj.should_receive(:to_int).and_return(@resource) - Process.setrlimit(obj, @limit, @max).should be_nil + Process.setrlimit(obj, @limit, @max).should == nil end end end platform_is :windows do it "is not implemented" do - Process.respond_to?(:setrlimit).should be_false + Process.respond_to?(:setrlimit).should == false -> do Process.setrlimit(nil, nil) - end.should raise_error NotImplementedError + end.should.raise NotImplementedError end end end diff --git a/spec/ruby/core/process/spawn_spec.rb b/spec/ruby/core/process/spawn_spec.rb index 283a7f033d..fb619dce42 100644 --- a/spec/ruby/core/process/spawn_spec.rb +++ b/spec/ruby/core/process/spawn_spec.rb @@ -51,7 +51,7 @@ describe "Process.spawn" do it "returns the process ID of the new process as an Integer" do pid = Process.spawn(*ruby_exe, "-e", "exit") Process.wait pid - pid.should be_an_instance_of(Integer) + pid.should.instance_of?(Integer) end it "returns immediately" do @@ -93,11 +93,11 @@ describe "Process.spawn" do end it "raises an ArgumentError if the command includes a null byte" do - -> { Process.spawn "\000" }.should raise_error(ArgumentError) + -> { Process.spawn "\000" }.should.raise(ArgumentError) end it "raises a TypeError if the argument does not respond to #to_str" do - -> { Process.spawn :echo }.should raise_error(TypeError) + -> { Process.spawn :echo }.should.raise(TypeError) end end @@ -122,11 +122,11 @@ describe "Process.spawn" do end it "raises an ArgumentError if an argument includes a null byte" do - -> { Process.spawn "echo", "\000" }.should raise_error(ArgumentError) + -> { Process.spawn "echo", "\000" }.should.raise(ArgumentError) end it "raises a TypeError if an argument does not respond to #to_str" do - -> { Process.spawn "echo", :foo }.should raise_error(TypeError) + -> { Process.spawn "echo", :foo }.should.raise(TypeError) end end @@ -178,19 +178,19 @@ describe "Process.spawn" do end it "raises an ArgumentError if the Array does not have exactly two elements" do - -> { Process.spawn([]) }.should raise_error(ArgumentError) - -> { Process.spawn([:a]) }.should raise_error(ArgumentError) - -> { Process.spawn([:a, :b, :c]) }.should raise_error(ArgumentError) + -> { Process.spawn([]) }.should.raise(ArgumentError) + -> { Process.spawn([:a]) }.should.raise(ArgumentError) + -> { Process.spawn([:a, :b, :c]) }.should.raise(ArgumentError) end it "raises an ArgumentError if the Strings in the Array include a null byte" do - -> { Process.spawn ["\000", "echo"] }.should raise_error(ArgumentError) - -> { Process.spawn ["echo", "\000"] }.should raise_error(ArgumentError) + -> { Process.spawn ["\000", "echo"] }.should.raise(ArgumentError) + -> { Process.spawn ["echo", "\000"] }.should.raise(ArgumentError) end it "raises a TypeError if an element in the Array does not respond to #to_str" do - -> { Process.spawn ["echo", :echo] }.should raise_error(TypeError) - -> { Process.spawn [:echo, "echo"] }.should raise_error(TypeError) + -> { Process.spawn ["echo", :echo] }.should.raise(TypeError) + -> { Process.spawn [:echo, "echo"] }.should.raise(TypeError) end end @@ -256,19 +256,19 @@ describe "Process.spawn" do it "raises an ArgumentError if an environment key includes an equals sign" do -> do Process.spawn({"FOO=" => "BAR"}, "echo #{@var}>#{@name}") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises an ArgumentError if an environment key includes a null byte" do -> do Process.spawn({"\000" => "BAR"}, "echo #{@var}>#{@name}") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises an ArgumentError if an environment value includes a null byte" do -> do Process.spawn({"FOO" => "\000"}, "echo #{@var}>#{@name}") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end # :unsetenv_others @@ -285,7 +285,7 @@ describe "Process.spawn" do it "unsets other environment variables when given a true :unsetenv_others option" do ENV["FOO"] = "BAR" Process.wait Process.spawn(*@common_env_spawn_args, unsetenv_others: true) - $?.success?.should be_true + $?.success?.should == true File.read(@name).should == "\n" end end @@ -293,7 +293,7 @@ describe "Process.spawn" do it "does not unset other environment variables when given a false :unsetenv_others option" do ENV["FOO"] = "BAR" Process.wait Process.spawn(*@common_env_spawn_args, unsetenv_others: false) - $?.success?.should be_true + $?.success?.should == true File.read(@name).should == "BAR\n" end @@ -301,7 +301,7 @@ describe "Process.spawn" do it "does not unset environment variables included in the environment hash" do env = @minimal_env.merge({"FOO" => "BAR"}) Process.wait Process.spawn(env, "echo #{@var}>#{@name}", unsetenv_others: true) - $?.success?.should be_true + $?.success?.should == true File.read(@name).should == "BAR\n" end end @@ -363,17 +363,17 @@ describe "Process.spawn" do end it "raises an ArgumentError if given a negative :pgroup option" do - -> { Process.spawn("echo", pgroup: -1) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", pgroup: -1) }.should.raise(ArgumentError) end it "raises a TypeError if given a symbol as :pgroup option" do - -> { Process.spawn("echo", pgroup: :true) }.should raise_error(TypeError) + -> { Process.spawn("echo", pgroup: :true) }.should.raise(TypeError) end end platform_is :windows do it "raises an ArgumentError if given :pgroup option" do - -> { Process.spawn("echo", pgroup: false) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", pgroup: false) }.should.raise(ArgumentError) end end @@ -452,7 +452,7 @@ describe "Process.spawn" do children.each do |child| -> do Process.kill("TERM", child) - end.should raise_error(Errno::ESRCH) + end.should.raise(Errno::ESRCH) end end end @@ -678,53 +678,93 @@ describe "Process.spawn" do # error handling it "raises an ArgumentError if passed no command arguments" do - -> { Process.spawn }.should raise_error(ArgumentError) + -> { Process.spawn }.should.raise(ArgumentError) end it "raises an ArgumentError if passed env or options but no command arguments" do - -> { Process.spawn({}) }.should raise_error(ArgumentError) + -> { Process.spawn({}) }.should.raise(ArgumentError) end it "raises an ArgumentError if passed env and options but no command arguments" do - -> { Process.spawn({}, {}) }.should raise_error(ArgumentError) + -> { Process.spawn({}, {}) }.should.raise(ArgumentError) end it "raises an Errno::ENOENT for an empty string" do - -> { Process.spawn "" }.should raise_error(Errno::ENOENT) + -> { Process.spawn "" }.should.raise(Errno::ENOENT) end it "raises an Errno::ENOENT if the command does not exist" do - -> { Process.spawn "nonesuch" }.should raise_error(Errno::ENOENT) + -> { Process.spawn "nonesuch" }.should.raise(Errno::ENOENT, "No such file or directory - nonesuch") + end + + it "sets $? to exit status 127 when the command does not exist" do + Process.spawn("nonesuch") rescue nil + $?.exitstatus.should == 127 + end + + it "raises an Errno::ENOENT if the file does not exist" do + -> { Process.spawn "./nonesuch" }.should.raise(Errno::ENOENT, "No such file or directory - ./nonesuch") + end + + it "sets $? to exit status 127 when the file does not exist" do + Process.spawn("./nonesuch") rescue nil + $?.exitstatus.should == 127 + end + + platform_is_not :windows do + it "raises an Errno::EACCES when the path is a directory" do + -> { Process.spawn "./" }.should.raise(Errno::EACCES, "Permission denied - ./") + end end unless File.executable?(__FILE__) # Some FS (e.g. vboxfs) locate all files executable platform_is_not :windows do it "raises an Errno::EACCES when the file does not have execute permissions" do - -> { Process.spawn __FILE__ }.should raise_error(Errno::EACCES) + -> { Process.spawn __FILE__ }.should.raise(Errno::EACCES, "Permission denied - #{__FILE__}") + end + + it "sets $? to exit status 127 when the file does not have execute permissions" do + Process.spawn(__FILE__) rescue nil + $?.exitstatus.should == 127 + end + + it "raises an Errno::ENOENT when a non-executable file is found in PATH" do + dir = tmp("spawn_path_non_executable_dir") + mkdir_p dir + begin + exe = 'process-spawn-non-executable-in-path' + File.write("#{dir}/#{exe}", "#!/bin/sh\necho hi") + File.chmod(0644, "#{dir}/#{exe}") + env = { "PATH" => "#{dir}#{File::PATH_SEPARATOR}#{ENV['PATH']}" } + -> { Process.spawn(env, exe) }.should.raise(Errno::ENOENT, "No such file or directory - #{exe}") + $?.exitstatus.should == 127 + ensure + rm_r dir + end end end platform_is :windows do it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do - -> { Process.spawn __FILE__ }.should raise_error(SystemCallError) { |e| - [Errno::EACCES, Errno::ENOEXEC].should include(e.class) + -> { Process.spawn __FILE__ }.should.raise(SystemCallError) { |e| + [Errno::EACCES, Errno::ENOEXEC].should.include?(e.class) } end end end it "raises an Errno::EACCES or Errno::EISDIR when passed a directory" do - -> { Process.spawn __dir__ }.should raise_error(SystemCallError) { |e| - [Errno::EACCES, Errno::EISDIR].should include(e.class) + -> { Process.spawn __dir__ }.should.raise(SystemCallError) { |e| + [Errno::EACCES, Errno::EISDIR].should.include?(e.class) } end it "raises an ArgumentError when passed a string key in options" do - -> { Process.spawn("echo", "chdir" => Dir.pwd) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", "chdir" => Dir.pwd) }.should.raise(ArgumentError) end it "raises an ArgumentError when passed an unknown option key" do - -> { Process.spawn("echo", nonesuch: :foo) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", nonesuch: :foo) }.should.raise(ArgumentError) end platform_is_not :windows, :aix do diff --git a/spec/ruby/core/process/status/bit_and_spec.rb b/spec/ruby/core/process/status/bit_and_spec.rb index 0e0edb0afa..a5b1123e90 100644 --- a/spec/ruby/core/process/status/bit_and_spec.rb +++ b/spec/ruby/core/process/status/bit_and_spec.rb @@ -1,6 +1,6 @@ require_relative '../../../spec_helper' -ruby_version_is ""..."3.5" do +ruby_version_is ""..."4.0" do describe "Process::Status#&" do it "returns a bitwise and of the integer status of an exited child" do @@ -17,13 +17,13 @@ ruby_version_is ""..."3.5" do end end - ruby_version_is "3.3"..."3.5" do + ruby_version_is ""..."4.0" do it "raises an ArgumentError if mask is negative" do suppress_warning do ruby_exe("exit(0)") -> { $? & -1 - }.should raise_error(ArgumentError, 'negative mask value: -1') + }.should.raise(ArgumentError, 'negative mask value: -1') end end diff --git a/spec/ruby/core/process/status/exited_spec.rb b/spec/ruby/core/process/status/exited_spec.rb index a61292b146..ad14b35000 100644 --- a/spec/ruby/core/process/status/exited_spec.rb +++ b/spec/ruby/core/process/status/exited_spec.rb @@ -7,7 +7,7 @@ describe "Process::Status#exited?" do end it "returns true" do - $?.exited?.should be_true + $?.exited?.should == true end end @@ -19,13 +19,13 @@ describe "Process::Status#exited?" do platform_is_not :windows do it "returns false" do - $?.exited?.should be_false + $?.exited?.should == false end end platform_is :windows do it "always returns true" do - $?.exited?.should be_true + $?.exited?.should == true end end end diff --git a/spec/ruby/core/process/status/right_shift_spec.rb b/spec/ruby/core/process/status/right_shift_spec.rb index a1ab75141a..5689526f54 100644 --- a/spec/ruby/core/process/status/right_shift_spec.rb +++ b/spec/ruby/core/process/status/right_shift_spec.rb @@ -1,6 +1,6 @@ require_relative '../../../spec_helper' -ruby_version_is ""..."3.5" do +ruby_version_is ""..."4.0" do describe "Process::Status#>>" do it "returns a right shift of the integer status of an exited child" do @@ -16,13 +16,13 @@ ruby_version_is ""..."3.5" do end end - ruby_version_is "3.3"..."3.5" do + ruby_version_is ""..."4.0" do it "raises an ArgumentError if shift value is negative" do suppress_warning do ruby_exe("exit(0)") -> { $? >> -1 - }.should raise_error(ArgumentError, 'negative shift value: -1') + }.should.raise(ArgumentError, 'negative shift value: -1') end end diff --git a/spec/ruby/core/process/status/signaled_spec.rb b/spec/ruby/core/process/status/signaled_spec.rb index c0de7b8006..8cf409bb42 100644 --- a/spec/ruby/core/process/status/signaled_spec.rb +++ b/spec/ruby/core/process/status/signaled_spec.rb @@ -7,7 +7,7 @@ describe "Process::Status#signaled?" do end it "returns false" do - $?.signaled?.should be_false + $?.signaled?.should == false end end @@ -18,13 +18,13 @@ describe "Process::Status#signaled?" do platform_is_not :windows do it "returns true" do - $?.signaled?.should be_true + $?.signaled?.should == true end end platform_is :windows do it "always returns false" do - $?.signaled?.should be_false + $?.signaled?.should == false end end end diff --git a/spec/ruby/core/process/status/success_spec.rb b/spec/ruby/core/process/status/success_spec.rb index 3589cc611f..f61243c667 100644 --- a/spec/ruby/core/process/status/success_spec.rb +++ b/spec/ruby/core/process/status/success_spec.rb @@ -7,7 +7,7 @@ describe "Process::Status#success?" do end it "returns true" do - $?.success?.should be_true + $?.success?.should == true end end @@ -17,7 +17,7 @@ describe "Process::Status#success?" do end it "returns false" do - $?.success?.should be_false + $?.success?.should == false end end @@ -28,13 +28,13 @@ describe "Process::Status#success?" do platform_is_not :windows do it "returns nil" do - $?.success?.should be_nil + $?.success?.should == nil end end platform_is :windows do it "always returns true" do - $?.success?.should be_true + $?.success?.should == true end end end diff --git a/spec/ruby/core/process/status/termsig_spec.rb b/spec/ruby/core/process/status/termsig_spec.rb index 9a22dbea71..1d57724d12 100644 --- a/spec/ruby/core/process/status/termsig_spec.rb +++ b/spec/ruby/core/process/status/termsig_spec.rb @@ -7,7 +7,7 @@ describe "Process::Status#termsig" do end it "returns nil" do - $?.termsig.should be_nil + $?.termsig.should == nil end end @@ -36,7 +36,7 @@ describe "Process::Status#termsig" do platform_is :windows do it "always returns nil" do - $?.termsig.should be_nil + $?.termsig.should == nil end end end diff --git a/spec/ruby/core/process/status/to_i_spec.rb b/spec/ruby/core/process/status/to_i_spec.rb index 39f8e2d84c..0bfb883d23 100644 --- a/spec/ruby/core/process/status/to_i_spec.rb +++ b/spec/ruby/core/process/status/to_i_spec.rb @@ -3,11 +3,11 @@ require_relative '../../../spec_helper' describe "Process::Status#to_i" do it "returns an integer when the child exits" do ruby_exe('exit 48', exit_status: 48) - $?.to_i.should be_an_instance_of(Integer) + $?.to_i.should.instance_of?(Integer) end it "returns an integer when the child is signaled" do ruby_exe('raise SignalException, "TERM"', exit_status: platform_is(:windows) ? 3 : :SIGTERM) - $?.to_i.should be_an_instance_of(Integer) + $?.to_i.should.instance_of?(Integer) end end diff --git a/spec/ruby/core/process/status/wait_spec.rb b/spec/ruby/core/process/status/wait_spec.rb index 57d56209a9..18ecc14f6f 100644 --- a/spec/ruby/core/process/status/wait_spec.rb +++ b/spec/ruby/core/process/status/wait_spec.rb @@ -21,14 +21,14 @@ describe "Process::Status.wait" do it "returns a status with its child pid" do pid = Process.spawn(ruby_cmd('exit')) status = Process::Status.wait - status.should be_an_instance_of(Process::Status) + status.should.instance_of?(Process::Status) status.pid.should == pid end it "should not set $? to the Process::Status" do pid = Process.spawn(ruby_cmd('exit')) status = Process::Status.wait - $?.should_not equal(status) + $?.should_not.equal?(status) end it "should not change the value of $?" do @@ -36,13 +36,13 @@ describe "Process::Status.wait" do Process.wait status = $? Process::Status.wait - status.should equal($?) + status.should.equal?($?) end it "waits for any child process if no pid is given" do pid = Process.spawn(ruby_cmd('exit')) Process::Status.wait.pid.should == pid - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) end it "waits for a specific child if a pid is given" do @@ -50,14 +50,14 @@ describe "Process::Status.wait" do pid2 = Process.spawn(ruby_cmd('exit')) Process::Status.wait(pid2).pid.should == pid2 Process::Status.wait(pid1).pid.should == pid1 - -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) - -> { Process.kill(0, pid2) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should.raise(Errno::ESRCH) + -> { Process.kill(0, pid2) }.should.raise(Errno::ESRCH) end it "coerces the pid to an Integer" do pid1 = Process.spawn(ruby_cmd('exit')) Process::Status.wait(mock_int(pid1)).pid.should == pid1 - -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should.raise(Errno::ESRCH) end # This spec is probably system-dependent. @@ -80,7 +80,7 @@ describe "Process::Status.wait" do sleep end - Process::Status.wait(pid, Process::WNOHANG).should be_nil + Process::Status.wait(pid, Process::WNOHANG).should == nil # wait for the child to setup its TERM handler write.close @@ -94,7 +94,7 @@ describe "Process::Status.wait" do it "always accepts flags=0" do pid = Process.spawn(ruby_cmd('exit')) Process::Status.wait(-1, 0).pid.should == pid - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) end end end diff --git a/spec/ruby/core/process/times_spec.rb b/spec/ruby/core/process/times_spec.rb index d3bff2cda9..a7ffbb79e5 100644 --- a/spec/ruby/core/process/times_spec.rb +++ b/spec/ruby/core/process/times_spec.rb @@ -2,7 +2,7 @@ require_relative '../../spec_helper' describe "Process.times" do it "returns a Process::Tms" do - Process.times.should be_kind_of(Process::Tms) + Process.times.should.is_a?(Process::Tms) end # TODO: Intel C Compiler does not work this example diff --git a/spec/ruby/core/process/tms/cstime_spec.rb b/spec/ruby/core/process/tms/cstime_spec.rb new file mode 100644 index 0000000000..9c2d9e8632 --- /dev/null +++ b/spec/ruby/core/process/tms/cstime_spec.rb @@ -0,0 +1,17 @@ +require_relative '../../../spec_helper' + +describe "Process::Tms#cstime" do + it "returns cstime attribute" do + cstime = Object.new + Process::Tms.new(nil, nil, nil, cstime).cstime.should == cstime + end +end + +describe "Process::Tms#cstime=" do + it "assigns a value to the cstime attribute" do + cstime = Object.new + tms = Process::Tms.new + tms.cstime = cstime + tms.cstime.should == cstime + end +end diff --git a/spec/ruby/core/process/tms/cutime_spec.rb b/spec/ruby/core/process/tms/cutime_spec.rb new file mode 100644 index 0000000000..0ac3ff1964 --- /dev/null +++ b/spec/ruby/core/process/tms/cutime_spec.rb @@ -0,0 +1,17 @@ +require_relative '../../../spec_helper' + +describe "Process::Tms#cutime" do + it "returns cutime attribute" do + cutime = Object.new + Process::Tms.new(nil, nil, cutime, nil).cutime.should == cutime + end +end + +describe "Process::Tms#cutime=" do + it "assigns a value to the cutime attribute" do + cutime = Object.new + tms = Process::Tms.new + tms.cutime = cutime + tms.cutime.should == cutime + end +end diff --git a/spec/ruby/core/process/tms/stime_spec.rb b/spec/ruby/core/process/tms/stime_spec.rb new file mode 100644 index 0000000000..1e8371475f --- /dev/null +++ b/spec/ruby/core/process/tms/stime_spec.rb @@ -0,0 +1,17 @@ +require_relative '../../../spec_helper' + +describe "Process::Tms#stime" do + it "returns stime attribute" do + stime = Object.new + Process::Tms.new(nil, stime, nil, nil).stime.should == stime + end +end + +describe "Process::Tms#stime=" do + it "assigns a value to the stime attribute" do + stime = Object.new + tms = Process::Tms.new + tms.stime = stime + tms.stime.should == stime + end +end diff --git a/spec/ruby/core/process/tms/utime_spec.rb b/spec/ruby/core/process/tms/utime_spec.rb new file mode 100644 index 0000000000..403a31e2e6 --- /dev/null +++ b/spec/ruby/core/process/tms/utime_spec.rb @@ -0,0 +1,17 @@ +require_relative '../../../spec_helper' + +describe "Process::Tms#utime" do + it "returns utime attribute" do + utime = Object.new + Process::Tms.new(utime, nil, nil, nil).utime.should == utime + end +end + +describe "Process::Tms#utime=" do + it "assigns a value to the ctime attribute" do + utime = Object.new + tms = Process::Tms.new + tms.utime = utime + tms.utime.should == utime + end +end diff --git a/spec/ruby/core/process/uid_spec.rb b/spec/ruby/core/process/uid_spec.rb index a068b1a2c1..1e218ef4fe 100644 --- a/spec/ruby/core/process/uid_spec.rb +++ b/spec/ruby/core/process/uid_spec.rb @@ -20,16 +20,16 @@ end describe "Process.uid=" do platform_is_not :windows do it "raises TypeError if not passed an Integer" do - -> { Process.uid = Object.new }.should raise_error(TypeError) + -> { Process.uid = Object.new }.should.raise(TypeError) end as_user do it "raises Errno::ERPERM if run by a non privileged user trying to set the superuser id" do - -> { (Process.uid = 0)}.should raise_error(Errno::EPERM) + -> { (Process.uid = 0)}.should.raise(Errno::EPERM) end it "raises Errno::ERPERM if run by a non privileged user trying to set the superuser id from username" do - -> { Process.uid = "root" }.should raise_error(Errno::EPERM) + -> { Process.uid = "root" }.should.raise(Errno::EPERM) end end diff --git a/spec/ruby/core/process/wait2_spec.rb b/spec/ruby/core/process/wait2_spec.rb index 8ba429dc96..5c57dd40fb 100644 --- a/spec/ruby/core/process/wait2_spec.rb +++ b/spec/ruby/core/process/wait2_spec.rb @@ -12,7 +12,7 @@ describe "Process.wait2" do leaked = Process.waitall $stderr.puts "leaked before wait2 specs: #{leaked}" unless leaked.empty? # Ruby-space should not see PIDs used by rjit - leaked.should be_empty + leaked.should.empty? rescue Errno::ECHILD # No child processes rescue NotImplementedError end @@ -30,15 +30,15 @@ describe "Process.wait2" do end it "raises a StandardError if no child processes exist" do - -> { Process.wait2 }.should raise_error(Errno::ECHILD) - -> { Process.wait2 }.should raise_error(StandardError) + -> { Process.wait2 }.should.raise(Errno::ECHILD) + -> { Process.wait2 }.should.raise(StandardError) end it "returns nil if the child process is still running when given the WNOHANG flag" do IO.popen(ruby_cmd('STDIN.getbyte'), "w") do |io| pid, status = Process.wait2(io.pid, Process::WNOHANG) - pid.should be_nil - status.should be_nil + pid.should == nil + status.should == nil io.write('a') end end diff --git a/spec/ruby/core/process/wait_spec.rb b/spec/ruby/core/process/wait_spec.rb index 385acc9928..0b2e715f65 100644 --- a/spec/ruby/core/process/wait_spec.rb +++ b/spec/ruby/core/process/wait_spec.rb @@ -14,7 +14,7 @@ describe "Process.wait" do end it "raises an Errno::ECHILD if there are no child processes" do - -> { Process.wait }.should raise_error(Errno::ECHILD) + -> { Process.wait }.should.raise(Errno::ECHILD) end platform_is_not :windows do @@ -26,14 +26,14 @@ describe "Process.wait" do it "sets $? to a Process::Status" do pid = Process.spawn(ruby_cmd('exit')) Process.wait - $?.should be_kind_of(Process::Status) + $?.should.is_a?(Process::Status) $?.pid.should == pid end it "waits for any child process if no pid is given" do pid = Process.spawn(ruby_cmd('exit')) Process.wait.should == pid - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) end it "waits for a specific child if a pid is given" do @@ -41,14 +41,14 @@ describe "Process.wait" do pid2 = Process.spawn(ruby_cmd('exit')) Process.wait(pid2).should == pid2 Process.wait(pid1).should == pid1 - -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) - -> { Process.kill(0, pid2) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should.raise(Errno::ESRCH) + -> { Process.kill(0, pid2) }.should.raise(Errno::ESRCH) end it "coerces the pid to an Integer" do pid1 = Process.spawn(ruby_cmd('exit')) Process.wait(mock_int(pid1)).should == pid1 - -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should.raise(Errno::ESRCH) end # This spec is probably system-dependent. @@ -71,7 +71,7 @@ describe "Process.wait" do sleep end - Process.wait(pid, Process::WNOHANG).should be_nil + Process.wait(pid, Process::WNOHANG).should == nil # wait for the child to setup its TERM handler write.close @@ -85,7 +85,7 @@ describe "Process.wait" do it "always accepts flags=0" do pid = Process.spawn(ruby_cmd('exit')) Process.wait(-1, 0).should == pid - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) end end end diff --git a/spec/ruby/core/process/waitall_spec.rb b/spec/ruby/core/process/waitall_spec.rb index 6cf4e32bc9..a77873f553 100644 --- a/spec/ruby/core/process/waitall_spec.rb +++ b/spec/ruby/core/process/waitall_spec.rb @@ -13,7 +13,7 @@ describe "Process.waitall" do end it "takes no arguments" do - -> { Process.waitall(0) }.should raise_error(ArgumentError) + -> { Process.waitall(0) }.should.raise(ArgumentError) end platform_is_not :windows do @@ -24,7 +24,7 @@ describe "Process.waitall" do pids << Process.fork { Process.exit! 0 } Process.waitall pids.each { |pid| - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) } end @@ -34,14 +34,14 @@ describe "Process.waitall" do pids << Process.fork { Process.exit! 1 } pids << Process.fork { Process.exit! 0 } a = Process.waitall - a.should be_kind_of(Array) + a.should.is_a?(Array) a.size.should == 3 pids.each { |pid| pid_status = a.assoc(pid) - pid_status.should be_kind_of(Array) + pid_status.should.is_a?(Array) pid_status.size.should == 2 pid_status.first.should == pid - pid_status.last.should be_kind_of(Process::Status) + pid_status.last.should.is_a?(Process::Status) } end end diff --git a/spec/ruby/core/process/warmup_spec.rb b/spec/ruby/core/process/warmup_spec.rb index b562d52d22..4530ae222c 100644 --- a/spec/ruby/core/process/warmup_spec.rb +++ b/spec/ruby/core/process/warmup_spec.rb @@ -1,11 +1,9 @@ require_relative '../../spec_helper' describe "Process.warmup" do - ruby_version_is "3.3" do - # The behavior is entirely implementation specific. - # Other implementations are free to just make it a noop - it "is implemented" do - Process.warmup.should == true - end + # The behavior is entirely implementation specific. + # Other implementations are free to just make it a noop + it "is implemented" do + Process.warmup.should == true end end |
