From df947170d271c70edca578cbcf4430727a913ba0 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Mon, 18 May 2020 20:16:23 +0200 Subject: [PATCH] Remove misleading/redundant error messages (#416) --- src/alire/alire.ads | 5 ++--- src/alr/alr-commands.adb | 12 ++++++++++-- testsuite/tests/get/get-not-found/test.py | 5 ++--- testsuite/tests/index/bad-action-command/test.py | 7 +++---- testsuite/tests/index/bad-license/test.py | 7 +++---- testsuite/tests/index/bad-tag/test.py | 3 +-- testsuite/tests/index/empty-tag/test.py | 3 +-- testsuite/tests/index/external-hint/test.py | 3 +-- testsuite/tests/index/local-index-not-found/test.py | 1 - testsuite/tests/index/long-tag/test.py | 8 ++++---- testsuite/tests/index/maint-bad-email/test.py | 3 +-- testsuite/tests/index/maint-bad-login/test.py | 3 +-- .../tests/index/origin-filesystem-bad-path/test.py | 3 +-- testsuite/tests/index/origin-unknown-kind/test.py | 1 - .../tests/index/too-long-short-description/test.py | 8 ++++---- testsuite/tests/run/no-compile/test.py | 3 +-- 16 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/alire/alire.ads b/src/alire/alire.ads index c60abb57..f9aa24be 100644 --- a/src/alire/alire.ads +++ b/src/alire/alire.ads @@ -12,14 +12,13 @@ package Alire with Preelaborate is -- relation with user inputs (e.g., parsing of TOML files or other inputs). -- Used internally in Alire in conjunction with Alire.Errors to use the -- normal exception mechanisms, that produce less boilerplate, while using - -- Outcomes for results returned to clients. That is, a Checked_Error ought - -- not to propagate into Alr.* code. + -- Outcomes for results returned to clients. Query_Unsuccessful : exception; -- Raised by subprograms that return releases/dependencies when not -- found/impossible. - Unimplemented : exception; + Unimplemented : exception; -- Features that are known to be missing and scheduled for near future -- implementation. diff --git a/src/alr/alr-commands.adb b/src/alr/alr-commands.adb index abe11a37..ec0b78fb 100644 --- a/src/alr/alr-commands.adb +++ b/src/alr/alr-commands.adb @@ -8,6 +8,7 @@ with Ada.Text_IO; use Ada.Text_IO; with Alire_Early_Elaboration; with Alire; with Alire.Config; +with Alire.Errors; with Alire.Features.Index; with Alire.Index; with Alire.Lockfiles; @@ -690,8 +691,16 @@ package body Alr.Commands is Execute_By_Name (What_Command); Log ("alr " & What_Command & " done", Detail); exception + when E : Alire.Checked_Error => + Trace.Error (Alire.Errors.Get (E, Clear => False)); + if Alire.Log_Level = Debug then + raise; + else + OS_Lib.Bailout (1); + end if; + when Child_Failed | Command_Failed => - Trace.Error ("alr " & What_Command & " unsuccessful"); + Trace.Detail ("alr " & What_Command & " unsuccessful"); if Alire.Log_Level = Debug then raise; else @@ -713,7 +722,6 @@ package body Alr.Commands is exception when Wrong_Command_Arguments => --- Display_Usage (Cmd); OS_Lib.Bailout (1); end Execute_By_Name; diff --git a/testsuite/tests/get/get-not-found/test.py b/testsuite/tests/get/get-not-found/test.py index 489c9e81..54ee07cf 100644 --- a/testsuite/tests/get/get-not-found/test.py +++ b/testsuite/tests/get/get-not-found/test.py @@ -10,9 +10,8 @@ from drivers.asserts import assert_eq p = run_alr('get', 'does_not_exist', complain_on_error=False, quiet=False) assert_eq(1, p.status) -assert_eq('Crate [does_not_exist] does not exist in the catalog.' - '\nERROR: alr get unsuccessful', - p.out.strip()) +assert_eq('Crate [does_not_exist] does not exist in the catalog.\n', + p.out) assert_eq([], glob('does_not_exist*')) print('SUCCESS') diff --git a/testsuite/tests/index/bad-action-command/test.py b/testsuite/tests/index/bad-action-command/test.py index d50d04da..38353484 100644 --- a/testsuite/tests/index/bad-action-command/test.py +++ b/testsuite/tests/index/bad-action-command/test.py @@ -8,9 +8,8 @@ from drivers.asserts import assert_match p = run_alr('show', 'hello_world', complain_on_error=False, debug=False, quiet=True) -assert_match( - 'ERROR: Loading crate .* actions command must be an array of string\(s\)\n' - 'ERROR: alr show unsuccessful\n', - p.out) +assert_match('ERROR: Loading crate .* actions command must' + ' be an array of string\(s\)\n', + p.out) print('SUCCESS') diff --git a/testsuite/tests/index/bad-license/test.py b/testsuite/tests/index/bad-license/test.py index 91111732..7dfb66ed 100644 --- a/testsuite/tests/index/bad-license/test.py +++ b/testsuite/tests/index/bad-license/test.py @@ -8,9 +8,8 @@ from drivers.asserts import assert_match p = run_alr('show', 'hello_world', complain_on_error=False, debug=False, quiet=True) -assert_match( - 'ERROR: Loading crate .*hello_world.toml: general: licenses: unknown license: \'Invalid license ID\'\n' - 'ERROR: alr show unsuccessful\n', - p.out) +assert_match('ERROR: Loading crate .*hello_world.toml: general: ' + 'licenses: unknown license: \'Invalid license ID\'\n', + p.out) print('SUCCESS') diff --git a/testsuite/tests/index/bad-tag/test.py b/testsuite/tests/index/bad-tag/test.py index 322ec102..326f88a6 100644 --- a/testsuite/tests/index/bad-tag/test.py +++ b/testsuite/tests/index/bad-tag/test.py @@ -11,8 +11,7 @@ p = run_alr('show', 'hello_world', assert_match( 'ERROR: Loading crate .*hello_world.toml: general: tags: ' 'Tag string is not valid\n' - 'ERROR: Cannot read valid property from tags\n' - 'ERROR: alr show unsuccessful\n', + 'ERROR: Cannot read valid property from tags\n', p.out) print('SUCCESS') diff --git a/testsuite/tests/index/empty-tag/test.py b/testsuite/tests/index/empty-tag/test.py index 486fac70..c4ae1f2b 100644 --- a/testsuite/tests/index/empty-tag/test.py +++ b/testsuite/tests/index/empty-tag/test.py @@ -11,8 +11,7 @@ p = run_alr('show', 'hello_world', assert_match( 'ERROR: Loading crate .*hello_world.toml: general: tags: ' 'Tag string is empty\n' - 'ERROR: Cannot read valid property from tags\n' - 'ERROR: alr show unsuccessful\n', + 'ERROR: Cannot read valid property from tags\n', p.out) print('SUCCESS') diff --git a/testsuite/tests/index/external-hint/test.py b/testsuite/tests/index/external-hint/test.py index f78fc05b..98e8ae3a 100644 --- a/testsuite/tests/index/external-hint/test.py +++ b/testsuite/tests/index/external-hint/test.py @@ -20,8 +20,7 @@ if distro_is_known(): assert_match(".*Hint: This is a custom hint.*", p.out, flags=re.S) else: assert_eq('ERROR: No source release indexed for the requested crate, and ' - 'cannot use system packages in unknown distribution\n' - 'ERROR: alr get unsuccessful\n', + 'cannot use system packages in unknown distribution\n', p.out) # 2nd test: hint is displayed when the hint belongs to a dependency, on get diff --git a/testsuite/tests/index/local-index-not-found/test.py b/testsuite/tests/index/local-index-not-found/test.py index e06ac2a7..6f4596e5 100644 --- a/testsuite/tests/index/local-index-not-found/test.py +++ b/testsuite/tests/index/local-index-not-found/test.py @@ -22,7 +22,6 @@ for d in ('no-such-directory', 'index.toml') assert_match('ERROR: Cannot load metadata from .*{}:' ' Not a readable directory' - '\nERROR: alr list unsuccessful' '\n' .format(re.escape(path_excerpt)), p.out) diff --git a/testsuite/tests/index/long-tag/test.py b/testsuite/tests/index/long-tag/test.py index 85712385..d7a7f9af 100644 --- a/testsuite/tests/index/long-tag/test.py +++ b/testsuite/tests/index/long-tag/test.py @@ -9,9 +9,9 @@ from drivers.asserts import assert_match p = run_alr('show', 'hello_world', complain_on_error=False, debug=False, quiet=True) assert_match('ERROR: Loading crate .*hello_world.toml:' - ' general: tags: Tag string is too long \(must be no more than [0-9]+\)\n' - 'ERROR: Cannot read valid property from tags\n' - 'ERROR: alr show unsuccessful\n', - p.out) + ' general: tags: Tag string is too long ' + '\(must be no more than [0-9]+\)\n' + 'ERROR: Cannot read valid property from tags\n', + p.out) print('SUCCESS') diff --git a/testsuite/tests/index/maint-bad-email/test.py b/testsuite/tests/index/maint-bad-email/test.py index 0e60dc22..d2a44a72 100644 --- a/testsuite/tests/index/maint-bad-email/test.py +++ b/testsuite/tests/index/maint-bad-email/test.py @@ -11,8 +11,7 @@ p = run_alr('show', 'hello_world', assert_match( 'ERROR: Loading crate .*hello_world.toml: general: maintainers: ' 'Maintainers must have a valid email, but got: Mr. User\n' - 'ERROR: Cannot read valid property from maintainers\n' - 'ERROR: alr show unsuccessful\n', + 'ERROR: Cannot read valid property from maintainers\n', p.out) print('SUCCESS') diff --git a/testsuite/tests/index/maint-bad-login/test.py b/testsuite/tests/index/maint-bad-login/test.py index e3b93ccf..f6165b6a 100644 --- a/testsuite/tests/index/maint-bad-login/test.py +++ b/testsuite/tests/index/maint-bad-login/test.py @@ -11,8 +11,7 @@ p = run_alr('show', 'hello_world', assert_match( 'ERROR: Loading crate .*hello_world.toml: general: maintainers-logins: ' 'maintainers-logins must be a valid GitHub login, but got: mr.user\n' - 'ERROR: Cannot read valid property from maintainers-logins\n' - 'ERROR: alr show unsuccessful\n', + 'ERROR: Cannot read valid property from maintainers-logins\n', p.out) print('SUCCESS') diff --git a/testsuite/tests/index/origin-filesystem-bad-path/test.py b/testsuite/tests/index/origin-filesystem-bad-path/test.py index 44228804..027e54cc 100644 --- a/testsuite/tests/index/origin-filesystem-bad-path/test.py +++ b/testsuite/tests/index/origin-filesystem-bad-path/test.py @@ -15,8 +15,7 @@ def run(i, error): config_dir, '.', {'bad_index_{}'.format(i): {'in_fixtures': False}}) p = run_alr('list', complain_on_error=False, debug=False) assert_match( - 'ERROR: {}' - '\nERROR: alr list unsuccessful\n$'.format(error), + 'ERROR: {}\n$'.format(error), p.out) diff --git a/testsuite/tests/index/origin-unknown-kind/test.py b/testsuite/tests/index/origin-unknown-kind/test.py index 6b05af16..a14ccc95 100644 --- a/testsuite/tests/index/origin-unknown-kind/test.py +++ b/testsuite/tests/index/origin-unknown-kind/test.py @@ -10,7 +10,6 @@ p = run_alr('show', 'hello_world', complain_on_error=False, debug=False, quiet=False) assert_match( 'ERROR: .* unknown origin: .*' - '\nERROR: alr show unsuccessful' '\n', p.out) print('SUCCESS') diff --git a/testsuite/tests/index/too-long-short-description/test.py b/testsuite/tests/index/too-long-short-description/test.py index e89ee049..031a86aa 100644 --- a/testsuite/tests/index/too-long-short-description/test.py +++ b/testsuite/tests/index/too-long-short-description/test.py @@ -9,9 +9,9 @@ from drivers.asserts import assert_match p = run_alr('show', 'hello_world', complain_on_error=False, debug=False, quiet=True) assert_match('ERROR: Loading crate .*hello_world.toml:' - ' general: description: Description string is too long \(must be no more than [0-9]+\)\n' - 'ERROR: Cannot read valid property from description\n' - 'ERROR: alr show unsuccessful\n', - p.out) + ' general: description: Description string is too long' + ' \(must be no more than [0-9]+\)\n' + 'ERROR: Cannot read valid property from description\n', + p.out) print('SUCCESS') diff --git a/testsuite/tests/run/no-compile/test.py b/testsuite/tests/run/no-compile/test.py index f14a17ec..6137757d 100644 --- a/testsuite/tests/run/no-compile/test.py +++ b/testsuite/tests/run/no-compile/test.py @@ -15,8 +15,7 @@ os.chdir('xxx') # Run it without compiling it first p = run_alr('run', '-s', complain_on_error=False) assert p.status != 0 -assert_match('ERROR: Executable "xxx(\.exe)?" not found\n' - 'ERROR: alr run unsuccessful\n', +assert_match('ERROR: Executable "xxx(\.exe)?" not found\n', p.out) print('SUCCESS') -- 2.39.5