@@ -1587,3 +1587,40 @@ func TestLibBundlesWhenLibWithTheSameNameIsInstalledGlobally(t *testing.T) {
1587
1587
requirejson .Parse (t , stdout ).Query (`.[].library.examples[1]` ).MustContain (`"OTALeds"` )
1588
1588
}
1589
1589
}
1590
+
1591
+ func TestLibListDoesNotIncludeEmptyLibraries (t * testing.T ) {
1592
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
1593
+ defer env .CleanUp ()
1594
+
1595
+ _ , _ , err := cli .Run ("lib" , "update-index" )
1596
+ require .NoError (t , err )
1597
+
1598
+ // Create a library that does not have neither a library.properties nor a ".h" file
1599
+ emptyLib := cli .SketchbookDir ().Join ("libraries" , "empty" )
1600
+ require .NoError (t , emptyLib .MkdirAll ())
1601
+
1602
+ // Check that the output of lib list and lib examples is empty
1603
+ stdout , _ , err := cli .Run ("lib" , "list" , "--format" , "json" )
1604
+ require .NoError (t , err )
1605
+ requirejson .Empty (t , stdout )
1606
+
1607
+ stdout , _ , err = cli .Run ("lib" , "examples" , "--format" , "json" )
1608
+ require .NoError (t , err )
1609
+ requirejson .Empty (t , stdout )
1610
+
1611
+ // Create a library with a header
1612
+ libWithHeader := cli .SketchbookDir ().Join ("libraries" , "libWithHeader" )
1613
+ require .NoError (t , libWithHeader .MkdirAll ())
1614
+ f , err := libWithHeader .Join ("libWithHeader.h" ).Create ()
1615
+ require .NoError (t , err )
1616
+ require .NoError (t , f .Close ())
1617
+
1618
+ // Check that the output of lib list and lib examples contains the library
1619
+ stdout , _ , err = cli .Run ("lib" , "list" , "--format" , "json" )
1620
+ require .NoError (t , err )
1621
+ requirejson .Len (t , stdout , 1 )
1622
+
1623
+ stdout , _ , err = cli .Run ("lib" , "examples" , "--format" , "json" )
1624
+ require .NoError (t , err )
1625
+ requirejson .Len (t , stdout , 1 )
1626
+ }
0 commit comments