Skip to content

Commit

Permalink
Merge pull request JuliaLang#13420 from JuliaLang/tk/pkgconflict
Browse files Browse the repository at this point in the history
Fix throwing of Pkg errors, add error-condition tests and fixes
  • Loading branch information
tkelman committed Oct 3, 2015
2 parents 01a852d + 3a57ccb commit 19563a3
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 146 deletions.
10 changes: 1 addition & 9 deletions base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@ function cd(f::Function, args...; kws...)
!haskey(ENV,"JULIA_PKGDIR") ? init() :
throw(PkgError("Package metadata directory $metadata_dir doesn't exist; run Pkg.init() to initialize it."))
end
try
Base.cd(()->f(args...; kws...), dir)
catch err
if isa(err, PkgError)
print_with_color(:red, "ERROR: $(err.msg)")
else
throw(err)
end
end
Base.cd(()->f(args...; kws...), dir)
end

function init(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRANCH)
Expand Down
6 changes: 3 additions & 3 deletions base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ pin(pkg::AbstractString) = pin(pkg, "")

function pin(pkg::AbstractString, ver::VersionNumber)
ispath(pkg,".git") || throw(PkgError("$pkg is not a git repo"))
Read.isinstalled(pkg) || throw(PkgError("$pkg cannot be pinned – not an installed package".tmp))
Read.isinstalled(pkg) || throw(PkgError("$pkg cannot be pinned – not an installed package"))
avail = Read.available(pkg)
isempty(avail) && throw(PkgError("$pkg cannot be pinned – not a registered package".tmp))
isempty(avail) && throw(PkgError("$pkg cannot be pinned – not a registered package"))
haskey(avail,ver) || throw(PkgError("$pkg$ver is not a registered version"))
pin(pkg, avail[ver].sha1)
end
Expand Down Expand Up @@ -475,7 +475,7 @@ function resolve(
for pkg in keys(reqs)
if !haskey(deps,pkg)
if "julia" in conflicts[pkg]
throw(PkgError("$pkg can't be installed because it has no versions that support ", VERSION, " of julia. " *
throw(PkgError("$pkg can't be installed because it has no versions that support $VERSION of julia. " *
"You may need to update METADATA by running `Pkg.update()`"))
else
sconflicts = join(conflicts[pkg], ", ", " and ")
Expand Down
2 changes: 2 additions & 0 deletions test/backtrace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ eval(Expr(:function, Expr(:call, :test_inline_2),

try
eval(:(test_inline_1()))
error("unexpected")
catch err
lkup = get_bt_frame(:test_inline_1, catch_backtrace())
if is(lkup, nothing)
Expand All @@ -51,6 +52,7 @@ catch err
end
try
eval(:(test_inline_2()))
error("unexpected")
catch err
lkup = get_bt_frame(:test_inline_2, catch_backtrace())
if is(lkup, nothing)
Expand Down
1 change: 1 addition & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ let deepthought(x, y) = 42
try
@assert 1 == 2 string("the answer to the ultimate question: ",
deepthought(6, 9))
error("unexpected")
catch ex
@test isa(ex, AssertionError)
@test ex.msg == "the answer to the ultimate question: 42"
Expand Down
2 changes: 2 additions & 0 deletions test/parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ try
@async error(i)
end
end
error("unexpected")
catch ex
@test typeof(ex) == CompositeException
@test length(ex) == 5
Expand All @@ -394,6 +395,7 @@ end

try
remotecall_fetch(()->throw(ErrorException("foobar")), id_other)
error("unexpected")
catch ex
@test typeof(ex) == RemoteException
@test typeof(ex.captured) == CapturedException
Expand Down
Loading

0 comments on commit 19563a3

Please sign in to comment.