diff --git a/.travis.yml b/.travis.yml index 462fc04..592f82c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ os: - linux - osx julia: - - 0.6 + - 0.7 + - 1.0 - nightly notifications: email: false diff --git a/REQUIRE b/REQUIRE index 7cd87bc..859ad46 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1 @@ -julia 0.6 -SHA 0.5.3 +julia 0.7 diff --git a/appveyor.yml b/appveyor.yml index 7eb6a73..c2588f1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,16 +1,18 @@ 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" - -## uncomment the following lines to allow failures on nightly julia -## (tests will run but not make your overall status red) -#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" + - julia_version: 0.7 + - julia_version: 1 + - julia_version: nightly + +platform: + - x86 # 32-bit + - x64 # 64-bit + +# # Uncomment the following lines to allow failures on nightly julia +# # (tests will run but not make your overall status red) +# matrix: +# allow_failures: +# - julia_version: nightly branches: only: @@ -24,24 +26,18 @@ notifications: on_build_status_changed: false install: - - ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" -# If there's a newer build queued for the same PR, cancel this one - - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` - https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` - Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` - throw "There are newer queued builds for this pull request, failing early." } -# 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(), \"MD5\"); Pkg.build(\"MD5\")" + - echo "%JL_BUILD_SCRIPT%" + - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" test_script: - - C:\projects\julia\bin\julia -e "Pkg.test(\"MD5\")" + - echo "%JL_TEST_SCRIPT%" + - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" + +# # 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%" diff --git a/src/MD5.jl b/src/MD5.jl index c7a2ebf..ae5d35d 100644 --- a/src/MD5.jl +++ b/src/MD5.jl @@ -1,6 +1,5 @@ module MD5 -# package code goes here using SHA using SHA: lrot, SHA_CTX @@ -14,7 +13,7 @@ include("core.jl") # Our basic function is to process arrays of bytes -function md5(data::T) where T<:Union{Array{UInt8,1},NTuple{N,UInt8} where N} +function md5(data::T) where T<:Union{AbstractVector{UInt8}, NTuple{N,UInt8} where N} ctx = MD5_CTX() update!(ctx, data) return digest!(ctx) @@ -22,7 +21,7 @@ end # AbstractStrings are a pretty handy thing to be able to crunch through -md5(str::AbstractString) = md5(Vector{UInt8}(str)) +md5(str::AbstractString) = md5(codeunits(str)) # Convenience function for IO devices, allows for things like: # open("test.txt") do f @@ -30,7 +29,7 @@ md5(str::AbstractString) = md5(Vector{UInt8}(str)) # done function md5(io::IO, chunk_size=4*1024) ctx = MD5_CTX() - buff = Vector{UInt8}(chunk_size) + buff = Vector{UInt8}(undef, chunk_size) while !eof(io) num_read = readbytes!(io, buff) update!(ctx, buff[1:num_read]) diff --git a/test/nettle.jl b/test/nettle.jl index d29f6d0..b6d8168 100644 --- a/test/nettle.jl +++ b/test/nettle.jl @@ -1,7 +1,11 @@ -import Nettle # redundant imports, so this file can be run standalone -using Base.Test +using Test import MD5 +using Random + + +import Nettle + function test_equal_state(md5_value::MD5.MD5_CTX,nettle_value::Nettle.Hasher) @test nettle_value.state[1:16] == @@ -33,3 +37,4 @@ end end end end + diff --git a/test/runtests.jl b/test/runtests.jl index 5bc4c77..a50aff5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,5 @@ using MD5 -using Base.Test +using Test @testset "String Tests" begin # From the reference https://tools.ietf.org/html/rfc1321 (final page) @@ -14,18 +14,18 @@ using Base.Test end @testset "Different forms of input data consistent" begin - for len in [0,1,10,100,1000] - bytearray = rand(UInt8, len) - str = String(bytearray) - stream = IOBuffer(bytearray) - @test md5(bytearray) == md5(str) + for len in [0,1,10, 100,1000] + bytes = rand(UInt8, len) + str = String(copy(bytes)) # String will take ownership and empty it's array inputs + stream = IOBuffer(bytes) + @test md5(bytes) == md5(str) @test md5(stream) == md5(str) end end @testset "misc" begin @test MD5.digestlen(MD5.MD5_CTX) == length(md5("")) - @test contains(sprint(show, MD5.MD5_CTX()), "MD5") + @test occursin("MD5", sprint(show, MD5.MD5_CTX())) end include("nettle.jl")