diff --git a/Manifest.toml b/Manifest.toml new file mode 100644 index 0000000..a8e5454 --- /dev/null +++ b/Manifest.toml @@ -0,0 +1,131 @@ +# This file is machine-generated - editing it directly is not advised + +[[ArgTools]] +git-tree-sha1 = "554913ddb20033409ef608b621e751b7711da0d1" +repo-rev = "master" +repo-url = "https://github.com/JuliaIO/ArgTools.jl" +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +version = "0.1.0" + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[BufferedStreams]] +deps = ["Compat", "Test"] +git-tree-sha1 = "5d55b9486590fdda5905c275bb21ce1f0754020f" +uuid = "e1450e63-4bb3-523b-b2a4-4ffa8c0fd77d" +version = "1.0.0" + +[[Bzip2_jll]] +deps = ["Libdl", "Pkg"] +git-tree-sha1 = "3663bfffede2ef41358b6fc2e1d8a6d50b3c3904" +uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0" +version = "1.0.6+2" + +[[CodecBzip2]] +deps = ["Bzip2_jll", "Libdl", "TranscodingStreams"] +git-tree-sha1 = "2e62a725210ce3c3c2e1a3080190e7ca491f18d7" +uuid = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd" +version = "0.7.2" + +[[Compat]] +deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] +git-tree-sha1 = "48c20c43e157c6eab6cf88326504ec042b05e456" +uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" +version = "3.10.0" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[DelimitedFiles]] +deps = ["Mmap"] +uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" + +[[Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[LibGit2]] +deps = ["Printf"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[LinearAlgebra]] +deps = ["Libdl"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[Pkg]] +deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[SharedArrays]] +deps = ["Distributed", "Mmap", "Random", "Serialization"] +uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[SparseArrays]] +deps = ["LinearAlgebra", "Random"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + +[[Statistics]] +deps = ["LinearAlgebra", "SparseArrays"] +uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" + +[[SuffixArrays]] +git-tree-sha1 = "b31ac8346f44683ffd9a4e66f56c6f94ccda3d09" +uuid = "24f65c1e-0a10-5d3d-8a1f-a83399f3fced" +version = "0.3.0" + +[[Test]] +deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[TranscodingStreams]] +deps = ["Random", "Test"] +git-tree-sha1 = "7c53c35547de1c5b9d46a4797cf6d8253807108c" +uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" +version = "0.9.5" + +[[UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" diff --git a/test/runtests.jl b/test/runtests.jl index 801fe69..5cf9d68 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,6 @@ using Test using BSDiff +using ArgTools using Pkg.Artifacts import bsdiff_classic_jll @@ -9,17 +10,6 @@ import zrl_jll const test_data = artifact"test_data" const FORMATS = sort!(collect(keys(BSDiff.FORMATS))) -readers(file) = [ - f -> f(file), - f -> open(f, file), - f -> open(f, `cat $file`), -] -writers(file) = [ - f -> f(file), - f -> open(f, file, write=true), - f -> open(f, pipeline(`cat`, file), write=true), -] - @testset "BSDiff" begin @testset "API coverage" begin # create new, old and reference patch files @@ -33,20 +23,21 @@ writers(file) = [ fmt = format == nothing ? [] : [:format => format] # check API passing only two paths @testset "2-arg API" begin - for old in readers(old_file), - new in readers(new_file) - patch_file = old() do old; new() do new - bsdiff(old, new; fmt...) - end; end - for patch in readers(patch_file) - new_file′ = old() do old; patch() do patch - bspatch(old, patch; fmt...) - end; end - @test read(new_file′, String) == "Hello, world!" - new_file′ = old() do old; patch() do patch - bspatch(old, patch) # format auto-detected - end; end - @test read(new_file′, String) == "Hello, world!" + arg_readers(old_file) do old + arg_readers(new_file) do new + patch_file = @arg_test old new begin + bsdiff(old, new; fmt...) + end + arg_readers(patch_file) do patch + new_file′ = @arg_test old patch begin + bspatch(old, patch; fmt...) + end + @test read(new_file′, String) == "Hello, world!" + new_file′ = @arg_test old patch begin + bspatch(old, patch) # format auto-detected + end + @test read(new_file′, String) == "Hello, world!" + end end end end @@ -54,45 +45,51 @@ writers(file) = [ @testset "3-arg API" begin patch_file = joinpath(dir, "patch") new_file′ = joinpath(dir, "new′") - for old in readers(old_file), - new in readers(new_file), - patch in writers(patch_file) - old() do old; new() do new; patch() do patch - bsdiff(old, new, patch; fmt...) - end; end; end - for new′ in writers(new_file′), - patch in readers(patch_file) - old() do old; new′() do new′; patch() do patch - bspatch(old, new′, patch; fmt...) - end; end; end - @test read(new_file′, String) == "Hello, world!" - old() do old; new′() do new′; patch() do patch - bspatch(old, new′, patch) # format auto-detected - end; end; end - @test read(new_file′, String) == "Hello, world!" + arg_readers(old_file) do old + arg_writers(patch_file) do patch + arg_readers(new_file) do new + @arg_test old new patch begin + bsdiff(old, new, patch; fmt...) + end + end + end + arg_readers(patch_file) do patch + arg_writers(new_file′) do new′ + @arg_test old new′ patch begin + bspatch(old, new′, patch; fmt...) + end + @test read(new_file′, String) == "Hello, world!" + rm(new_file′) + @arg_test old new′ patch begin + bspatch(old, new′, patch) # format auto-detected + end + @test read(new_file′, String) == "Hello, world!" + end end end end @testset "bsindex API" begin - for old in readers(old_file), - index in writers(index_file) - old() do old; index() do index - bsindex(old, index) - end; end - for index in readers(index_file), - new in readers(new_file) - patch_file = old() do old; index() do index; new() do new - bsdiff((old, index), new; fmt...) - end; end; end - new_file′ = old() do old - bspatch(old, patch_file; fmt...) + arg_readers(old_file) do old + arg_writers(index_file) do index + @arg_test old index begin + bsindex(old, index) end - @test read(new_file′, String) == "Hello, world!" end - # test that 1-arg API makes the same file - index_file′ = old() do old - bsindex(old) + arg_readers(index_file) do index + arg_readers(new_file) do new + patch_file = @arg_test old index new begin + bsdiff((old, index), new; fmt...) + end + arg_readers(patch_file) do patch + new_file′ = @arg_test old patch begin + bspatch(old, patch; fmt...) + end + @test read(new_file′, String) == "Hello, world!" + end + end end + # test that 1-arg API produces same index + index_file′ = @arg_test old bsindex(old) @test read(index_file) == read(index_file′) end end