From b19c6b3822162c760f994f4aa6058d5a140f6f93 Mon Sep 17 00:00:00 2001 From: Jakob Nybo Nissen Date: Wed, 1 Mar 2023 10:29:53 +0100 Subject: [PATCH 1/2] Remove dependency on Test, Random These dependencies are used in two ways: During testing, and to be used in tests by dependents of TranscodingStreams. The former reason is addressed by moving them to be test-specific dependencies, the latter should ideally be addressed in the dependents themselves. --- Project.toml | 9 +++------ src/TranscodingStreams.jl | 1 - test/codecnoop.jl | 8 ++++---- test/runtests.jl | 7 ++----- {src => test}/testtools.jl | 22 +++++++++++----------- 5 files changed, 20 insertions(+), 27 deletions(-) rename {src => test}/testtools.jl (88%) diff --git a/Project.toml b/Project.toml index 73443af7..0cc323f0 100644 --- a/Project.toml +++ b/Project.toml @@ -2,11 +2,7 @@ name = "TranscodingStreams" uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" license = "MIT" authors = ["Kenta Sato "] -version = "0.9.11" - -[deps] -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +version = "0.10.0" [compat] julia = "1" @@ -17,7 +13,8 @@ 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", "Pkg", "CodecZlib", "CodecXz", "CodecZstd", "CodecBase"] diff --git a/src/TranscodingStreams.jl b/src/TranscodingStreams.jl index e1d96946..7ebf3534 100644 --- a/src/TranscodingStreams.jl +++ b/src/TranscodingStreams.jl @@ -16,6 +16,5 @@ include("stream.jl") include("io.jl") include("noop.jl") include("transcode.jl") -include("testtools.jl") end # module diff --git a/test/codecnoop.jl b/test/codecnoop.jl index b95e9a79..5c87bde0 100644 --- a/test/codecnoop.jl +++ b/test/codecnoop.jl @@ -196,10 +196,10 @@ @test transcode(Noop(), data) == data @test 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)) diff --git a/test/runtests.jl b/test/runtests.jl index 9f5bd94c..e9fe7284 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,6 +2,8 @@ using TranscodingStreams using Test using Pkg +include("testtools.jl") + # Tool tests # ---------- @@ -121,8 +123,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 diff --git a/src/testtools.jl b/test/testtools.jl similarity index 88% rename from src/testtools.jl rename to test/testtools.jl index c02cca8e..387cceb8 100644 --- a/src/testtools.jl +++ b/test/testtools.jl @@ -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 @@ -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) @@ -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))) @@ -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[]) @@ -92,20 +92,20 @@ 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]) @@ -113,5 +113,5 @@ function test_chunked_write(Encoder, Decoder) Test.@test ok close(stream) end - finalize(encoder) + TranscodingStreams.finalize(encoder) end From c174ea38409497f1faea63895a7713694397b056 Mon Sep 17 00:00:00 2001 From: Jakob Nybo Nissen Date: Wed, 1 Mar 2023 10:43:08 +0100 Subject: [PATCH 2/2] Remove downstream tests in TS tests --- Project.toml | 7 +------ test/REQUIRE | 4 ---- test/runtests.jl | 1 - 3 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 test/REQUIRE diff --git a/Project.toml b/Project.toml index 0cc323f0..27a6451d 100644 --- a/Project.toml +++ b/Project.toml @@ -8,13 +8,8 @@ version = "0.10.0" julia = "1" [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", "Random", "Pkg", "CodecZlib", "CodecXz", "CodecZstd", "CodecBase"] +test = ["Test", "Random"] diff --git a/test/REQUIRE b/test/REQUIRE deleted file mode 100644 index ce62955c..00000000 --- a/test/REQUIRE +++ /dev/null @@ -1,4 +0,0 @@ -CodecZlib 0.4 -CodecXz 0.4 -CodecZstd 0.4 -CodecBase 0.1 diff --git a/test/runtests.jl b/test/runtests.jl index e9fe7284..fea9e5e9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,5 @@ using TranscodingStreams using Test -using Pkg include("testtools.jl")