diff --git a/.appveyor.yml b/.appveyor.yml index e38d704..3c86871 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,13 +1,23 @@ 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.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: latest branches: only: - master + - /release-.*/ notifications: - provider: Email @@ -15,26 +25,19 @@ notifications: on_build_failure: false on_build_status_changed: false -init: - - git config --global core.autocrlf input - 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: - - C:\projects\julia\bin\julia -e "versioninfo(); - Pkg.clone(pwd(), \"Pidfile\"); Pkg.build(\"Pidfile\")" + - echo "%JL_BUILD_SCRIPT%" + - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" test_script: - - C:\projects\julia\bin\julia -e "Pkg.test(\"Pidfile\")" + - 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/.travis.yml b/.travis.yml index c5898fa..f0b4362 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,15 +4,14 @@ os: - linux - osx julia: - - 0.6 + - 0.7 + - 1.0 - nightly notifications: email: false -git: - depth: 99999999 after_success: # push coverage results to Coveralls - - julia -e 'cd(Pkg.dir("Pidfile")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' + - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' # push coverage results to Codecov - - julia -e 'cd(Pkg.dir("Pidfile")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' + - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' diff --git a/REQUIRE b/REQUIRE index b3a21b7..859ad46 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1 @@ -julia v0.6 -Compat v0.30.0 +julia 0.7 diff --git a/src/Pidfile.jl b/src/Pidfile.jl index facd339..49e1394 100644 --- a/src/Pidfile.jl +++ b/src/Pidfile.jl @@ -1,36 +1,19 @@ __precompile__() module Pidfile -if VERSION < v"0.7.0-DEV.1053" -using Compat # defines read(io, String) -end export mkpidlock -if VERSION < v"0.7.0-DEV.3107" -macro warn(msg) - return :(warn($(esc(msg)))) -end -macro info(msg) - return :(info($(esc(msg)))) -end -end - using Base: - UVError, UV_EEXIST, UV_ESRCH, + IOError, UV_EEXIST, UV_ESRCH, Process using Base.Filesystem: File, open, JL_O_CREAT, JL_O_RDWR, JL_O_RDONLY, JL_O_EXCL, samefile -if VERSION < v"0.7.0-DEV.914" -using Base.Filesystem: watch_file -const iswindows = Sys.is_windows -else using FileWatching: watch_file using Base.Sys: iswindows -end """ mkpidlock(at::String, [pid::Cint, proc::Process]; kwopts...) @@ -60,11 +43,7 @@ mutable struct LockMonitor try write_pidfile(fd, pid) lock = new(at, fd) - if VERSION < v"0.7.0-DEV.2562" - finalizer(lock, close) - else - finalizer(close, lock) - end + finalizer(close, lock) catch ex close(fd) rm(at) @@ -107,9 +86,6 @@ function parse_pidfile(io::IO) fields = split(read(io, String), ' ', limit = 2) pid = tryparse(Cuint, fields[1]) pid === nothing && (pid = Cuint(0)) - if VERSION < v"0.7" && !isa(pid, Cuint) - pid = get(pid, Cuint(0)) - end hostname = (length(fields) == 2) ? fields[2] : "" when = mtime(io) age = time() - when @@ -125,7 +101,7 @@ function parse_pidfile(path::String) close(existing) end catch ex - isa(ex, EOFError) || isa(ex, UVError) || rethrow(ex) + isa(ex, EOFError) || isa(ex, IOError) || rethrow(ex) return (Cuint(0), "", 0.0) end end @@ -175,7 +151,7 @@ function tryopen_exclusive(path::String, mode::Integer = 0o444) try return open(path, JL_O_RDWR | JL_O_CREAT | JL_O_EXCL, mode) catch ex - (isa(ex, UVError) && ex.code == UV_EEXIST) || rethrow(ex) + (isa(ex, IOError) && ex.code == UV_EEXIST) || rethrow(ex) end return nothing end @@ -202,7 +178,7 @@ function open_exclusive(path::String; t = @async try watch_file(path, poll_interval) catch ex - isa(ex, UVError) || rethrow(ex) + isa(ex, IOError) || rethrow(ex) sleep(poll_interval) # if the watch failed, convert to just doing a sleep end # now try again to create it @@ -217,7 +193,7 @@ function open_exclusive(path::String; try rm(path) catch ex - isa(ex, UVError) || rethrow(ex) + isa(ex, IOError) || rethrow(ex) end end end diff --git a/test/runtests.jl b/test/runtests.jl index 1e2b630..c382109 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,13 +1,7 @@ using Pidfile -if VERSION < v"0.7.0-DEV.2005" - using Base.Test - thrown_type(x::Exception) = typeof(x) - thrown_type(x::Type) = x -else - using Test - thrown_type(x) = x -end +using Test +thrown_type(x) = x using Base.Filesystem: File using Pidfile: iswindows, @@ -76,11 +70,7 @@ end @testset "parse_pidfile" begin age = 0 - if VERSION < v"0.7-" - @test parse_pidfile("nonexist") == (Cuint(0), "", 0.0) - else - @test parse_pidfile("nonexist") === (Cuint(0), "", 0.0) - end + @test parse_pidfile("nonexist") === (Cuint(0), "", 0.0) open(io -> write_pidfile(io, pid), "pidfile", "w") pid2, host2, age2 = parse_pidfile("pidfile") @test pid == pid2 @@ -109,7 +99,7 @@ end # release the pidfile after a short delay deleted = false - rmtask = @schedule begin + rmtask = @async begin sleep(3) rm("pidfile") deleted = true @@ -145,7 +135,7 @@ end close(f) end deleted = false - rmtask = @schedule begin + rmtask = @async begin sleep(8) rm("pidfile") deleted = true @@ -192,13 +182,13 @@ end end @testset "open_exclusive: other errors" begin - @test_throws(thrown_type(Base.UVError("open", Base.UV_ENOENT)), + @test_throws(thrown_type(Base.IOError("open: no such file or directory (ENOENT)", Base.UV_ENOENT)), open_exclusive("nonexist/folder")) end @testset "mkpidlock" begin lockf = mkpidlock("pidfile") - waittask = @schedule begin + waittask = @async begin sleep(3) cd(homedir()) do return close(lockf) @@ -206,7 +196,7 @@ end end t = @elapsed lockf1 = mkpidlock("pidfile") @test t > 2 - @test istaskdone(waittask) && wait(waittask) + @test istaskdone(waittask) && fetch(waittask) @test !close(lockf) finalize(lockf1) t = @elapsed lockf2 = mkpidlock("pidfile")