diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
commit | 5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch) | |
tree | 05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/core/process | |
parent | a06301b103371b0b7da8eaca26ba744961769f99 (diff) |
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/core/process')
-rw-r--r-- | spec/ruby/core/process/clock_gettime_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/process/daemon_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/process/detach_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/process/euid_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/core/process/exec_spec.rb | 20 | ||||
-rw-r--r-- | spec/ruby/core/process/getrlimit_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/core/process/groups_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/process/initgroups_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/process/kill_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/core/process/setrlimit_spec.rb | 10 | ||||
-rw-r--r-- | spec/ruby/core/process/spawn_spec.rb | 126 | ||||
-rw-r--r-- | spec/ruby/core/process/uid_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/core/process/wait2_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/process/wait_spec.rb | 12 | ||||
-rw-r--r-- | spec/ruby/core/process/waitall_spec.rb | 4 |
15 files changed, 107 insertions, 107 deletions
diff --git a/spec/ruby/core/process/clock_gettime_spec.rb b/spec/ruby/core/process/clock_gettime_spec.rb index 4cd13857ea..d3f973d7ae 100644 --- a/spec/ruby/core/process/clock_gettime_spec.rb +++ b/spec/ruby/core/process/clock_gettime_spec.rb @@ -20,7 +20,7 @@ describe "Process.clock_gettime" do end it 'raises an ArgumentError for an invalid time unit' do - lambda { Process.clock_gettime(Process::CLOCK_MONOTONIC, :bad) }.should raise_error(ArgumentError) + -> { Process.clock_gettime(Process::CLOCK_MONOTONIC, :bad) }.should raise_error(ArgumentError) end it 'defaults to :float_second' do diff --git a/spec/ruby/core/process/daemon_spec.rb b/spec/ruby/core/process/daemon_spec.rb index b472a3b9e9..70ffd1b320 100644 --- a/spec/ruby/core/process/daemon_spec.rb +++ b/spec/ruby/core/process/daemon_spec.rb @@ -107,7 +107,7 @@ end platform_is :windows do describe "Process.daemon" do it "raises a NotImplementedError" do - lambda { + -> { Process.daemon }.should raise_error(NotImplementedError) end diff --git a/spec/ruby/core/process/detach_spec.rb b/spec/ruby/core/process/detach_spec.rb index 74169a2fed..1c27ed9c2c 100644 --- a/spec/ruby/core/process/detach_spec.rb +++ b/spec/ruby/core/process/detach_spec.rb @@ -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 - lambda { Process.waitpid(pid) }.should raise_error(Errno::ECHILD) + -> { Process.waitpid(pid) }.should raise_error(Errno::ECHILD) end end diff --git a/spec/ruby/core/process/euid_spec.rb b/spec/ruby/core/process/euid_spec.rb index ffb71a7178..7bbacfadfd 100644 --- a/spec/ruby/core/process/euid_spec.rb +++ b/spec/ruby/core/process/euid_spec.rb @@ -18,16 +18,16 @@ describe "Process.euid=" do platform_is_not :windows do it "raises TypeError if not passed an Integer" do - lambda { Process.euid = Object.new }.should raise_error(TypeError) + -> { Process.euid = Object.new }.should raise_error(TypeError) end as_user do it "raises Errno::ERPERM if run by a non superuser trying to set the superuser id" do - lambda { (Process.euid = 0)}.should raise_error(Errno::EPERM) + -> { (Process.euid = 0)}.should raise_error(Errno::EPERM) end it "raises Errno::ERPERM if run by a non superuser trying to set the superuser id from username" do - lambda { Process.euid = "root" }.should raise_error(Errno::EPERM) + -> { Process.euid = "root" }.should raise_error(Errno::EPERM) end end diff --git a/spec/ruby/core/process/exec_spec.rb b/spec/ruby/core/process/exec_spec.rb index 098898d42e..848990c6dc 100644 --- a/spec/ruby/core/process/exec_spec.rb +++ b/spec/ruby/core/process/exec_spec.rb @@ -2,27 +2,27 @@ require_relative '../../spec_helper' describe "Process.exec" do it "raises Errno::ENOENT for an empty string" do - lambda { Process.exec "" }.should raise_error(Errno::ENOENT) + -> { Process.exec "" }.should raise_error(Errno::ENOENT) end it "raises Errno::ENOENT for a command which does not exist" do - lambda { Process.exec "bogus-noent-script.sh" }.should raise_error(Errno::ENOENT) + -> { Process.exec "bogus-noent-script.sh" }.should raise_error(Errno::ENOENT) end it "raises an ArgumentError if the command includes a null byte" do - lambda { Process.exec "\000" }.should raise_error(ArgumentError) + -> { Process.exec "\000" }.should raise_error(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 - lambda { Process.exec __FILE__ }.should raise_error(Errno::EACCES) + -> { Process.exec __FILE__ }.should raise_error(Errno::EACCES) end end platform_is :windows do it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do - lambda { Process.exec __FILE__ }.should raise_error(SystemCallError) { |e| + -> { Process.exec __FILE__ }.should raise_error(SystemCallError) { |e| [Errno::EACCES, Errno::ENOEXEC].should include(e.class) } end @@ -31,13 +31,13 @@ describe "Process.exec" do platform_is_not :openbsd do it "raises Errno::EACCES when passed a directory" do - lambda { Process.exec File.dirname(__FILE__) }.should raise_error(Errno::EACCES) + -> { Process.exec File.dirname(__FILE__) }.should raise_error(Errno::EACCES) end end platform_is :openbsd do it "raises Errno::EISDIR when passed a directory" do - lambda { Process.exec File.dirname(__FILE__) }.should raise_error(Errno::EISDIR) + -> { Process.exec File.dirname(__FILE__) }.should raise_error(Errno::EISDIR) end end @@ -179,9 +179,9 @@ describe "Process.exec" do end it "raises an ArgumentError if the Array does not have exactly two elements" do - lambda { Process.exec([]) }.should raise_error(ArgumentError) - lambda { Process.exec([:a]) }.should raise_error(ArgumentError) - lambda { Process.exec([:a, :b, :c]) }.should raise_error(ArgumentError) + -> { Process.exec([]) }.should raise_error(ArgumentError) + -> { Process.exec([:a]) }.should raise_error(ArgumentError) + -> { Process.exec([:a, :b, :c]) }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/process/getrlimit_spec.rb b/spec/ruby/core/process/getrlimit_spec.rb index d866a48186..f77a61a475 100644 --- a/spec/ruby/core/process/getrlimit_spec.rb +++ b/spec/ruby/core/process/getrlimit_spec.rb @@ -36,7 +36,7 @@ platform_is_not :windows do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - lambda { Process.getrlimit(obj) }.should raise_error(TypeError) + -> { Process.getrlimit(obj) }.should raise_error(TypeError) end end @@ -49,7 +49,7 @@ platform_is_not :windows do end it "raises ArgumentError when passed an unknown resource" do - lambda { Process.getrlimit(:FOO) }.should raise_error(ArgumentError) + -> { Process.getrlimit(:FOO) }.should raise_error(ArgumentError) end end @@ -62,7 +62,7 @@ platform_is_not :windows do end it "raises ArgumentError when passed an unknown resource" do - lambda { Process.getrlimit("FOO") }.should raise_error(ArgumentError) + -> { Process.getrlimit("FOO") }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/process/groups_spec.rb b/spec/ruby/core/process/groups_spec.rb index 325deb5977..6b9175736d 100644 --- a/spec/ruby/core/process/groups_spec.rb +++ b/spec/ruby/core/process/groups_spec.rb @@ -46,14 +46,14 @@ describe "Process.groups=" do Process.groups.should == [ Process.gid ] supplementary = groups - [ Process.gid ] if supplementary.length > 0 - lambda { Process.groups = supplementary }.should raise_error(Errno::EPERM) + -> { Process.groups = supplementary }.should raise_error(Errno::EPERM) end end end platform_is_not :aix do it "raises Errno::EPERM" do - lambda { + -> { Process.groups = [0] }.should raise_error(Errno::EPERM) end diff --git a/spec/ruby/core/process/initgroups_spec.rb b/spec/ruby/core/process/initgroups_spec.rb index e711fc0798..1dd516d8b2 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 - lambda { Process.initgroups(name, gid) }.should raise_error(Errno::EPERM) + -> { Process.initgroups(name, gid) }.should raise_error(Errno::EPERM) end end end diff --git a/spec/ruby/core/process/kill_spec.rb b/spec/ruby/core/process/kill_spec.rb index 14deba2451..4bd64a1fe8 100644 --- a/spec/ruby/core/process/kill_spec.rb +++ b/spec/ruby/core/process/kill_spec.rb @@ -9,25 +9,25 @@ describe "Process.kill" do end it "raises an ArgumentError for unknown signals" do - lambda { Process.kill("FOO", @pid) }.should raise_error(ArgumentError) + -> { Process.kill("FOO", @pid) }.should raise_error(ArgumentError) end it "raises an ArgumentError if passed a lowercase signal name" do - lambda { Process.kill("term", @pid) }.should raise_error(ArgumentError) + -> { Process.kill("term", @pid) }.should raise_error(ArgumentError) end it "raises an ArgumentError if signal is not a Fixnum or String" do signal = mock("process kill signal") signal.should_not_receive(:to_int) - lambda { Process.kill(signal, @pid) }.should raise_error(ArgumentError) + -> { Process.kill(signal, @pid) }.should raise_error(ArgumentError) end it "raises Errno::ESRCH if the process does not exist" do pid = Process.spawn(*ruby_exe, "-e", "sleep 10") Process.kill("SIGKILL", pid) Process.wait(pid) - lambda { + -> { Process.kill("SIGKILL", pid) }.should raise_error(Errno::ESRCH) end diff --git a/spec/ruby/core/process/setrlimit_spec.rb b/spec/ruby/core/process/setrlimit_spec.rb index f4ff607b7b..8bc035a4f1 100644 --- a/spec/ruby/core/process/setrlimit_spec.rb +++ b/spec/ruby/core/process/setrlimit_spec.rb @@ -16,7 +16,7 @@ platform_is_not :windows do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - lambda { Process.setrlimit(obj, @limit, @max) }.should raise_error(TypeError) + -> { Process.setrlimit(obj, @limit, @max) }.should raise_error(TypeError) end it "calls #to_int to convert the soft limit to an Integer" do @@ -27,7 +27,7 @@ platform_is_not :windows do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - lambda { Process.setrlimit(@resource, obj, @max) }.should raise_error(TypeError) + -> { Process.setrlimit(@resource, obj, @max) }.should raise_error(TypeError) end it "calls #to_int to convert the hard limit to an Integer" do @@ -38,7 +38,7 @@ platform_is_not :windows do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - lambda { Process.setrlimit(@resource, @limit, obj) }.should raise_error(TypeError) + -> { Process.setrlimit(@resource, @limit, obj) }.should raise_error(TypeError) end end @@ -120,7 +120,7 @@ platform_is_not :windows do end it "raises ArgumentError when passed an unknown resource" do - lambda { Process.setrlimit(:FOO, 1, 1) }.should raise_error(ArgumentError) + -> { Process.setrlimit(:FOO, 1, 1) }.should raise_error(ArgumentError) end end @@ -202,7 +202,7 @@ platform_is_not :windows do end it "raises ArgumentError when passed an unknown resource" do - lambda { Process.setrlimit("FOO", 1, 1) }.should raise_error(ArgumentError) + -> { Process.setrlimit("FOO", 1, 1) }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/process/spawn_spec.rb b/spec/ruby/core/process/spawn_spec.rb index aa7a7dc3aa..46faced3e4 100644 --- a/spec/ruby/core/process/spawn_spec.rb +++ b/spec/ruby/core/process/spawn_spec.rb @@ -45,7 +45,7 @@ describe "Process.spawn" do end it "executes the given command" do - lambda { Process.wait Process.spawn("echo spawn") }.should output_to_fd("spawn\n") + -> { Process.wait Process.spawn("echo spawn") }.should output_to_fd("spawn\n") end it "returns the process ID of the new process as a Fixnum" do @@ -67,43 +67,43 @@ describe "Process.spawn" do describe "with a single argument" do platform_is_not :windows do it "subjects the specified command to shell expansion" do - lambda { Process.wait Process.spawn("echo *") }.should_not output_to_fd("*\n") + -> { Process.wait Process.spawn("echo *") }.should_not output_to_fd("*\n") end it "creates an argument array with shell parsing semantics for whitespace" do - lambda { Process.wait Process.spawn("echo a b c d") }.should output_to_fd("a b c d\n") + -> { Process.wait Process.spawn("echo a b c d") }.should output_to_fd("a b c d\n") end end platform_is :windows do # There is no shell expansion on Windows it "does not subject the specified command to shell expansion on Windows" do - lambda { Process.wait Process.spawn("echo *") }.should output_to_fd("*\n") + -> { Process.wait Process.spawn("echo *") }.should output_to_fd("*\n") end it "does not create an argument array with shell parsing semantics for whitespace on Windows" do - lambda { Process.wait Process.spawn("echo a b c d") }.should output_to_fd("a b c d\n") + -> { Process.wait Process.spawn("echo a b c d") }.should output_to_fd("a b c d\n") end end it "calls #to_str to convert the argument to a String" do o = mock("to_str") o.should_receive(:to_str).and_return("echo foo") - lambda { Process.wait Process.spawn(o) }.should output_to_fd("foo\n") + -> { Process.wait Process.spawn(o) }.should output_to_fd("foo\n") end it "raises an ArgumentError if the command includes a null byte" do - lambda { Process.spawn "\000" }.should raise_error(ArgumentError) + -> { Process.spawn "\000" }.should raise_error(ArgumentError) end it "raises a TypeError if the argument does not respond to #to_str" do - lambda { Process.spawn :echo }.should raise_error(TypeError) + -> { Process.spawn :echo }.should raise_error(TypeError) end end describe "with multiple arguments" do it "does not subject the arguments to shell expansion" do - lambda { Process.wait Process.spawn("echo", "*") }.should output_to_fd("*\n") + -> { Process.wait Process.spawn("echo", "*") }.should output_to_fd("*\n") end it "preserves whitespace in passed arguments" do @@ -112,36 +112,36 @@ describe "Process.spawn" do # The echo command on Windows takes quotes literally out = "\"a b c d\"\n" end - lambda { Process.wait Process.spawn("echo", "a b c d") }.should output_to_fd(out) + -> { Process.wait Process.spawn("echo", "a b c d") }.should output_to_fd(out) end it "calls #to_str to convert the arguments to Strings" do o = mock("to_str") o.should_receive(:to_str).and_return("foo") - lambda { Process.wait Process.spawn("echo", o) }.should output_to_fd("foo\n") + -> { Process.wait Process.spawn("echo", o) }.should output_to_fd("foo\n") end it "raises an ArgumentError if an argument includes a null byte" do - lambda { Process.spawn "echo", "\000" }.should raise_error(ArgumentError) + -> { Process.spawn "echo", "\000" }.should raise_error(ArgumentError) end it "raises a TypeError if an argument does not respond to #to_str" do - lambda { Process.spawn "echo", :foo }.should raise_error(TypeError) + -> { Process.spawn "echo", :foo }.should raise_error(TypeError) end end describe "with a command array" do it "uses the first element as the command name and the second as the argv[0] value" do platform_is_not :windows do - lambda { Process.wait Process.spawn(["/bin/sh", "argv_zero"], "-c", "echo $0") }.should output_to_fd("argv_zero\n") + -> { Process.wait Process.spawn(["/bin/sh", "argv_zero"], "-c", "echo $0") }.should output_to_fd("argv_zero\n") end platform_is :windows do - lambda { Process.wait Process.spawn(["cmd.exe", "/C"], "/C", "echo", "argv_zero") }.should output_to_fd("argv_zero\n") + -> { Process.wait Process.spawn(["cmd.exe", "/C"], "/C", "echo", "argv_zero") }.should output_to_fd("argv_zero\n") end end it "does not subject the arguments to shell expansion" do - lambda { Process.wait Process.spawn(["echo", "echo"], "*") }.should output_to_fd("*\n") + -> { Process.wait Process.spawn(["echo", "echo"], "*") }.should output_to_fd("*\n") end it "preserves whitespace in passed arguments" do @@ -150,47 +150,47 @@ describe "Process.spawn" do # The echo command on Windows takes quotes literally out = "\"a b c d\"\n" end - lambda { Process.wait Process.spawn(["echo", "echo"], "a b c d") }.should output_to_fd(out) + -> { Process.wait Process.spawn(["echo", "echo"], "a b c d") }.should output_to_fd(out) end it "calls #to_ary to convert the argument to an Array" do o = mock("to_ary") platform_is_not :windows do o.should_receive(:to_ary).and_return(["/bin/sh", "argv_zero"]) - lambda { Process.wait Process.spawn(o, "-c", "echo $0") }.should output_to_fd("argv_zero\n") + -> { Process.wait Process.spawn(o, "-c", "echo $0") }.should output_to_fd("argv_zero\n") end platform_is :windows do o.should_receive(:to_ary).and_return(["cmd.exe", "/C"]) - lambda { Process.wait Process.spawn(o, "/C", "echo", "argv_zero") }.should output_to_fd("argv_zero\n") + -> { Process.wait Process.spawn(o, "/C", "echo", "argv_zero") }.should output_to_fd("argv_zero\n") end end it "calls #to_str to convert the first element to a String" do o = mock("to_str") o.should_receive(:to_str).and_return("echo") - lambda { Process.wait Process.spawn([o, "echo"], "foo") }.should output_to_fd("foo\n") + -> { Process.wait Process.spawn([o, "echo"], "foo") }.should output_to_fd("foo\n") end it "calls #to_str to convert the second element to a String" do o = mock("to_str") o.should_receive(:to_str).and_return("echo") - lambda { Process.wait Process.spawn(["echo", o], "foo") }.should output_to_fd("foo\n") + -> { Process.wait Process.spawn(["echo", o], "foo") }.should output_to_fd("foo\n") end it "raises an ArgumentError if the Array does not have exactly two elements" do - lambda { Process.spawn([]) }.should raise_error(ArgumentError) - lambda { Process.spawn([:a]) }.should raise_error(ArgumentError) - lambda { Process.spawn([:a, :b, :c]) }.should raise_error(ArgumentError) + -> { Process.spawn([]) }.should raise_error(ArgumentError) + -> { Process.spawn([:a]) }.should raise_error(ArgumentError) + -> { Process.spawn([:a, :b, :c]) }.should raise_error(ArgumentError) end it "raises an ArgumentError if the Strings in the Array include a null byte" do - lambda { Process.spawn ["\000", "echo"] }.should raise_error(ArgumentError) - lambda { Process.spawn ["echo", "\000"] }.should raise_error(ArgumentError) + -> { Process.spawn ["\000", "echo"] }.should raise_error(ArgumentError) + -> { Process.spawn ["echo", "\000"] }.should raise_error(ArgumentError) end it "raises a TypeError if an element in the Array does not respond to #to_str" do - lambda { Process.spawn ["echo", :echo] }.should raise_error(TypeError) - lambda { Process.spawn [:echo, "echo"] }.should raise_error(TypeError) + -> { Process.spawn ["echo", :echo] }.should raise_error(TypeError) + -> { Process.spawn [:echo, "echo"] }.should raise_error(TypeError) end end @@ -238,19 +238,19 @@ describe "Process.spawn" do end it "raises an ArgumentError if an environment key includes an equals sign" do - lambda do + -> do Process.spawn({"FOO=" => "BAR"}, "echo #{@var}>#{@name}") end.should raise_error(ArgumentError) end it "raises an ArgumentError if an environment key includes a null byte" do - lambda do + -> do Process.spawn({"\000" => "BAR"}, "echo #{@var}>#{@name}") end.should raise_error(ArgumentError) end it "raises an ArgumentError if an environment value includes a null byte" do - lambda do + -> do Process.spawn({"FOO" => "\000"}, "echo #{@var}>#{@name}") end.should raise_error(ArgumentError) end @@ -294,25 +294,25 @@ describe "Process.spawn" do platform_is_not :windows do it "joins the current process group by default" do - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)")) end.should output_to_fd(Process.getpgid(Process.pid).to_s) end it "joins the current process if pgroup: false" do - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: false) end.should output_to_fd(Process.getpgid(Process.pid).to_s) end it "joins the current process if pgroup: nil" do - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: nil) end.should output_to_fd(Process.getpgid(Process.pid).to_s) end it "joins a new process group if pgroup: true" do - process = lambda do + process = -> do Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: true) end @@ -321,7 +321,7 @@ describe "Process.spawn" do end it "joins a new process group if pgroup: 0" do - process = lambda do + process = -> do Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: 0) end @@ -331,23 +331,23 @@ describe "Process.spawn" do it "joins the specified process group if pgroup: pgid" do pgid = Process.getpgid(Process.pid) - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: pgid) end.should output_to_fd(pgid.to_s) end it "raises an ArgumentError if given a negative :pgroup option" do - lambda { Process.spawn("echo", pgroup: -1) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", pgroup: -1) }.should raise_error(ArgumentError) end it "raises a TypeError if given a symbol as :pgroup option" do - lambda { Process.spawn("echo", pgroup: :true) }.should raise_error(TypeError) + -> { Process.spawn("echo", pgroup: :true) }.should raise_error(TypeError) end end platform_is :windows do it "raises an ArgumentError if given :pgroup option" do - lambda { Process.spawn("echo", pgroup: false) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", pgroup: false) }.should raise_error(ArgumentError) end end @@ -358,7 +358,7 @@ describe "Process.spawn" do # :chdir it "uses the current working directory as its working directory" do - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print Dir.pwd")) end.should output_to_fd(Dir.pwd) end @@ -374,7 +374,7 @@ describe "Process.spawn" do end it "changes to the directory passed for :chdir" do - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print Dir.pwd"), chdir: @dir) end.should output_to_fd(@dir) end @@ -383,7 +383,7 @@ describe "Process.spawn" do dir = mock("spawn_to_path") dir.should_receive(:to_path).and_return(@dir) - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print Dir.pwd"), chdir: dir) end.should output_to_fd(@dir) end @@ -424,7 +424,7 @@ describe "Process.spawn" do sleep(1) children.each do |child| - lambda do + -> do Process.kill("TERM", child) end.should raise_error(Errno::ESRCH) end @@ -436,14 +436,14 @@ describe "Process.spawn" do # :umask it "uses the current umask by default" do - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print File.umask")) end.should output_to_fd(File.umask.to_s) end platform_is_not :windows do it "sets the umask if given the :umask option" do - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print File.umask"), umask: 146) end.should output_to_fd("146") end @@ -453,7 +453,7 @@ describe "Process.spawn" do it "redirects STDOUT to the given file descriptor if out: Fixnum" do File.open(@name, 'w') do |file| - lambda do + -> do Process.wait Process.spawn("echo glark", out: file.fileno) end.should output_to_fd("glark\n", file) end @@ -461,7 +461,7 @@ describe "Process.spawn" do it "redirects STDOUT to the given file if out: IO" do File.open(@name, 'w') do |file| - lambda do + -> do Process.wait Process.spawn("echo glark", out: file) end.should output_to_fd("glark\n", file) end @@ -479,7 +479,7 @@ describe "Process.spawn" do it "redirects STDERR to the given file descriptor if err: Fixnum" do File.open(@name, 'w') do |file| - lambda do + -> do Process.wait Process.spawn("echo glark>&2", err: file.fileno) end.should output_to_fd("glark\n", file) end @@ -487,7 +487,7 @@ describe "Process.spawn" do it "redirects STDERR to the given file descriptor if err: IO" do File.open(@name, 'w') do |file| - lambda do + -> do Process.wait Process.spawn("echo glark>&2", err: file) end.should output_to_fd("glark\n", file) end @@ -500,7 +500,7 @@ describe "Process.spawn" do it "redirects STDERR to child STDOUT if :err => [:child, :out]" do File.open(@name, 'w') do |file| - lambda do + -> do Process.wait Process.spawn("echo glark>&2", :out => file, :err => [:child, :out]) end.should output_to_fd("glark\n", file) end @@ -508,7 +508,7 @@ describe "Process.spawn" do it "redirects both STDERR and STDOUT to the given file descriptor" do File.open(@name, 'w') do |file| - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print(:glark); STDOUT.flush; STDERR.print(:bang)"), [:out, :err] => file.fileno) end.should output_to_fd("glarkbang", file) @@ -517,7 +517,7 @@ describe "Process.spawn" do it "redirects both STDERR and STDOUT to the given IO" do File.open(@name, 'w') do |file| - lambda do + -> do Process.wait Process.spawn(ruby_cmd("print(:glark); STDOUT.flush; STDERR.print(:bang)"), [:out, :err] => file) end.should output_to_fd("glarkbang", file) @@ -626,35 +626,35 @@ describe "Process.spawn" do # error handling it "raises an ArgumentError if passed no command arguments" do - lambda { Process.spawn }.should raise_error(ArgumentError) + -> { Process.spawn }.should raise_error(ArgumentError) end it "raises an ArgumentError if passed env or options but no command arguments" do - lambda { Process.spawn({}) }.should raise_error(ArgumentError) + -> { Process.spawn({}) }.should raise_error(ArgumentError) end it "raises an ArgumentError if passed env and options but no command arguments" do - lambda { Process.spawn({}, {}) }.should raise_error(ArgumentError) + -> { Process.spawn({}, {}) }.should raise_error(ArgumentError) end it "raises an Errno::ENOENT for an empty string" do - lambda { Process.spawn "" }.should raise_error(Errno::ENOENT) + -> { Process.spawn "" }.should raise_error(Errno::ENOENT) end it "raises an Errno::ENOENT if the command does not exist" do - lambda { Process.spawn "nonesuch" }.should raise_error(Errno::ENOENT) + -> { Process.spawn "nonesuch" }.should raise_error(Errno::ENOENT) 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 - lambda { Process.spawn __FILE__ }.should raise_error(Errno::EACCES) + -> { Process.spawn __FILE__ }.should raise_error(Errno::EACCES) end end platform_is :windows do it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do - lambda { Process.spawn __FILE__ }.should raise_error(SystemCallError) { |e| + -> { Process.spawn __FILE__ }.should raise_error(SystemCallError) { |e| [Errno::EACCES, Errno::ENOEXEC].should include(e.class) } end @@ -662,17 +662,17 @@ describe "Process.spawn" do end it "raises an Errno::EACCES or Errno::EISDIR when passed a directory" do - lambda { Process.spawn File.dirname(__FILE__) }.should raise_error(SystemCallError) { |e| + -> { Process.spawn File.dirname(__FILE__) }.should raise_error(SystemCallError) { |e| [Errno::EACCES, Errno::EISDIR].should include(e.class) } end it "raises an ArgumentError when passed a string key in options" do - lambda { Process.spawn("echo", "chdir" => Dir.pwd) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", "chdir" => Dir.pwd) }.should raise_error(ArgumentError) end it "raises an ArgumentError when passed an unknown option key" do - lambda { Process.spawn("echo", nonesuch: :foo) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", nonesuch: :foo) }.should raise_error(ArgumentError) end platform_is_not :windows, :aix do diff --git a/spec/ruby/core/process/uid_spec.rb b/spec/ruby/core/process/uid_spec.rb index 350779aff3..a068b1a2c1 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 - lambda { Process.uid = Object.new }.should raise_error(TypeError) + -> { Process.uid = Object.new }.should raise_error(TypeError) end as_user do it "raises Errno::ERPERM if run by a non privileged user trying to set the superuser id" do - lambda { (Process.uid = 0)}.should raise_error(Errno::EPERM) + -> { (Process.uid = 0)}.should raise_error(Errno::EPERM) end it "raises Errno::ERPERM if run by a non privileged user trying to set the superuser id from username" do - lambda { Process.uid = "root" }.should raise_error(Errno::EPERM) + -> { Process.uid = "root" }.should raise_error(Errno::EPERM) end end diff --git a/spec/ruby/core/process/wait2_spec.rb b/spec/ruby/core/process/wait2_spec.rb index 4b6491ccd2..6eb7fc6d06 100644 --- a/spec/ruby/core/process/wait2_spec.rb +++ b/spec/ruby/core/process/wait2_spec.rb @@ -30,7 +30,7 @@ describe "Process.wait2" do end it "raises a StandardError if no child processes exist" do - lambda { Process.wait2 }.should raise_error(Errno::ECHILD) - lambda { Process.wait2 }.should raise_error(StandardError) + -> { Process.wait2 }.should raise_error(Errno::ECHILD) + -> { Process.wait2 }.should raise_error(StandardError) end end diff --git a/spec/ruby/core/process/wait_spec.rb b/spec/ruby/core/process/wait_spec.rb index 000ff684d4..f393a99e0f 100644 --- a/spec/ruby/core/process/wait_spec.rb +++ b/spec/ruby/core/process/wait_spec.rb @@ -15,7 +15,7 @@ describe "Process.wait" do end it "raises an Errno::ECHILD if there are no child processes" do - lambda { Process.wait }.should raise_error(Errno::ECHILD) + -> { Process.wait }.should raise_error(Errno::ECHILD) end platform_is_not :windows do @@ -34,7 +34,7 @@ describe "Process.wait" do it "waits for any child process if no pid is given" do pid = Process.spawn(ruby_cmd('exit')) Process.wait.should == pid - lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) end it "waits for a specific child if a pid is given" do @@ -42,14 +42,14 @@ describe "Process.wait" do pid2 = Process.spawn(ruby_cmd('exit')) Process.wait(pid2).should == pid2 Process.wait(pid1).should == pid1 - lambda { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) - lambda { Process.kill(0, pid2) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid2) }.should raise_error(Errno::ESRCH) end it "coerces the pid to an Integer" do pid1 = Process.spawn(ruby_cmd('exit')) Process.wait(mock_int(pid1)).should == pid1 - lambda { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) end # This spec is probably system-dependent. @@ -86,7 +86,7 @@ describe "Process.wait" do it "always accepts flags=0" do pid = Process.spawn(ruby_cmd('exit')) Process.wait(-1, 0).should == pid - lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) end end end diff --git a/spec/ruby/core/process/waitall_spec.rb b/spec/ruby/core/process/waitall_spec.rb index bdc1ea7490..6cf4e32bc9 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 - lambda { Process.waitall(0) }.should raise_error(ArgumentError) + -> { Process.waitall(0) }.should raise_error(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| - lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) } end |