aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/file
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-13 21:58:54 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-13 21:58:54 +0000
commitb46da8d84efeb97cb52ba0560d5b149ccda0d561 (patch)
tree382ba848ef97215f1a5ec991727db3ed7f90973c /spec/ruby/core/file
parent5b55eaa00db05004d1a6b74c3aaa5e680fc73235 (diff)
downloadruby-b46da8d84efeb97cb52ba0560d5b149ccda0d561.tar.gz
Update to ruby/spec@4bb0f25
* Specs added by TruffleRuby. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/file')
-rw-r--r--spec/ruby/core/file/expand_path_spec.rb2
-rw-r--r--spec/ruby/core/file/fixtures/file_types.rb30
-rw-r--r--spec/ruby/core/file/open_spec.rb2
-rw-r--r--spec/ruby/core/file/pipe_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/pipe_spec.rb2
5 files changed, 20 insertions, 18 deletions
diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb
index 9d08cbb02b..99279aec85 100644
--- a/spec/ruby/core/file/expand_path_spec.rb
+++ b/spec/ruby/core/file/expand_path_spec.rb
@@ -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
diff --git a/spec/ruby/core/file/fixtures/file_types.rb b/spec/ruby/core/file/fixtures/file_types.rb
index 397cac9b6b..a36817fb4e 100644
--- a/spec/ruby/core/file/fixtures/file_types.rb
+++ b/spec/ruby/core/file/fixtures/file_types.rb
@@ -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
diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb
index 6ccac75a9a..a22a856dd9 100644
--- a/spec/ruby/core/file/open_spec.rb
+++ b/spec/ruby/core/file/open_spec.rb
@@ -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
diff --git a/spec/ruby/core/file/pipe_spec.rb b/spec/ruby/core/file/pipe_spec.rb
index 64e6fce09a..01d72dbe85 100644
--- a/spec/ruby/core/file/pipe_spec.rb
+++ b/spec/ruby/core/file/pipe_spec.rb
@@ -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
diff --git a/spec/ruby/core/file/stat/pipe_spec.rb b/spec/ruby/core/file/stat/pipe_spec.rb
index 027b40eaaa..7abb6c742a 100644
--- a/spec/ruby/core/file/stat/pipe_spec.rb
+++ b/spec/ruby/core/file/stat/pipe_spec.rb
@@ -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