From 981a51c67e76f854c7a11df65373c78a373e361c Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Sun, 29 Oct 2023 18:27:07 +0100 Subject: [PATCH 1/3] Fix "-h/--help" being catched after "--" --- deps/clic | 2 +- src/alr/alr-commands.adb | 8 ----- .../tests/help/help-after-double-dash/test.py | 30 +++++++++++++++++++ .../help/help-after-double-dash/test.yaml | 3 ++ 4 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 testsuite/tests/help/help-after-double-dash/test.py create mode 100644 testsuite/tests/help/help-after-double-dash/test.yaml diff --git a/deps/clic b/deps/clic index b40b170b1..4713e68c9 160000 --- a/deps/clic +++ b/deps/clic @@ -1 +1 @@ -Subproject commit b40b170b1561adfa99910c69e3897cc2ca441730 +Subproject commit 4713e68c93a3f306adcff720e7171a40e5d10e6f diff --git a/src/alr/alr-commands.adb b/src/alr/alr-commands.adb index b14916eb3..ca76a58d2 100644 --- a/src/alr/alr-commands.adb +++ b/src/alr/alr-commands.adb @@ -70,9 +70,6 @@ package body Alr.Commands is Debug_Channel : Boolean renames Alire_Early_Elaboration.Switch_D; -- For the stderr debug channel - Help_Switch : aliased Boolean := False; - -- Catches the -h/--help help switch - Prefer_Oldest : aliased Boolean := False; -- Catches the --prefer-oldest policy switch @@ -155,11 +152,6 @@ package body Alr.Commands is "-f", "--force", "Keep going after a recoverable troublesome situation"); - Define_Switch (Config, - Help_Switch'Access, - "-h", "--help", - "Display general or command-specific help"); - Define_Switch (Config, CLIC.User_Input.Not_Interactive'Access, "-n", "--non-interactive", diff --git a/testsuite/tests/help/help-after-double-dash/test.py b/testsuite/tests/help/help-after-double-dash/test.py new file mode 100644 index 000000000..46c41120d --- /dev/null +++ b/testsuite/tests/help/help-after-double-dash/test.py @@ -0,0 +1,30 @@ +""" +Bug #1379: -h/--help must not trigger our help system after a "--" argument +""" + +import re + +from drivers.alr import init_local_crate, run_alr +from drivers.asserts import assert_match + +# For no command, "--" with help afterwards should simply trigger an error + +assert_match(".*" + re.escape("Unrecognized option '--' (global)"), + run_alr("--", "--help", complain_on_error=False).out) + +# For a command that doesn't understand "--", same: + +assert_match(".*" + re.escape("Unrecognized option '--' (command/topic \"show\")"), + run_alr("show", "--", "--help", complain_on_error=False).out) + +# For `alr exec`, it should trigger the secondary command help and not ours. We +# verify the command being launched includes the "--help" option. Since `exec` +# requires a workspace, we enter one first. + +init_local_crate() + +assert_match(".*" + re.escape('Command ["alr_fake", "--help"] exited with code 1'), + run_alr("exec", "--", "alr_fake", "--help", + complain_on_error=False).out) + +print("SUCCESS") diff --git a/testsuite/tests/help/help-after-double-dash/test.yaml b/testsuite/tests/help/help-after-double-dash/test.yaml new file mode 100644 index 000000000..00fb56e10 --- /dev/null +++ b/testsuite/tests/help/help-after-double-dash/test.yaml @@ -0,0 +1,3 @@ +driver: python-script +build_mode: both +indexes: {} \ No newline at end of file From edd6a8543f69d26bcef70cec1285a12d2ca287f7 Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Mon, 6 Nov 2023 11:18:23 +0100 Subject: [PATCH 2/3] Bump clic dependency --- alire.toml | 2 +- deps/clic | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/alire.toml b/alire.toml index 32bda836b..e0d1f9134 100644 --- a/alire.toml +++ b/alire.toml @@ -49,7 +49,7 @@ windows = { ALIRE_OS = "windows" } [[pins]] aaa = { url = "https://github.com/mosteo/aaa", commit = "ecc38772bd4a6b469b54c62363766ea1c0e9f912" } ada_toml = { url = "https://github.com/mosteo/ada-toml", commit = "da4e59c382ceb0de6733d571ecbab7ea4919b33d" } -clic = { url = "https://github.com/alire-project/clic", commit = "b40b170b1561adfa99910c69e3897cc2ca441730" } +clic = { url = "https://github.com/alire-project/clic", commit = "de0330053584bad4dbb3dbd5e1ba939c4e8c6b55" } dirty_booleans = { url = "https://github.com/mosteo/dirty_booleans", branch = "main" } diskflags = { url = "https://github.com/mosteo/diskflags", branch = "main" } gnatcoll = { url = "https://github.com/alire-project/gnatcoll-core.git", commit = "4e663b87a028252e7e074f054f8f453661397166" } diff --git a/deps/clic b/deps/clic index 4713e68c9..de0330053 160000 --- a/deps/clic +++ b/deps/clic @@ -1 +1 @@ -Subproject commit 4713e68c93a3f306adcff720e7171a40e5d10e6f +Subproject commit de0330053584bad4dbb3dbd5e1ba939c4e8c6b55 From 2c9f7a43dd6e5da6535da7c4fa478b2e1bf9ece7 Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Mon, 6 Nov 2023 13:04:59 +0100 Subject: [PATCH 3/3] Fix test on Windows --- src/alire/alire-os_lib-subprocess.adb | 2 +- testsuite/tests/help/help-after-double-dash/test.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/alire/alire-os_lib-subprocess.adb b/src/alire/alire-os_lib-subprocess.adb index efc4b94b5..29cd39c2c 100644 --- a/src/alire/alire-os_lib-subprocess.adb +++ b/src/alire/alire-os_lib-subprocess.adb @@ -143,7 +143,7 @@ package body Alire.OS_Lib.Subprocess is Raise_Checked_Error ("Command " & Image (Command, Arguments) - & " exited with code" & Exit_Code'Img + & " exited with code" & AAA.Strings.Trim (Exit_Code'Image) & " and output: " & Output.Flatten (Separator => "\n")); return Output; diff --git a/testsuite/tests/help/help-after-double-dash/test.py b/testsuite/tests/help/help-after-double-dash/test.py index 46c41120d..549c62b17 100644 --- a/testsuite/tests/help/help-after-double-dash/test.py +++ b/testsuite/tests/help/help-after-double-dash/test.py @@ -23,8 +23,9 @@ init_local_crate() -assert_match(".*" + re.escape('Command ["alr_fake", "--help"] exited with code 1'), +assert_match(".*" + re.escape('Command ["alr_fake", "--help"] exited with code'), run_alr("exec", "--", "alr_fake", "--help", complain_on_error=False).out) +# We don't match the code as it varies between OSes print("SUCCESS")