Skip to content

Commit

Permalink
Improve alr get feedback on unknown crate name (#1708)
Browse files Browse the repository at this point in the history
* Update alr-commands-get.adb

Added a help message for the case the exact crate name was not found.

* Tweak tests for new output

---------

Co-authored-by: Alejandro R. Mosteo <[email protected]>
  • Loading branch information
zertovitch and mosteo authored Jul 1, 2024
1 parent 873fda0 commit b5a896a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/alr/alr-commands-get.adb
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ package body Alr.Commands.Get is
else
Reportaise_Command_Failed
("Crate [" & Allowed.Crate.As_String
& "] does not exist in the index.");
& "] does not exist in the index. "
& "Use `alr search " & Allowed.Crate.As_String
& "` for similar names.");
end if;
end if;

Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/get/get-not-found/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

p = run_alr('get', 'does_not_exist', complain_on_error=False)
assert_eq(1, p.status)
assert_match('.*Crate \[does_not_exist\] does not exist in the index\.\n',
assert_match('.*Crate \[does_not_exist\] does not exist in the index\..*\n',
p.out)
assert_eq([], glob('does_not_exist*'))

Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/get/provides/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Check the error for a truly unknown crate:

assert_eq("""\
ERROR: Crate [unobtanium] does not exist in the index.
ERROR: Crate [unobtanium] does not exist in the index. Use `alr search unobtanium` for similar names.
""",
run_alr("get", "unobtanium", "--dirname", complain_on_error=False).out)

Expand Down
3 changes: 0 additions & 3 deletions testsuite/tests/index/external-hint/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
Test the hinting with custom text in external definitions
"""

from glob import glob

from drivers.alr import distro_is_known, run_alr
from drivers.asserts import assert_eq, assert_match

import re
import platform

# 1st test: directly attempting to retrieve an external (this is doable for
# system externals in supported platforms -- never in this test). Depending on
Expand Down

0 comments on commit b5a896a

Please sign in to comment.