Skip to content

Commit

Permalink
Fix deprecations and test on nightly
Browse files Browse the repository at this point in the history
deprecation warning test was failing due to bold control characters
  • Loading branch information
tkelman authored and stevengj committed Jan 21, 2017
1 parent 519ded1 commit 0c6b85a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
julia 0.4
BinDeps 0.3.21
@osx Homebrew
Compat 0.8.0
Compat 0.9.5
@windows WinRPM
12 changes: 6 additions & 6 deletions src/ZMQ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type Context
if p == C_NULL
throw(StateError(jl_zmq_error_str()))
end
zctx = new(p, Array(Socket,0))
zctx = new(p, Socket[])
finalizer(zctx, close)
return zctx
end
Expand Down Expand Up @@ -418,7 +418,7 @@ end
isfreed(m::Message) = haskey(gc_protect, m.handle)

# AbstractArray behaviors:
similar(a::Message, T, dims::Dims) = Array(T, dims) # ?
similar(a::Message, T, dims::Dims) = Array{T}(dims) # ?
length(zmsg::Message) = @compat Int(ccall((:zmq_msg_size, zmq), Csize_t, (Ptr{Message},), &zmsg))
size(zmsg::Message) = (length(zmsg),)
unsafe_convert(::Type{Ptr{UInt8}}, zmsg::Message) = ccall((:zmq_msg_data, zmq), Ptr{UInt8}, (Ptr{Message},), &zmsg)
Expand Down Expand Up @@ -571,11 +571,11 @@ const FORWARDER = 2
const QUEUE = 3

function __init__()
major = Array(Cint,1)
minor = Array(Cint,1)
patch = Array(Cint,1)
major = Ref{Cint}()
minor = Ref{Cint}()
patch = Ref{Cint}()
ccall((:zmq_version, zmq), Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), major, minor, patch)
global const version = VersionNumber(major[1], minor[1], patch[1])
global const version = VersionNumber(major[], minor[], patch[])
if version < v"3"
error("ZMQ version $version < 3 is not supported")
end
Expand Down
5 changes: 4 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ ZMQ.send(s2, Message("another test request"))
msg = ZMQ.recv(s1)
o=convert(IOStream, msg)
seek(o, 0)
@assert (takebuf_string(o)=="another test request")
@assert (String(take!(o))=="another test request")

ZMQ.close(s1)
ZMQ.close(s2)
ZMQ.close(ctx2)

# deprecate bytestring(::Message)
let olderr = STDERR
old_have_color = Base.have_color
eval(Base, :(have_color = false)) # avoid control characters in output
rderr, wrerr = redirect_stderr()
reader = @async readstring(rderr)
@assert bytestring(Message("hello")) == "hello"
Expand All @@ -94,4 +96,5 @@ let olderr = STDERR
else
@assert contains(wait(reader), "WARNING: bytestring(zmsg::Message) is deprecated")
end
eval(Base, :(have_color = $old_have_color)) # avoid control characters in output
end

0 comments on commit 0c6b85a

Please sign in to comment.