From b5a896a465dc57c5d2bf87d5a583515bd4368571 Mon Sep 17 00:00:00 2001 From: Gautier de Montmollin Date: Mon, 1 Jul 2024 14:40:40 +0200 Subject: [PATCH] Improve `alr get` feedback on unknown crate name (#1708) * 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 --- src/alr/alr-commands-get.adb | 4 +++- testsuite/tests/get/get-not-found/test.py | 2 +- testsuite/tests/get/provides/test.py | 2 +- testsuite/tests/index/external-hint/test.py | 3 --- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/alr/alr-commands-get.adb b/src/alr/alr-commands-get.adb index cc040e5c..1b5f443d 100644 --- a/src/alr/alr-commands-get.adb +++ b/src/alr/alr-commands-get.adb @@ -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; diff --git a/testsuite/tests/get/get-not-found/test.py b/testsuite/tests/get/get-not-found/test.py index f59e890b..82221d88 100644 --- a/testsuite/tests/get/get-not-found/test.py +++ b/testsuite/tests/get/get-not-found/test.py @@ -10,7 +10,7 @@ from drivers.asserts import assert_eq, assert_match 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*')) diff --git a/testsuite/tests/get/provides/test.py b/testsuite/tests/get/provides/test.py index 86e835e8..b56d9e08 100644 --- a/testsuite/tests/get/provides/test.py +++ b/testsuite/tests/get/provides/test.py @@ -19,7 +19,7 @@ assert_eq("""Crate gnat is abstract and provided by: # 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) diff --git a/testsuite/tests/index/external-hint/test.py b/testsuite/tests/index/external-hint/test.py index 2436f2a9..f926d82b 100644 --- a/testsuite/tests/index/external-hint/test.py +++ b/testsuite/tests/index/external-hint/test.py @@ -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 -- 2.39.5