diff --git a/base/download.jl b/base/download.jl index 59cbadcb2f6af..8db0e4819e708 100644 --- a/base/download.jl +++ b/base/download.jl @@ -4,22 +4,3 @@ Downloads() = require(PkgId( UUID((0xf43a241f_c20a_4ad4, 0x852c_f6b1247861c6)), "Downloads", )) - -""" - download(url::AbstractString, [path::AbstractString = tempname()]) -> path - -Download a file from the given url, saving it to the location `path`, or if not -specified, a temporary path. Returns the path of the downloaded file. - -!!! note - Since Julia 1.6, this function is deprecated and is just a thin wrapper - around `Downloads.download`. In new code, you should use that function - directly instead of calling this. -""" -download(url::AbstractString, path::AbstractString) = do_download(url, path) -download(url::AbstractString) = do_download(url, nothing) - -function do_download(url::AbstractString, path::Union{AbstractString, Nothing}) - depwarn("Base.download is deprecated; use Downloads.download instead", :download) - invokelatest(Downloads().download, url, path) -end diff --git a/test/download.jl b/test/download.jl index a37afae231a2a..ee28d60dc4406 100644 --- a/test/download.jl +++ b/test/download.jl @@ -1,6 +1 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license - -cmd = `$(Base.julia_cmd()) --depwarn=no --startup-file=no download_exec.jl` -if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) - error("download test failed, cmd : $cmd") -end diff --git a/test/download_exec.jl b/test/download_exec.jl index 777fb6773c463..ee28d60dc4406 100644 --- a/test/download_exec.jl +++ b/test/download_exec.jl @@ -1,32 +1 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license - -module TestDownload - -using Test - -mktempdir() do temp_dir - # Download a file - file = joinpath(temp_dir, "ip") - @test download("https://httpbin.julialang.org/ip", file) == file - @test isfile(file) - @test !isempty(read(file)) - ip = read(file, String) - - # Download an empty file - empty_file = joinpath(temp_dir, "empty") - @test download("https://httpbin.julialang.org/status/200", empty_file) == empty_file - @test isfile(empty_file) - @test isempty(read(empty_file)) - - # Make sure that failed downloads do not leave files around - missing_file = joinpath(temp_dir, "missing") - @test_throws Exception download("https://httpbin.julialang.org/status/404", missing_file) - @test !isfile(missing_file) - - # Use a TEST-NET (192.0.2.0/24) address which shouldn't be bound - invalid_host_file = joinpath(temp_dir, "invalid_host") - @test_throws Exception download("http://192.0.2.1", invalid_host_file) - @test !isfile(invalid_host_file) -end - -end # module