Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add basic spec for opening a FIFO. #103

Merged
merged 1 commit into from

1 participant

@headius

This isn't the greatest spec, but it covers some basics of opening a FIFO. Had trouble with blocking .open on some impls, and I know this is also doing sysreads, but I'm not sure how to verify the FIFO has been opened and is working correctly.

@headius headius merged commit 7648fd6 into rubyspec:master
@eregon eregon deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 2, 2012
  1. @headius
This page is out of date. Refresh to see the latest.
Showing with 35 additions and 0 deletions.
  1. +35 −0 core/file/open_spec.rb
View
35 core/file/open_spec.rb
@@ -523,6 +523,41 @@
ruby_version_is "1.9" do
it "needs to be completed for hash argument"
end
+
+ platform_is_not :windows do
+ if `which mkfifo`.chomp != ""
+ describe "on a FIFO" do
+ before :each do
+ @fifo = tmp("File_open_fifo")
+ system "mkfifo #{@fifo}"
+ end
+
+ after :each do
+ rm_r @fifo
+ end
+
+ it "opens it as a normal file" do
+ file_w, file_r, read_bytes, written_length = nil
+
+ # open in threads, due to blocking open and writes
+ Thread.new do
+ file_w = File.open(@fifo, 'w')
+ written_length = file_w.syswrite('hello')
+ end
+ Thread.new do
+ file_r = File.open(@fifo, 'r')
+ read_bytes = file_r.sysread(5)
+ end
+
+ Thread.pass until read_bytes && written_length
+
+ written_length.should == 5
+ read_bytes.should == 'hello'
+ end
+ end
+ end
+ end
+
end
describe "File.open" do
Something went wrong with that request. Please try again.