Skip to content

Commit

Permalink
feat: search without solving and with --solve (#1799)
Browse files Browse the repository at this point in the history
* feat: search without solving and with --solve

* User changes
  • Loading branch information
mosteo authored Nov 28, 2024
1 parent b5bfbad commit e6269b1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
11 changes: 11 additions & 0 deletions doc/user-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
14 changes: 13 additions & 1 deletion src/alr/alr-commands-search.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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;
1 change: 1 addition & 0 deletions src/alr/alr-commands-search.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
13 changes: 10 additions & 3 deletions testsuite/tests/search/basic/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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', '', ''),
Expand Down

0 comments on commit e6269b1

Please sign in to comment.