Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ranked suggestions to add error #2985

Merged
merged 5 commits into from
Feb 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,19 @@ end
@test_throws PkgError(
"version specification invalid when tracking a repository: `0.5.0` specified for package `Example`"
) Pkg.add(name="Example", rev="master", version="0.5.0")
# Adding with a slight typo gives suggestions
try Pkg.add("Examplle")
@assert false # to fail if add doesn't error
IanButterworth marked this conversation as resolved.
Show resolved Hide resolved
catch err
@test err isa PkgError
@test match(r"ERROR: The following package names could not be resolved:", err.msg) !== nothing
@test match(r"* Examplle (not found in project, manifest or registry)", err.msg) !== nothing
@test match(r"Suggestions:", err.msg) !== nothing
@test match(r"Example", err.msg) !== nothing
end
@test_throws PkgError(
"name, UUID, URL, or filesystem path specification required when calling `add`"
) Pkg.add(Pkg.PackageSpec())
# Adding an unregistered package
@test_throws PkgError Pkg.add("ThisIsHopefullyRandom012856014925701382")
# Wrong UUID
Expand Down