Skip to content

Commit

Permalink
feat: search without solving and with --solve
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Nov 23, 2024
1 parent 20dc457 commit 678decd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
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 678decd

Please sign in to comment.