Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change: Remove test facilities for downstream users #133

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "TranscodingStreams"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
license = "MIT"
authors = ["Kenta Sato <[email protected]>"]
version = "0.9.13"
version = "0.10.0"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -12,12 +12,8 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
julia = "1.6"

[extras]
CodecBase = "6c391c72-fb7b-5838-ba82-7cfb1bcfecbf"
CodecXz = "ba30903b-d9e8-5048-a5ec-d1f5b0d4b47b"
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
CodecZstd = "6b39b394-51ab-5f42-8807-6242bab2b4c2"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Pkg", "CodecZlib", "CodecXz", "CodecZstd", "CodecBase"]
test = ["Test", "Random"]
1 change: 0 additions & 1 deletion src/TranscodingStreams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ include("stream.jl")
include("io.jl")
include("noop.jl")
include("transcode.jl")
include("testtools.jl")

end # module
4 changes: 0 additions & 4 deletions test/REQUIRE

This file was deleted.

8 changes: 4 additions & 4 deletions test/codecnoop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@
data = "foo"
@test String(transcode(Noop, data)) == data

TranscodingStreams.test_roundtrip_transcode(Noop, Noop)
TranscodingStreams.test_roundtrip_read(NoopStream, NoopStream)
TranscodingStreams.test_roundtrip_write(NoopStream, NoopStream)
TranscodingStreams.test_roundtrip_lines(NoopStream, NoopStream)
test_roundtrip_transcode(Noop, Noop)
test_roundtrip_read(NoopStream, NoopStream)
test_roundtrip_write(NoopStream, NoopStream)
test_roundtrip_lines(NoopStream, NoopStream)

# switch write => read
stream = NoopStream(IOBuffer(b"foobar", read=true, write=true))
Expand Down
8 changes: 2 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using TranscodingStreams
using Test
using Pkg

include("testtools.jl")

if VERSION ≥ v"1.1"
@test isempty(detect_unbound_args(TranscodingStreams; recursive=true))
Expand Down Expand Up @@ -126,8 +127,3 @@ end
include("codecnoop.jl")
include("codecinvalid.jl")
include("codecquadruple.jl")

# Test third-party codec packages.
for pkg in ["CodecZlib", "CodecXz", "CodecZstd", "CodecBase"]
Pkg.test(pkg)
end
22 changes: 11 additions & 11 deletions src/testtools.jl → test/testtools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function test_roundtrip_write(encoder, decoder)
data = rand(alpha, n)
file = IOBuffer()
stream = encoder(decoder(file))
write(stream, data, TOKEN_END); flush(stream)
write(stream, data, TranscodingStreams.TOKEN_END); flush(stream)
Test.@test hash(take!(file)) == hash(data)
close(stream)
end
Expand All @@ -32,16 +32,16 @@ end
function test_roundtrip_transcode(encode, decode)
seed!(TEST_RANDOM_SEED)
encoder = encode()
initialize(encoder)
TranscodingStreams.initialize(encoder)
decoder = decode()
initialize(decoder)
TranscodingStreams.initialize(decoder)
for n in vcat(0:30, sort!(rand(500:100_000, 30))), alpha in (0x00:0xff, 0x00:0x0f)
data = rand(alpha, n)
Test.@test hash(transcode(decode, transcode(encode, data))) == hash(data)
Test.@test hash(transcode(decoder, transcode(encoder, data))) == hash(data)
end
finalize(encoder)
finalize(decoder)
TranscodingStreams.finalize(encoder)
TranscodingStreams.finalize(decoder)
end

function test_roundtrip_lines(encoder, decoder)
Expand All @@ -54,7 +54,7 @@ function test_roundtrip_lines(encoder, decoder)
println(stream, line)
push!(lines, line)
end
write(stream, TOKEN_END)
write(stream, TranscodingStreams.TOKEN_END)
flush(stream)
seekstart(buf)
Test.@test hash(lines) == hash(readlines(decoder(buf)))
Expand All @@ -78,7 +78,7 @@ function test_chunked_read(Encoder, Decoder)
seed!(TEST_RANDOM_SEED)
alpha = b"色即是空"
encoder = Encoder()
initialize(encoder)
TranscodingStreams.initialize(encoder)
for _ in 1:500
chunks = [rand(alpha, rand(0:100)) for _ in 1:rand(1:100)]
data = mapfoldl(x->transcode(encoder, x), vcat, chunks, init=UInt8[])
Expand All @@ -92,26 +92,26 @@ function test_chunked_read(Encoder, Decoder)
end
Test.@test ok
end
finalize(encoder)
TranscodingStreams.finalize(encoder)
end

function test_chunked_write(Encoder, Decoder)
seed!(TEST_RANDOM_SEED)
alpha = b"空即是色"
encoder = Encoder()
initialize(encoder)
TranscodingStreams.initialize(encoder)
for _ in 1:500
chunks = [rand(alpha, rand(0:100)) for _ in 1:2]
data = map(x->transcode(encoder, x), chunks)
buffer = IOBuffer()
stream = TranscodingStream(Decoder(), buffer, stop_on_end=true)
write(stream, vcat(data...))
write(stream, vcat(data...))Test
flush(stream)
ok = true
ok &= hash(take!(buffer)) == hash(chunks[1])
ok &= buffersize(stream.state.buffer1) == length(data[2])
Test.@test ok
close(stream)
end
finalize(encoder)
TranscodingStreams.finalize(encoder)
end