ruby-changes:46847
From: eregon <ko1@a...>
Date: Tue, 30 May 2017 02:56:50 +0900 (JST)
Subject: [ruby-changes:46847] eregon:r58962 (trunk): Clean up a bit the Process.setpriority specs
eregon 2017-05-30 02:56:46 +0900 (Tue, 30 May 2017) New Revision: 58962 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58962 Log: Clean up a bit the Process.setpriority specs Added files: trunk/spec/rubyspec/core/process/fixtures/setpriority.rb Modified files: trunk/spec/rubyspec/core/process/setpriority_spec.rb Index: spec/rubyspec/core/process/setpriority_spec.rb =================================================================== --- spec/rubyspec/core/process/setpriority_spec.rb (revision 58961) +++ spec/rubyspec/core/process/setpriority_spec.rb (revision 58962) @@ -4,18 +4,12 @@ describe "Process.setpriority" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/process/setpriority_spec.rb#L4 platform_is_not :windows do it "sets the scheduling priority for a specified process" do priority = Process.getpriority(Process::PRIO_PROCESS, 0) - IO.popen('-') do |f| - if f - pr = Integer(f.gets) - Integer(f.gets).should == 0 - Integer(f.gets).should == (pr+1) - else - pr = Process.getpriority(Process::PRIO_PROCESS, 0) - p pr - p Process.setpriority(Process::PRIO_PROCESS, 0, (pr + 1)) - p Process.getpriority(Process::PRIO_PROCESS, 0) - end - end + + out = ruby_exe(fixture(__FILE__, "setpriority.rb"), args: "process") + out = out.lines.map { |l| Integer(l) } + pr = out[0] + out.should == [pr, 0, pr+1] + Process.getpriority(Process::PRIO_PROCESS, 0).should == priority end @@ -24,19 +18,12 @@ describe "Process.setpriority" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/process/setpriority_spec.rb#L18 platform_is_not :darwin, :freebsd do it "sets the scheduling priority for a specified process group" do priority = Process.getpriority(Process::PRIO_PGRP, 0) - IO.popen('-') do |f| - if f - pr = Integer(f.gets) - Integer(f.gets).should == 0 - Integer(f.gets).should == (pr+1) - else - Process.setpgrp - pr = Process.getpriority(Process::PRIO_PGRP, 0) - p pr - p Process.setpriority(Process::PRIO_PGRP, 0, pr + 1) - p Process.getpriority(Process::PRIO_PGRP, 0) - end - end + + out = ruby_exe(fixture(__FILE__, "setpriority.rb"), args: "group") + out = out.lines.map { |l| Integer(l) } + pr = out[0] + out.should == [pr, 0, pr+1] + Process.getpriority(Process::PRIO_PGRP, 0).should == priority end end Index: spec/rubyspec/core/process/fixtures/setpriority.rb =================================================================== --- spec/rubyspec/core/process/fixtures/setpriority.rb (nonexistent) +++ spec/rubyspec/core/process/fixtures/setpriority.rb (revision 58962) @@ -0,0 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/process/fixtures/setpriority.rb#L1 +case ARGV[0] +when "process" + which = Process::PRIO_PROCESS +when "group" + Process.setpgrp + which = Process::PRIO_PGRP +end + +priority = Process.getpriority(which, 0) +p priority +p Process.setpriority(which, 0, priority + 1) +p Process.getpriority(which, 0) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/