JuliaIO / GZip.jl

A Julia interface for gzip functions in zlib
https://juliaio.github.io/GZip.jl/dev
MIT License
39 stars 30 forks source link

Pkg.test("GZip") fails on Windows #48

Closed bmharsha closed 6 years ago

bmharsha commented 8 years ago

I'm encountering following error when I run Pkg.test("GZip")

julia> Pkg.test("GZip")
INFO: Testing GZip
ERROR: LoadError: unlink: resource busy or locked (EBUSY)
 in unlink at fs.jl:102
while loading C:\Users\Administrator\.julia\v0.4\GZip\test\runtests.jl, in expression starting on line 27
================================[ ERROR: GZip ]=================================

failed process: Process(`'C:\Users\Administrator\AppData\Local\Julia-0.4.3\bin\julia' --check-bounds=yes --code-coverage=none --color=yes 'C:\Users\Administrator\.julia\v0.4\GZip\test\runtests.jl'`, ProcessExited(1)) [1]

================================================================================

ERROR: GZip had test errors
 in error at error.jl:21

I encountered same error on 3 different Windows systems

All these 3 systems had Julia version 0.4.3

I tested this on following GZip versions

I tried executing the runtests.jl manually, I encountered similar error

julia> include("runtests.jl")
ERROR: LoadError: unlink: resource busy or locked (EBUSY) in unlink at fs.jl:102
while loading C:\Users\julia\.julia\v0.4\GZip\test\runtests.jl, in expression starting on line 27
hustf commented 8 years ago

Same error here, on the tagged version and on master. Julia 0.4.6 and Windows 10 64 bit.

hustf commented 8 years ago

When checking out #41 without rebasing:

julia> Pkg.test("GZip")
INFO: Testing GZip
INFO: Recompiling stale cache file C:\Users\Frøystein\.julia\lib\v0.4\GZip.ji for module GZip.
INFO: Could not find files for the given pattern(s).
ERROR: LoadError: test failed: "using Compat\r\nusing GZip\r\nusing Base.Test\r\n##########################\r\n# test_context(\"GZip tests\")\r\
n##########################\r\n\r\n#for epoch in 1:10\r\n\r\ntmp = mktempdir()\r\ntest_infile = @__FILE__\r\ntest_compressed = joinpath(tmp, \"runtests.jl.gz\")\r\ntest_empty = joinpath(tmp, 
\"empty.jl.gz\")\r\n\r\n@windows_only cmdGunzip=`where gunzip`\r\n@unix_only    cmdGunzip=`which gunzip`\r\ntest_gunzip = true\r\ntry\r\n\t@compat run(pipeline(cmdGunzip, DevNull))\r\ncatch\r\n    
test_gunzip = false\r\nend\r\n\r\ntry\r\n    #########################\r\n    # test_group(\"Compress Test1: gzip.jl\")\r\n    ##########################\r\n\r\n    data = open(readall, test_infile)\r
\n\r\n    first_char = data[1]\r\n\r\n    gzfile = gzopen(test_compressed, \"wb\")\r\n    @test write(gzfile, data) == length(data.data)\r\n    @test close(gzfile) == Z_OK\r\n    @test close(gzfile) != 
Z_OK\r\n\r\n    @test_throws EOFError write(gzfile, data)\r\n\r\n    if test_gunzip\r\n        data2 = readall(`gunzip -c \$test_compressed`)\r\n   
     @test data == data2\r\n    end\r\n\r\n    data3 = gzopen(readall, test_compressed)\r\n    @test data == data3\r\n\r\n    # Test gzfdio\r\n    r
aw_file = open(test_compressed, \"r\")\r\n    @unix_only gzfile = gzdopen(fd(raw_file), \"r\")\r\n    @unix_only data4 = readall(gzfile)\r\n\t@windows_only data4 =\"Can not use gfzdio\"\r\n    
close(gzfile)\r\n    close(raw_file)\r\n    @test data == data4\r\n\r\n    # Test peek\r\n    gzfile = gzopen(test_compressed, \"r\")\r\n    @test peek(gzfile) == first_char\r\n    readall(gzfile)\r\n 
   @test peek(gzfile) == -1\r\n    close(gzfile)\r\n\r\n    # Screw up the file\r\n    raw_file = open(test_compressed, \"r+\")\r\n    seek(raw_file, 3) # leave the gzip magic 2-byte header\r\n   
 write(raw_file, zeros(UInt8, 10))\r\n    close(raw_file)\r\n\r\n    try\r\n        gzopen(readall, test_compressed)\r\n        throw(ErrorException(\"Expecting ArgumentError or similar\"))\r\n  
  catch ex\r\n@compat         @test typeof(ex) <: Union{ArgumentError, ZError, GZError} ||\r\n              contains(ex.msg, \"too many arguments\")\r\n    end\r\n\r\n    ##########################\r\n 
   # test_group(\"gzip file function tests (writing)\")\r\n    ##########################\r\n    gzfile = gzopen(test_compressed, \"wb\")\r\n    write(gzfile, data) == length(data.data)\r\n  
  @test flush(gzfile) == Z_OK\r\n\r\n    NEW = GZip.GZLIB_VERSION > \"1.2.3.9\"\r\n    pos = position(gzfile)\r\n    NEW && (pos2 = position(gzfile,true))\r\n    @test_throws ErrorException 
seek(gzfile, 100)   # can't seek backwards on write\r\n    @test position(gzfile) == pos\r\n    NEW && (@test position(gzfile,true) == pos2)\r\n    @test skip(gzfile, 100)\r\n    @test 
position(gzfile) == pos + 100\r\n    NEW && (@test position(gzfile,true) == pos2)\r\n\r\n    @test_throws MethodError truncate(gzfile, 100)\r\n    @test_throws MethodError seekend(gzfile)\r\n\r\n  
  @test close(gzfile) == Z_OK\r\n\r\n    gzopen(test_empty, \"w\") do io\r\n        a = \"\".data\r\n        @test gzwrite(io, pointer(a), length(a)*sizeof(eltype(a))) == @compat Int32(0)\r\n    
end\r\n\r\n    ##########################\r\n    # test_group(\"gzip file function tests (strategy read/write)\")\r\n    ##########################\r\n\r\n    # rewrite the test file\r\n    
modes = \"fhR \"\r\n    if GZip.ZLIB_VERSION >= (1,2,5,2)\r\n        modes = \"fhRFT \"\r\n    end\r\n    for ch in modes\r\n        if ch == ' '\r\n            ch = \"\"\r\n        end\r\n    
    for level = 0:9\r\n            gzfile = gzopen(test_compressed, \"wb\$level\$ch\")\r\n            @test write(gzfile, data) == length(data.data)\r\n            @test close(gzfile) == Z_OK\r\n\r\n     
       file_size = filesize(test_compressed)\r\n\r\n            #println(\"wb\$level\$ch: \", file_size)\r\n\r\n            if ch == 'T'\r\n                @test(file_size == length(data.data))\r\n   
         elseif level == 0\r\n                @test(file_size > length(data.data))\r\n            else\r\n                @test(file_size < length(data.data))\r\n            end\r\n\r\n          
  # readline test\r\n            gzf = gzopen(test_compressed)\r\n            s = IOBuffer()\r\n            while !eof(gzf)\r\n                write(s, readline(gzf))\r\n            end\r\n      
      data2 = takebuf_string(s);\r\n\r\n            # readuntil test\r\n            seek(gzf, 0)\r\n            while !eof(gzf)\r\n                write(s, readuntil(gzf, 'a'))\r\n           
 end\r\n            data3 = takebuf_string(s);\r\n            close(gzf)\r\n\r\n            @test(data == data2)\r\n            @test(data == data3)\r\n\r\n        end\r\n    end\r\n\r\n   
 ##########################\r\n    # test_group(\"gzip array/matrix tests (write/read)\")\r\n    ##########################\r\n\r\n    let BUFSIZE = 65536\r\n        for level = 0:3:6\r\n    
        for T in [Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64,Int128,UInt128,\r\n                      Float32,Float64,Complex64,Complex128]\r\n\r\n                minval = 34567\r\n    
            try\r\n                    minval = min(typemax(T), 34567)\r\n                catch\r\n                    # do nothing\r\n                end\r\n\r\n                # Ordered array\r\n 
               b = zeros(T, BUFSIZE)\r\n                if !isa(T, Complex)\r\n                    for i = 1:length(b)\r\n                        b[i] = (i-1)%minval;\r\n                    end\r\n  
              else\r\n                    for i = 1:len
gth(b)\r\n                        b[i] = (i-1)%minval - (minval-(i-1))%minval * im\r\n                    end\r\n                end\r\n\r\n                # Random array\r\n                
if isa(T, A
bstractFloat)\r\n                    r = (T)[rand(BUFSIZE)...];\r\n                elseif isa(T, Complex64)\r\n                    r = Int32[rand(BUFSIZE)...] + Int32[rand(BUFSIZE)...] * im\r\n         
       elseif isa(T, Complex128)\r\n                    r = Int64[rand(BUFSIZE)...] + Int64[rand(BUFSIZE)...] * im\r\n                else\r\n                    r = b[rand(1:BUFSIZE, BUFSIZE)];\r\n    
            end\r\n\r\n                # Array file\r\n                b_array_fn = joinpath(tmp, \"b_array.raw.gz\")\r\n                r_array_fn = joinpath(tmp, \"r_array.raw.gz\")\r\n\r\n            
    gzaf_b = gzopen(b_array_fn, \"w\$level\")\r\n                write(gzaf_b, b)\r\n                close(gzaf_b)\r\n\r\n                #println(\"\$T (\$level) ordered: \$(filesize(b_array_fn))\"
)\r\n\r\n                gzaf_r = gzopen(r_array_fn, \"w\$level\")\r\n                write(gzaf_r, r)\r\n                close(gzaf_r)\r\n\r\n                #println(\"\$T (\$level) random: \$(f
ilesize(r_array_fn))\")\r\n\r\n                b2 = zeros(T, BUFSIZE)\r\n                r2 = zeros(T, BUFSIZE)\r\n\r\n                b2_infile = gzopen(b_array_fn)\r\n                read(b2_infile, 
b2);\r\n                close(b2_infile)\r\n\r\n                r2_infile = gzopen(r_array_fn)\r\n                read(r2_infile, r2);\r\n                close(r2_infile)\r\n\r\n              
  @test b == b2\r\n                @test r == r2\r\n            end\r\n        end\r\n    end\r\nfinally\r\n    rm(tmp, recursive=true)\r\nend\r\n\r\n#end  # for epoch\r\n" == "Can not use gfzdio"
 in expression: data == data4
 in error at error.jl:21
while loading C:\Users\Frøystein\.julia\v0.4\GZip\test\runtests.jl, in expression starting on line 24
================================[ ERROR: GZip ]=================================

failed process: Process(`'C:\Users\Frøystein\AppData\Local\Julia-0.4.6\bin\julia' --check-bounds=yes --code-coverage=none --color=yes 'C:\Users\Frøystein\.julia\v0.4\GZip\test\runtests.jl'`, ProcessExited(1)) [1]

================================================================================
ERROR: GZip had test errors
 in error at error.jl:21
hustf commented 8 years ago

I still find 0.3.11 useful for those scripts that were never translated.

On 0.3.11 Windows and Master:

julia> Pkg.test("GZip")
INFO: Testing GZip
symbol could not be found dup (-1): The specified procedure could not be found.

ERROR: unlink: resource busy or locked (EBUSY)
 in unlink at fs.jl:97 (repeats 2 times)
while loading C:\Users\F\.julia\v0.3\GZip\test\runtests.jl, in expression starting on line 31
=========================================================================[ ERROR: GZip ]=========================================================================

failed process: Process(`'C:\Users\F\AppData\Local\Julia-0.3.11\bin/julia' 'C:\Users\Frøystein\.julia\v0.3\GZip\test\runtests.jl'`, ProcessExited(1)) [1]

=================================================================================================================================================================
INFO: No packages to install, update or remove
ERROR: GZip had test errors
 in error at error.jl:21 (repeats 2 times)
mdpradeep commented 8 years ago

Any update on this issue ?

ararslan commented 7 years ago

Still happening on AppVeyor with all Julia versions.