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

Updates to work with julia v1.0 #18

Merged
merged 3 commits into from Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 19 additions & 30 deletions .appveyor.yml
@@ -1,42 +1,31 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
- julia_version: 0.6
- julia_version: 0.7
- julia_version: 1
- julia_version: nightly

platform:
- x86 # 32-bit
- x64 # 64-bit

matrix:
allow_failures:
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

branches:
only:
- master
- /release-.*/

notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: false
- julia_version: nightly

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo(); Pkg.clone(pwd(), \"CodecLz4\"); Pkg.build(\"CodecLz4\")"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"CodecLz4\"; coverage=true)"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

after_test:
- C:\projects\julia\bin\julia -e "cd(Pkg.dir(\"CodecLz4\")); Pkg.add(\"Coverage\"); using Coverage; Codecov.submit(process_folder())"
# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
25 changes: 22 additions & 3 deletions .travis.yml
Expand Up @@ -5,6 +5,8 @@ os:
- osx
julia:
- 0.6
- 0.7
- 1.0
- nightly
matrix:
allow_failures:
Expand All @@ -14,7 +16,24 @@ notifications:
email: false
script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd()); Pkg.build("CodecLz4"); Pkg.test("CodecLz4"; coverage=true)'
- |
julia --depwarn=error -e '
VERSION >= v"0.7.0-DEV.3656" && using Pkg
if VERSION >= v"0.7.0-DEV.5183" && (isfile("Project.toml") || isfile("JuliaProject.toml"))
Pkg.build(); Pkg.test(coverage=true)
else
Pkg.clone(pwd()); Pkg.build("CodecLz4"); Pkg.test("CodecLz4"; coverage=true)
end'
after_success:
- julia -e 'cd(Pkg.dir("CodecLz4")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
- julia -e 'Pkg.add("Documenter"); cd(Pkg.dir("CodecLz4")); include(joinpath("docs", "make.jl"))'
- |
julia -e '
VERSION >= v"0.7.0-DEV.3656" && using Pkg
VERSION >= v"0.7.0-DEV.5183" || cd(Pkg.dir("CodecLz4"))
Pkg.add("Coverage"); using Coverage
Codecov.submit(process_folder())'
- |
julia -e '
VERSION >= v"0.7.0-DEV.3656" && using Pkg
VERSION >= v"0.7.0-DEV.5183" || cd(Pkg.dir("CodecLz4"))
Pkg.add("Documenter");
include(joinpath("docs", "make.jl"))'
12 changes: 5 additions & 7 deletions deps/build.jl
@@ -1,5 +1,7 @@
using BinDeps
using Compat.Libdl
using Base.Sys: WORD_SIZE
import Compat.Sys
@BinDeps.setup

function validate_lz4(name,handle)
Expand All @@ -11,14 +13,10 @@ liblz4 = library_dependency("liblz4", validate = validate_lz4)

long_version = "1.8.1.2"
short_version = "1.8.1"
zipname = "lz4_v$(replace(short_version, "." => "_"))_win$(Sys.WORD_SIZE).zip"
zipname = "lz4_v$(replace(short_version, "." => "_"))_win$(WORD_SIZE).zip"

suffix = "so.$short_version"

isapple() = VERSION < v"0.7.0" ? Sys.is_apple() : Sys.isapple()
iswindows() = VERSION < v"0.7.0" ? Sys.is_windows() : Sys.iswindows()

if isapple()
if Sys.isapple()
suffix = "$short_version.$(Libdl.dlext)"
end

Expand Down Expand Up @@ -54,7 +52,7 @@ provides(BuildProcess,
end
end), liblz4, os = :Windows)

if iswindows()
if Sys.iswindows()
push!(BinDeps.defaults, BuildProcess)
@BinDeps.install Dict(:liblz4 => :liblz4)
pop!(BinDeps.defaults)
Expand Down
4 changes: 2 additions & 2 deletions src/stream_compression.jl
Expand Up @@ -32,7 +32,7 @@ function LZ4Compressor(; kwargs...)
ctx = Ref{Ptr{LZ4F_cctx}}(C_NULL)
frame = LZ4F_frameInfo_t(; y...)
prefs = Ref(LZ4F_preferences_t(frame; x...))
return LZ4Compressor(ctx, prefs, Memory(Vector{UInt8}(uninitialized, LZ4F_HEADER_SIZE_MAX)), false)
return LZ4Compressor(ctx, prefs, Memory(Vector{UInt8}(undef, LZ4F_HEADER_SIZE_MAX)), false)
end

const LZ4CompressorStream{S} = TranscodingStream{LZ4Compressor,S} where S<:IO
Expand Down Expand Up @@ -83,7 +83,7 @@ Creates the LZ4F header to be written to the output.
"""
function TranscodingStreams.startproc(codec::LZ4Compressor, mode::Symbol, error::Error)::Symbol
try
header = Vector{UInt8}(uninitialized, LZ4F_HEADER_SIZE_MAX)
header = Vector{UInt8}(undef, LZ4F_HEADER_SIZE_MAX)
headerSize = LZ4F_compressBegin(codec.ctx[], header, convert(Csize_t, LZ4F_HEADER_SIZE_MAX), codec.prefs)
codec.header = Memory(resize!(header, headerSize))
codec.write_header = true
Expand Down
20 changes: 10 additions & 10 deletions test/lz4frame.jl
Expand Up @@ -9,14 +9,14 @@ using Compat
no_error = UInt(0)
@test !CodecLz4.LZ4F_isError(no_error)
@test CodecLz4.LZ4F_getErrorName(no_error) == "Unspecified error code"

ERROR_GENERIC = typemax(UInt)
@test CodecLz4.LZ4F_isError(ERROR_GENERIC)
@test CodecLz4.LZ4F_getErrorName(ERROR_GENERIC) == "ERROR_GENERIC"
end

@testset "keywords" begin

frame = CodecLz4.LZ4F_frameInfo_t()
@test frame.blockSizeID == Cuint(default_size)
@test frame.blockMode == Cuint(block_linked)
Expand Down Expand Up @@ -99,7 +99,7 @@ using Compat
dctx = Ref{Ptr{CodecLz4.LZ4F_dctx}}(C_NULL)
srcsize = Ref{Csize_t}(origsize)
dstsize = Ref{Csize_t}(8*1280)
decbuffer = Vector{UInt8}(uninitialized, 1280)
decbuffer = Vector{UInt8}(undef, 1280)

frameinfo = Ref(CodecLz4.LZ4F_frameInfo_t())

Expand Down Expand Up @@ -128,13 +128,13 @@ using Compat
dctx = Ref{Ptr{CodecLz4.LZ4F_dctx}}(C_NULL)
srcsize = Ref{Csize_t}(origsize)
dstsize = Ref{Csize_t}(1280)
decbuffer = Vector{UInt8}(uninitialized, 1280)
decbuffer = Vector{UInt8}(undef, 1280)

frameinfo = Ref(CodecLz4.LZ4F_frameInfo_t())

CodecLz4.LZ4F_createDecompressionContext(dctx, version)

buffer[1:CodecLz4.LZ4F_HEADER_SIZE_MAX] = 0x10
buffer[1:CodecLz4.LZ4F_HEADER_SIZE_MAX] .= 0x10
@test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_getFrameInfo(dctx[], frameinfo, buffer, srcsize)

offset = srcsize[]
Expand All @@ -158,7 +158,7 @@ using Compat
@test bound > 0

bufsize = bound + CodecLz4.LZ4F_HEADER_SIZE_MAX
buffer = Vector{UInt8}(uninitialized, ceil(Int, bound / 8))
buffer = Vector{UInt8}(undef, ceil(Int, bound / 8))

@test_nowarn result = CodecLz4.LZ4F_compressBegin(ctx[], buffer, bufsize, prefs)

Expand Down Expand Up @@ -187,7 +187,7 @@ using Compat
prefs = Ptr{CodecLz4.LZ4F_preferences_t}(C_NULL)

bufsize = test_size
buffer = Vector{UInt8}(uninitialized, test_size)
buffer = Vector{UInt8}(undef, test_size)

@test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_compressBegin(ctx[], buffer, bufsize, prefs)
@test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_compressUpdate(ctx[], pointer(buffer), bufsize, pointer(testIn), test_size, C_NULL)
Expand All @@ -205,7 +205,7 @@ using Compat
@test bound > 0

bufsize = bound + CodecLz4.LZ4F_HEADER_SIZE_MAX
buffer = Vector{UInt8}(uninitialized, ceil(Int, bound / 8))
buffer = Vector{UInt8}(undef, ceil(Int, bound / 8))

@test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_compressBegin(ctx[], buffer, UInt(2), prefs)
@test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_compressUpdate(ctx[], pointer(buffer), bufsize, pointer(testIn), test_size, C_NULL)
Expand Down Expand Up @@ -233,7 +233,7 @@ using Compat
dctx = Ref{Ptr{CodecLz4.LZ4F_dctx}}(C_NULL)
srcsize = Ref{Csize_t}(test_size)
dstsize = Ref{Csize_t}(8*1280)
decbuffer = Vector{UInt8}(uninitialized, 1280)
decbuffer = Vector{UInt8}(undef, 1280)

frameinfo = Ref(CodecLz4.LZ4F_frameInfo_t())
@test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_getFrameInfo(dctx[], frameinfo, pointer(testIn), srcsize)
Expand All @@ -251,7 +251,7 @@ using Compat
@test bound > 0

bufsize = bound + CodecLz4.LZ4F_HEADER_SIZE_MAX
buffer = Vector{UInt8}(uninitialized, ceil(Int, bound / 8))
buffer = Vector{UInt8}(undef, ceil(Int, bound / 8))

@test_nowarn result = CodecLz4.LZ4F_compressBegin(ctx[], buffer, bufsize, prefs)

Expand Down
6 changes: 3 additions & 3 deletions test/stream_compression.jl
Expand Up @@ -55,7 +55,7 @@ end

@testset "Errors" begin
input = Memory(Vector{UInt8}(text))
output = Memory(Vector{UInt8}(uninitialized, 1280))
output = Memory(Vector{UInt8}(undef, 1280))
not_initialized = LZ4Compressor()
@test TranscodingStreams.startproc(not_initialized, :read, Error()) == :error
@test TranscodingStreams.process(not_initialized, input, output, Error()) == (0, 0, :error)
Expand All @@ -68,7 +68,7 @@ end
@test_throws CodecLz4.LZ4Exception read(stream)
@test_throws ArgumentError read(stream)

output = Memory(Vector{UInt8}(uninitialized, 1))
output = Memory(Vector{UInt8}(undef, 1))
compressor = LZ4Compressor()
@test_nowarn TranscodingStreams.initialize(compressor)
@test TranscodingStreams.startproc(compressor, :read, Error()) == :ok
Expand Down Expand Up @@ -108,4 +108,4 @@ end
@test frame.contentSize == Culonglong(100)
@test frame.blockChecksumFlag == Cuint(1)

end
end