1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
* Specs added by TruffleRuby.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2018-06-13 21:58:54 +00:00
parent 5b55eaa00d
commit b46da8d84e
24 changed files with 812 additions and 57 deletions

View file

@ -109,8 +109,8 @@ describe "File.expand_path" do
File.expand_path(Dir.pwd).should == Dir.pwd
File.expand_path('~/').should == @home
File.expand_path('~/..badfilename').should == "#{@home}/..badfilename"
File.expand_path('..').should == Dir.pwd.split('/')[0...-1].join("/")
File.expand_path('~/a','~/b').should == "#{@home}/a"
File.expand_path('..').should == File.dirname(Dir.pwd)
end
it "does not replace multiple '/' at the beginning of the path" do

View file

@ -5,17 +5,11 @@ module FileSpecs
@file = tmp("test.txt")
@dir = Dir.pwd
@fifo = tmp("test_fifo")
@link = tmp("test_link")
platform_is_not :windows do
@block = `find /dev /devices -type b 2> /dev/null`.split("\n").first
@char = `{ tty || find /dev /devices -type c; } 2> /dev/null`.split("\n").last
%w[/dev /usr/bin /usr/local/bin].each do |dir|
links = `find #{dir} -type l 2> /dev/null`.split("\n")
next if links.empty?
@link = links.first
break
end
@block = `find /dev /devices -type b 2>/dev/null`.split("\n").first
@char = `{ tty || find /dev /devices -type c; } 2>/dev/null`.split("\n").last
end
@configured = true
@ -32,24 +26,29 @@ module FileSpecs
yield @dir
end
# TODO: need a platform-independent helper here
def self.fifo
system "mkfifo #{@fifo} 2> /dev/null"
File.mkfifo(@fifo)
yield @fifo
ensure
rm_r @fifo
end
def self.block_device
raise "Could not find a block device" unless @block
yield @block
end
def self.character_device
raise "Could not find a character device" unless @char
yield @char
end
def self.symlink
touch(@file)
File.symlink(@file, @link)
yield @link
ensure
rm_r @file, @link
end
def self.socket
@ -57,8 +56,11 @@ module FileSpecs
name = tmp("ftype_socket.socket")
rm_r name
socket = UNIXServer.new name
yield name
socket.close
rm_r name
begin
yield name
ensure
socket.close
rm_r name
end
end
end

View file

@ -604,7 +604,7 @@ describe "File.open" do
describe "on a FIFO" do
before :each do
@fifo = tmp("File_open_fifo")
system "mkfifo #{@fifo}"
File.mkfifo(@fifo)
end
after :each do

View file

@ -22,7 +22,7 @@ describe "File.pipe?" do
platform_is_not :windows do
it "returns true if the file is a pipe" do
filename = tmp("i_am_a_pipe")
system "mkfifo #{filename}"
File.mkfifo(filename)
File.pipe?(filename).should == true

View file

@ -20,7 +20,7 @@ describe "File::Stat#pipe?" do
platform_is_not :windows do
it "returns true if the file is a pipe" do
filename = tmp("i_am_a_pipe")
system "mkfifo #{filename}"
File.mkfifo(filename)
st = File.stat(filename)
st.pipe?.should == true