Clean up a bit the Process.setpriority specs

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-05-29 17:56:46 +00:00
Родитель a578c375ad
Коммит f35c3a5498
2 изменённых файлов: 24 добавлений и 25 удалений

Просмотреть файл

@ -0,0 +1,12 @@
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)

Просмотреть файл

@ -4,18 +4,12 @@ describe "Process.setpriority" do
platform_is_not :windows do platform_is_not :windows do
it "sets the scheduling priority for a specified process" do it "sets the scheduling priority for a specified process" do
priority = Process.getpriority(Process::PRIO_PROCESS, 0) priority = Process.getpriority(Process::PRIO_PROCESS, 0)
IO.popen('-') do |f|
if f out = ruby_exe(fixture(__FILE__, "setpriority.rb"), args: "process")
pr = Integer(f.gets) out = out.lines.map { |l| Integer(l) }
Integer(f.gets).should == 0 pr = out[0]
Integer(f.gets).should == (pr+1) out.should == [pr, 0, 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
Process.getpriority(Process::PRIO_PROCESS, 0).should == priority Process.getpriority(Process::PRIO_PROCESS, 0).should == priority
end end
@ -24,19 +18,12 @@ describe "Process.setpriority" do
platform_is_not :darwin, :freebsd do platform_is_not :darwin, :freebsd do
it "sets the scheduling priority for a specified process group" do it "sets the scheduling priority for a specified process group" do
priority = Process.getpriority(Process::PRIO_PGRP, 0) priority = Process.getpriority(Process::PRIO_PGRP, 0)
IO.popen('-') do |f|
if f out = ruby_exe(fixture(__FILE__, "setpriority.rb"), args: "group")
pr = Integer(f.gets) out = out.lines.map { |l| Integer(l) }
Integer(f.gets).should == 0 pr = out[0]
Integer(f.gets).should == (pr+1) out.should == [pr, 0, 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
Process.getpriority(Process::PRIO_PGRP, 0).should == priority Process.getpriority(Process::PRIO_PGRP, 0).should == priority
end end
end end