Don't use cat command on native Windows

This commit is contained in:
Hiroshi SHIBATA 2024-01-12 18:14:26 +09:00
Родитель 396e94666b
Коммит 80feecd6a3
4 изменённых файлов: 17 добавлений и 9 удалений

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

@ -4,7 +4,8 @@ require_relative 'fixtures/classes'
describe "IO#close_read" do
before :each do
@io = IO.popen 'cat', "r+"
cmd = platform_is(:windows) ? 'rem' : 'cat'
@io = IO.popen cmd, "r+"
@path = tmp('io.close.txt')
end

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

@ -3,7 +3,8 @@ require_relative 'fixtures/classes'
describe "IO#close_write" do
before :each do
@io = IO.popen 'cat', 'r+'
cmd = platform_is(:windows) ? 'rem' : 'cat'
@io = IO.popen cmd, 'r+'
@path = tmp('io.close.txt')
end
@ -48,12 +49,15 @@ describe "IO#close_write" do
io.should.closed?
end
it "flushes and closes the write stream" do
@io.puts '12345'
# Windows didn't have command like cat
platform_is_not :windows do
it "flushes and closes the write stream" do
@io.puts '12345'
@io.close_write
@io.close_write
@io.read.should == "12345\n"
@io.read.should == "12345\n"
end
end
it "does nothing on closed stream" do

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

@ -26,7 +26,8 @@ describe "IO#lineno" do
end
it "raises an IOError on a duplexed stream with the read side closed" do
IO.popen('cat', 'r+') do |p|
cmd = platform_is(:windows) ? 'rem' : 'cat'
IO.popen(cmd, 'r+') do |p|
p.close_read
-> { p.lineno }.should raise_error(IOError)
end
@ -70,7 +71,8 @@ describe "IO#lineno=" do
end
it "raises an IOError on a duplexed stream with the read side closed" do
IO.popen('cat', 'r+') do |p|
cmd = platform_is(:windows) ? 'rem' : 'cat'
IO.popen(cmd, 'r+') do |p|
p.close_read
-> { p.lineno = 0 }.should raise_error(IOError)
end

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

@ -3,7 +3,8 @@ require_relative 'fixtures/classes'
describe "IO#stat" do
before :each do
@io = IO.popen 'cat', "r+"
cmd = platform_is(:windows) ? 'rem' : 'cat'
@io = IO.popen cmd, "r+"
end
after :each do