This repository has been archived by the owner. It is now read-only.
elixir-git / xgit Public archive
Xgit.Util.UnzipStream: No code coverage for zlib :continue case #50
Labels
Comments
Haven't tested yet myself, but I think if you take the compressed binary, and splitt it into 2 parts and only throw the 1st part into Here's an example: # generate a random large file
$ dd if=/dev/urandom of=largefile.txt bs=1048576 count=10
$ gzip largefile.txt
# => largefile.txt.gz defmodule Test do
@windowbits 15 + 32 # automatically detect headers and deflate
@stream_bytes 50
def decompress(file) do
z = :zlib.open()
:zlib.inflateInit(z, @windowbits)
binary = file |> File.stream!([], @stream_bytes) |> Enum.take(1000)
loop(z, :zlib.safeInflate(z, binary))
end
def loop(z, {:continue, _incomplete_decompressed_binary}) do
# wait in a holding pattern until we get more binary
IO.puts "waiting for more data"
loop(z, :zlib.safeInflate(z, []))
end
def loop(z, {:finished, decompressed_data}) do
IO.puts "done"
:zlib.close(z)
decompressed_data
end
end
Test.decompress("largefile.txt.gz")
#=> waiting for more data
#=> waiting for more data
#=> waiting for more data
#=> done
#=> [
<<150, 228, 216, 236, 53, 47, 20, 62, 248, 185, 65, 227, 173, 63, 163, 31,
248, 207, 252, 79, 134, 34, 193, 185, 23, 122, 23, 62, 250, 7, 241, 229,
126, 251, 192, 135, 139, 173, 68, 132, 79, 67, 7, 250, 100, 252, 167, 228,
245, ...>>
] This may be a good place to start for understanding how to write a test to cover |
@dbernheisel thank you, that looks like a promising lead! |
scouten
added a commit
that referenced
this issue
Aug 19, 2019
Closes #50. Thank you to @dbernheisel for the idea for how to accomplish this.
Confirmed. Fix coming soon. Thank you! |
6 tasks
scouten
added a commit
that referenced
this issue
Aug 19, 2019
Closes #50. Thank you to @dbernheisel for the idea for how to accomplish this.
Closed by #104. Will be included in a new release soon. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the Bug
In
Xgit.Util.UnzipStream.process_all_data/3
the case where:zlib.safeInflate/2
returns{:continue, data}
is not reachable by any test data I've been able to construct.Steps to Reproduce😉
If I knew …
The text was updated successfully, but these errors were encountered: