Skip to content

Commit

Permalink
Merge pull request #8822 from straight-shoota/fix/win32-io-specs
Browse files Browse the repository at this point in the history
Enable IO specs on win32
  • Loading branch information
straight-shoota authored Feb 20, 2020
2 parents a20216d + e5ca5d5 commit 32a2dc6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions spec/std/io/buffered_spec.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec"
require "../spec_helper"

private class BufferedWrapper < IO
include IO::Buffered
Expand Down Expand Up @@ -416,7 +416,7 @@ describe "IO::Buffered" do
io.read_char.should eq('b')
end

describe "encoding" do
pending_win32 describe: "encoding" do
describe "decode" do
it "gets_to_end" do
str = "Hello world" * 200
Expand Down
16 changes: 10 additions & 6 deletions spec/std/io/io_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require "../spec_helper"
require "big"
{% unless flag?(:win32) %}
require "big"
{% end %}
require "base64"

# This is a non-optimized version of IO::Memory so we can test
Expand Down Expand Up @@ -80,7 +82,7 @@ end

describe IO do
describe "partial read" do
it "doesn't block on first read. blocks on 2nd read" do
pending_win32 "doesn't block on first read. blocks on 2nd read" do
IO.pipe do |read, write|
write.puts "hello"
slice = Bytes.new 1024
Expand Down Expand Up @@ -494,7 +496,7 @@ describe IO do
end
end

describe "encoding" do
pending_win32 describe: "encoding" do
describe "decode" do
it "gets_to_end" do
str = "Hello world" * 200
Expand Down Expand Up @@ -843,7 +845,7 @@ describe IO do
end
end

describe "#close" do
pending_win32 describe: "#close" do
it "aborts 'read' in a different thread" do
ch = Channel(Symbol).new(1)

Expand Down Expand Up @@ -889,6 +891,8 @@ describe IO do
end
end

typeof(STDIN.cooked { })
typeof(STDIN.cooked!)
{% unless flag?(:win32) %}
typeof(STDIN.cooked { })
typeof(STDIN.cooked!)
{% end %}
end
4 changes: 2 additions & 2 deletions spec/std/io/memory_spec.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec"
require "../spec_helper"

describe IO::Memory do
it "writes" do
Expand Down Expand Up @@ -373,7 +373,7 @@ describe IO::Memory do
io.gets_to_end.should eq("")
end

describe "encoding" do
pending_win32 describe: "encoding" do
describe "decode" do
it "gets_to_end" do
str = "Hello world" * 200
Expand Down
6 changes: 3 additions & 3 deletions spec/win32_std_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ require "./std/indexable_spec.cr"
require "./std/ini_spec.cr"
require "./std/int_spec.cr"
require "./std/io/argf_spec.cr"
# require "./std/io/buffered_spec.cr" (failed codegen)
require "./std/io/buffered_spec.cr"
require "./std/io/byte_format_spec.cr"
require "./std/io/delimited_spec.cr"
require "./std/io/hexdump_spec.cr"
# require "./std/io/io_spec.cr" (failed codegen)
# require "./std/io/memory_spec.cr" (failed codegen)
require "./std/io/io_spec.cr"
require "./std/io/memory_spec.cr"
require "./std/io/multi_writer_spec.cr"
require "./std/io/sized_spec.cr"
require "./std/io/stapled_spec.cr"
Expand Down
2 changes: 1 addition & 1 deletion src/crystal/system/win32/file_descriptor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module Crystal::System::FileDescriptor
end
{% else %}
# dup doesn't copy the CLOEXEC flag, copy it manually to the new
if LibC.dup2(other.fd, self.fd) == -1
if LibC._dup2(other.fd, self.fd) == -1
raise Errno.new("Could not reopen file descriptor")
end

Expand Down
1 change: 1 addition & 0 deletions src/lib_c/x86_64-windows-msvc/c/io.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ lib LibC
fun _chsize(fd : Int, size : Long) : Int
fun _get_osfhandle(fd : Int) : IntPtrT
fun _pipe(pfds : Int*, psize : UInt, textmode : Int) : Int
fun _dup2(fd1 : Int, fd2 : Int) : Int
end

0 comments on commit 32a2dc6

Please sign in to comment.