@@ -667,7 +667,7 @@ func TestCoreSearchSortedResults(t *testing.T) {
667667 require .NoError (t , err )
668668
669669 out := strings .Split (strings .TrimSpace (string (stdout )), "\n " )
670- var lines , deprecated , notDeprecated [][]string
670+ var lines , deprecated , notDeprecated , incompatibles [][]string
671671 for i , v := range out {
672672 if i > 0 {
673673 v = strings .Join (strings .Fields (v ), " " )
@@ -677,6 +677,10 @@ func TestCoreSearchSortedResults(t *testing.T) {
677677 for _ , v := range lines {
678678 if strings .HasPrefix (v [2 ], "[DEPRECATED]" ) {
679679 deprecated = append (deprecated , v )
680+ continue
681+ }
682+ if _ , err := semver .Parse (v [1 ]); err != nil {
683+ incompatibles = append (incompatibles , v )
680684 } else {
681685 notDeprecated = append (notDeprecated , v )
682686 }
@@ -689,9 +693,13 @@ func TestCoreSearchSortedResults(t *testing.T) {
689693 require .True (t , sort .SliceIsSorted (notDeprecated , func (i , j int ) bool {
690694 return strings .ToLower (notDeprecated [i ][2 ]) < strings .ToLower (notDeprecated [j ][2 ])
691695 }))
696+ require .True (t , sort .SliceIsSorted (incompatibles , func (i , j int ) bool {
697+ return strings .ToLower (incompatibles [i ][2 ]) < strings .ToLower (incompatibles [j ][2 ])
698+ }))
692699
700+ result := append (notDeprecated , incompatibles ... )
693701 // verify that deprecated platforms are the last ones
694- require .Equal (t , lines , append (notDeprecated , deprecated ... ))
702+ require .Equal (t , lines , append (result , deprecated ... ))
695703
696704 // test same behaviour with json output
697705 stdout , _ , err = cli .Run ("core" , "search" , "--additional-urls=" + url .String (), "--format=json" )
@@ -705,7 +713,7 @@ func TestCoreSearchSortedResults(t *testing.T) {
705713 require .Equal (t , sortedDeprecated , notSortedDeprecated )
706714
707715 sortedNotDeprecated := requirejson .Parse (t , stdout ).Query (
708- "[ .[] | select(.deprecated != true) | .name |=ascii_downcase | .name ] | sort " ).String ()
716+ "[ .[] | select(.deprecated != true) | .name |=ascii_downcase | {name: .name, incompatible:.incompatible} ] | sort_by(.incompatible) | [.[] | .name] " ).String ()
709717 notSortedNotDeprecated := requirejson .Parse (t , stdout ).Query (
710718 "[.[] | select(.deprecated != true) | .name |=ascii_downcase | .name]" ).String ()
711719 require .Equal (t , sortedNotDeprecated , notSortedNotDeprecated )
@@ -1161,4 +1169,13 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
11611169 require .NoError (t , err )
11621170 requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest` , `"1.0.1"` )
11631171 requirejson .Query (t , stdout , `.[] | select(.id == "incompatible_vendor:avr") | .incompatible` , `true` )
1172+
1173+ // In text mode, core search doesn't show any version if no compatible one are present
1174+ stdout , _ , err = cli .Run ("core" , "search" , additionalURLs )
1175+ require .NoError (t , err )
1176+ var lines [][]string
1177+ for _ , v := range strings .Split (strings .TrimSpace (string (stdout )), "\n " ) {
1178+ lines = append (lines , strings .Fields (strings .TrimSpace (v )))
1179+ }
1180+ require .Contains (t , lines , []string {"incompatible_vendor:avr" , "Incompatible" , "Boards" })
11641181}
0 commit comments