diff --git a/src/alire/alire-releases.adb b/src/alire/alire-releases.adb index bf85b8c50..b944de4e8 100644 --- a/src/alire/alire-releases.adb +++ b/src/alire/alire-releases.adb @@ -924,9 +924,9 @@ package body Alire.Releases is ----------------------- function Property_Contains (R : Release; Str : String) - return AAA.Strings.Vector + return AAA.Strings.Set is - Results : AAA.Strings.Vector; + Results : AAA.Strings.Set; use AAA.Strings; Search : constant String := To_Lower_Case (Str); @@ -941,12 +941,12 @@ package body Alire.Releases is Value : constant String := Trim (Tail (Image, ':')); begin if Contains (To_Lower_Case (Value), Search) then - Results.Append (Prop); + Results.Include (Prop); end if; end; else if Contains (To_Lower_Case (Image), Search) then - Results.Append (Image); + Results.Include (Image); end if; end if; end; diff --git a/src/alire/alire-releases.ads b/src/alire/alire-releases.ads index 6b3f2b2da..c601758da 100644 --- a/src/alire/alire-releases.ads +++ b/src/alire/alire-releases.ads @@ -309,9 +309,8 @@ package Alire.Releases is -- True if some property contains the given string function Property_Contains (R : Release; Str : String) - return AAA.Strings.Vector; - -- Return a vector with the names of propreties that contain the given - -- string. + return AAA.Strings.Set; + -- Return a set with the names of propeties that contain the given string function Satisfies (R : Release; Dep : Alire.Dependencies.Dependency'Class) diff --git a/src/alr/alr-commands-search.adb b/src/alr/alr-commands-search.adb index 44d8b0136..f5ff17169 100644 --- a/src/alr/alr-commands-search.adb +++ b/src/alr/alr-commands-search.adb @@ -37,7 +37,7 @@ package body Alr.Commands.Search is ------------------- procedure Print_Release (R : Alire.Releases.Release; - Match_Locations : AAA.Strings.Vector) + Match_Locations : AAA.Strings.Set) is package Solver renames Alire.Solver; @@ -63,7 +63,7 @@ package body Alr.Commands.Search is Tab.Append (TTY.Version (Semantic_Versioning.Image (R.Version))); Tab.Append (TTY.Description (R.Description)); Tab.Append (R.Notes); - Tab.Append (Match_Locations.Flatten (", ")); + Tab.Append (Match_Locations.To_Vector.Flatten (", ")); end Print_Release; ----------------- @@ -72,16 +72,16 @@ package body Alr.Commands.Search is function Match_Crate (Crate : Alire.Crates.Crate; Pattern : String) - return AAA.Strings.Vector + return AAA.Strings.Set is - Match_Locations : AAA.Strings.Vector; + Match_Locations : AAA.Strings.Set; begin if AAA.Strings.Contains (+Crate.Name, Pattern) then - Match_Locations.Append ("Name"); + Match_Locations.Include ("Name"); end if; if AAA.Strings.Contains (Crate.Description, Pattern) then - Match_Locations.Append ("Description"); + Match_Locations.Include ("Description"); end if; return Match_Locations; end Match_Crate; @@ -90,7 +90,7 @@ package body Alr.Commands.Search is -- Filter_Release -- -------------------- - procedure Filter_Release (R : Alire.Releases.Release; + procedure Filter_Release (R : Alire.Releases.Release; Pattern : String) is begin @@ -98,10 +98,10 @@ package body Alr.Commands.Search is if Pattern = "" then -- Empty pattern means include everything - Print_Release (R, Match_Locations => AAA.Strings.Empty_Vector); + Print_Release (R, Match_Locations => AAA.Strings.Empty_Set); else declare - Match_Locations : constant AAA.Strings.Vector + Match_Locations : constant AAA.Strings.Set := R.Property_Contains (Pattern); begin if not Match_Locations.Is_Empty @@ -119,8 +119,8 @@ package body Alr.Commands.Search is -------------------- procedure Print_External (Name : Alire.Crate_Name; - Ext : Alire.Externals.External'Class; - Match_Locations : AAA.Strings.Vector) + Ext : Alire.Externals.External'Class; + Match_Locations : AAA.Strings.Set) is begin Found := Found + 1; @@ -132,7 +132,7 @@ package body Alr.Commands.Search is Tab.Append ("external"); Tab.Append (Alire.Index.Crate (Name).TTY_Description); Tab.Append (Ext.Image); - Tab.Append (Match_Locations.Flatten (", ")); + Tab.Append (Match_Locations.To_Vector.Flatten (", ")); end Print_External; begin @@ -209,7 +209,7 @@ package body Alr.Commands.Search is -- List_All_Or_Latest -- ------------------------ - procedure List_All_Or_Latest (Crate : Alire.Crates.Crate; + procedure List_All_Or_Latest (Crate : Alire.Crates.Crate; Pattern : String) is Progress : Trace.Ongoing := @@ -238,7 +238,7 @@ package body Alr.Commands.Search is Trace.Activity (Crate.Name.Index_Prefix) with Unreferenced; - Match_Locations : constant AAA.Strings.Vector := + Match_Locations : constant AAA.Strings.Set := Match_Crate (Crate, Pattern); begin if Cmd.External diff --git a/testsuite/fixtures/basic_index/li/libhello/libhello-1.0.0.toml b/testsuite/fixtures/basic_index/li/libhello/libhello-1.0.0.toml index c46f09fab..11d2c745e 100644 --- a/testsuite/fixtures/basic_index/li/libhello/libhello-1.0.0.toml +++ b/testsuite/fixtures/basic_index/li/libhello/libhello-1.0.0.toml @@ -3,7 +3,9 @@ name = "libhello" version = "1.0.0" maintainers = ["alejandro@mosteo.com"] maintainers-logins = ["mylogin"] -tags = ["libhello-tag1"] + +# for an `alr search` test we need multiple tags that match the same pattern +tags = ["libhello-tag1", "libhello-tag2"] [configuration.variables] Var1={type="Boolean", default=true} diff --git a/testsuite/tests/search/basic/test.py b/testsuite/tests/search/basic/test.py index 815d96de3..ab4deac3d 100644 --- a/testsuite/tests/search/basic/test.py +++ b/testsuite/tests/search/basic/test.py @@ -42,8 +42,8 @@ def format_table(*args): assert_eq('libhello "Hello, world!" demonstration project support library\n', p.out) -# Then on all properties -p = run_alr('search', 'libhello-tag1') +# Then on all properties, matching properties name should appear only once +p = run_alr('search', 'libhello-tag') assert_eq(format_table( ('libhello', '', '1.0.0', '"Hello, world!" demonstration project support library', '', 'Tag'),