Skip to content

Commit

Permalink
Merge pull request #11133 from JuliaLang/tk/fix11108
Browse files Browse the repository at this point in the history
Replace @windowsxp_only macro with runtime check
  • Loading branch information
tkelman committed May 6, 2015
2 parents 90f7cd0 + 0fa3e34 commit 900cf12
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 36 deletions.
2 changes: 0 additions & 2 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1375,8 +1375,6 @@ export
@unix_only,
@osx_only,
@linux_only,
@windowsxp_only,
@non_windowsxp_only,

# tasks
@schedule,
Expand Down
7 changes: 4 additions & 3 deletions base/fs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ function sendfile(src::AbstractString, dst::AbstractString)
end

@windows_only const UV_FS_SYMLINK_JUNCTION = 0x0002
@non_windowsxp_only function symlink(p::AbstractString, np::AbstractString)
function symlink(p::AbstractString, np::AbstractString)
@windows_only if Base.windows_version() < Base.WINDOWS_VISTA_VER
error("Windows XP does not support soft symlinks")
end
flags = 0
@windows_only if isdir(p); flags |= UV_FS_SYMLINK_JUNCTION; p = abspath(p); end
err = ccall(:jl_fs_symlink, Int32, (Cstring, Cstring, Cint), p, np, flags)
Expand All @@ -167,8 +170,6 @@ end
end
uv_error("symlink",err)
end
@windowsxp_only symlink(p::AbstractString, np::AbstractString) =
error("WindowsXP does not support soft symlinks")

function readlink(path::AbstractString)
req = Libc.malloc(_sizeof_uv_fs)
Expand Down
10 changes: 1 addition & 9 deletions base/osutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,4 @@ end
end
@unix_only windows_version() = (0,0)

WINDOWS_XP_VER = (5,1)

macro windowsxp_only(ex)
_os_test(:?, Expr(:(:), ex, nothing), OS_NAME===:Windows && windows_version() <= WINDOWS_XP_VER)
end

macro non_windowsxp_only(ex)
_os_test(:?, Expr(:(:), nothing, ex), OS_NAME===:Windows && windows_version() <= WINDOWS_XP_VER)
end
WINDOWS_VISTA_VER = (6,0)
21 changes: 11 additions & 10 deletions base/pkg/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ function mkcachedir()
return
end

@windowsxp_only mkdir(cache)
@non_windowsxp_only begin
if Dir.isversioned(pwd())
rootcache = joinpath(realpath(".."), ".cache")
if !isdir(rootcache)
mkdir(rootcache)
end
symlink(rootcache, cache)
return
end
@windows_only if Base.windows_version() < Base.WINDOWS_VISTA_VER
mkdir(cache)
return
end
if Dir.isversioned(pwd())
rootcache = joinpath(realpath(".."), ".cache")
if !isdir(rootcache)
mkdir(rootcache)
end
symlink(rootcache, cache)
return
end
mkdir(cache)
end


Expand Down
6 changes: 4 additions & 2 deletions test/backtrace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ end
dlls = Libdl.dllist()
@test !isempty(dlls)
@test length(dlls) > 3 # at a bare minimum, probably have some version of libstdc, libgcc, libjulia, ...
@non_windowsxp_only @test Base.samefile(Libdl.dlpath(dlls[1]), dlls[1])
@non_windowsxp_only @test Base.samefile(Libdl.dlpath(dlls[end]), dlls[end])
if @unix? true : (Base.windows_version() >= Base.WINDOWS_VISTA_VER)
@test Base.samefile(Libdl.dlpath(dlls[1]), dlls[1])
@test Base.samefile(Libdl.dlpath(dlls[end]), dlls[end])
end
@test length(filter(dlls) do dl
return ismatch(Regex("^libjulia(?:.*)\.$(Libdl.dlext)(?:\..+)?\$"), basename(dl))
end) == 1 # look for something libjulia-like (but only one)
8 changes: 4 additions & 4 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mkdir(subdir)
subdir2 = joinpath(dir, "adir2")
mkdir(subdir2)

@non_windowsxp_only begin
if @unix? true : (Base.windows_version() >= Base.WINDOWS_VISTA_VER)
dirlink = joinpath(dir, "dirlink")
symlink(subdir, dirlink)
# relative link
Expand Down Expand Up @@ -70,7 +70,7 @@ end
@unix_only @test islink(link) == true
@unix_only @test readlink(link) == file

@non_windowsxp_only begin
if @unix? true : (Base.windows_version() >= Base.WINDOWS_VISTA_VER)
@test islink(dirlink) == true
@test isdir(dirlink) == true
@test readlink(dirlink) == subdir * @windows? "\\" : ""
Expand Down Expand Up @@ -441,7 +441,7 @@ rm(cfile)

# issue #10506 #10434
## Tests for directories and links to directories
@non_windowsxp_only begin
if @unix? true : (Base.windows_version() >= Base.WINDOWS_VISTA_VER)
function setup_dirs(tmpdir)
srcdir = joinpath(tmpdir, "src")
hidden_srcdir = joinpath(tmpdir, ".hidden_srcdir")
Expand Down Expand Up @@ -729,7 +729,7 @@ end
rm(link)
rm(rellink)
end
@non_windowsxp_only begin
if @unix? true : (Base.windows_version() >= Base.WINDOWS_VISTA_VER)
rm(dirlink)
rm(relsubdirlink)
end
Expand Down
12 changes: 7 additions & 5 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ccall(:jl_exit_on_sigint, Void, (Cint,), 0)
# in the mix. If verification needs to be done, keep it to the bare minimum. Basically
# this should make sure nothing crashes without depending on how exactly the control
# characters are being used.
@non_windowsxp_only begin
if @unix? true : (Base.windows_version() >= Base.WINDOWS_VISTA_VER)
stdin_write, stdout_read, stdout_read, repl = fake_repl()

repl.specialdisplay = Base.REPL.REPLDisplay(repl)
Expand Down Expand Up @@ -237,7 +237,7 @@ end

ccall(:jl_exit_on_sigint, Void, (Cint,), 1)

@non_windowsxp_only let exename = joinpath(JULIA_HOME, Base.julia_exename())
let exename = joinpath(JULIA_HOME, Base.julia_exename())

# Test REPL in dumb mode
@unix_only begin
Expand Down Expand Up @@ -277,7 +277,9 @@ close(master)
end

# Test stream mode
outs, ins, p = readandwrite(`$exename --startup-file=no --quiet`)
write(ins,"1\nquit()\n")
@test readall(outs) == "1\n"
if @unix? true : (Base.windows_version() >= Base.WINDOWS_VISTA_VER)
outs, ins, p = readandwrite(`$exename --startup-file=no --quiet`)
write(ins,"1\nquit()\n")
@test readall(outs) == "1\n"
end
end
2 changes: 1 addition & 1 deletion test/socket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ begin
close(a)
close(b)
end
@non_windowsxp_only begin
if @unix? true : (Base.windows_version() >= Base.WINDOWS_VISTA_VER)
a = UDPSocket()
b = UDPSocket()
bind(a, ip"::1", UInt16(port))
Expand Down

0 comments on commit 900cf12

Please sign in to comment.