From e6269b1a214ea666e4f3cb8491ac65d292e7ad96 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Thu, 28 Nov 2024 09:12:21 +0100 Subject: [PATCH] feat: search without solving and with --solve (#1799) * feat: search without solving and with --solve * User changes --- doc/user-changes.md | 11 +++++++++++ src/alr/alr-commands-search.adb | 14 +++++++++++++- src/alr/alr-commands-search.ads | 1 + testsuite/tests/search/basic/test.py | 13 ++++++++++--- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/doc/user-changes.md b/doc/user-changes.md index 1cd072e0b..bb60282f0 100644 --- a/doc/user-changes.md +++ b/doc/user-changes.md @@ -6,6 +6,17 @@ stay on top of `alr` new features. ## Release `2.1` +PR [1799](https://github.com/alire-project/alire/pull/1799) + +`alr search` no longer solves dependencies of releases by default, in order to +speed up the command. The `--solve` switch can be used to achieve the old +behavior. + +In the new default situation, releases that have dependencies are marked with a +'?' symbol in the STATUS column. The `--solve` switch will solve the +dependencies and replace the '?' with either nothing for a solvable release or +the usual 'X' if dependencies are unsatisfiable. + ## Release `2.0` ### `ALIRE_SETTINGS_DIR` replaces `ALR_CONFIG` diff --git a/src/alr/alr-commands-search.adb b/src/alr/alr-commands-search.adb index ed6485f38..becb67df5 100644 --- a/src/alr/alr-commands-search.adb +++ b/src/alr/alr-commands-search.adb @@ -51,7 +51,12 @@ package body Alr.Commands.Search is (if R.Is_Available (Platform.Properties) then " " else Flag_Unav) & (if R.Origin.Is_System then " " else - (if Solver.Is_Resolvable + (if not Cmd.Solve + then + (if R.Dependencies (Platform.Properties).Is_Empty + then " " + else TTY.Dim ("?")) + elsif Solver.Is_Resolvable (R.Dependencies (Platform.Properties), Platform.Properties, Alire.Solutions.Empty_Valid_Solution, @@ -334,6 +339,8 @@ package body Alr.Commands.Search is .Append ("E: the release is externally provided.") .Append ("S: the release is available through a system package.") .Append ("U: the release is not available in the current platform.") + .Append ("?: the release has dependencies but solving was skipped " + & "(see --solve).") .Append ("X: the release has dependencies that cannot be resolved.") .New_Line .Append ("The reasons for unavailability (U) can be ascertained with" @@ -383,6 +390,11 @@ package body Alr.Commands.Search is Cmd.External'Access, "", "--external", "Include externally-provided releases in search"); + + Define_Switch (Config, + Cmd.Solve'Access, + "", "--solve", + "Solve dependencies of releases"); end Setup_Switches; end Alr.Commands.Search; diff --git a/src/alr/alr-commands-search.ads b/src/alr/alr-commands-search.ads index 8e0e40ecd..7bcbbd11f 100644 --- a/src/alr/alr-commands-search.ads +++ b/src/alr/alr-commands-search.ads @@ -36,6 +36,7 @@ private Full : aliased Boolean := False; List : aliased Boolean := False; External : aliased Boolean := False; + Solve : aliased Boolean := False; end record; end Alr.Commands.Search; diff --git a/testsuite/tests/search/basic/test.py b/testsuite/tests/search/basic/test.py index ab4deac3d..b650b90dd 100644 --- a/testsuite/tests/search/basic/test.py +++ b/testsuite/tests/search/basic/test.py @@ -17,9 +17,16 @@ def format_table(*args): lines.append(format_line(*arg)) return ''.join(lines) - -# List latest releases crates +# List latest releases crates, without solving dependencies p = run_alr('search', '--list') +assert_eq(format_table( + ('hello', ' ?', '1.0.1', '"Hello, world!" demonstration project', '', ''), + ('libhello', '', '1.0.0', + '"Hello, world!" demonstration project support library', '', ''), +), p.out) + +# List latest releases crates, solving dependencies +p = run_alr('search', '--list', '--solve') assert_eq(format_table( ('hello', '', '1.0.1', '"Hello, world!" demonstration project', '', ''), ('libhello', '', '1.0.0', @@ -28,7 +35,7 @@ def format_table(*args): # List all releases crates -p = run_alr('search', '--list', '--full') +p = run_alr('search', '--list', '--full', '--solve') assert_eq(format_table( ('hello', '', '1.0.1', '"Hello, world!" demonstration project', '', ''), ('hello', '', '1.0.0', '"Hello, world!" demonstration project', '', ''),