@@ -848,6 +848,46 @@ func TestCoreListPlatformWithoutPlatformTxt(t *testing.T) {
848
848
requirejson .Query (t , stdout , ".[] | .name" , "\" some-packager-some-arch\" " )
849
849
}
850
850
851
+ func TestCoreDownloadMultiplePlatforms (t * testing.T ) {
852
+ if runtime .GOOS == "windows" || runtime .GOOS == "darwin" {
853
+ t .Skip ("macOS by default is case insensitive https://github.com/actions/virtual-environments/issues/865 " ,
854
+ "Windows too is case insensitive" ,
855
+ "https://stackoverflow.com/questions/7199039/file-paths-in-windows-environment-not-case-sensitive" )
856
+ }
857
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
858
+ defer env .CleanUp ()
859
+
860
+ _ , _ , err := cli .Run ("update" )
861
+ require .NoError (t , err )
862
+
863
+ // Verifies no core is installed
864
+ stdout , _ , err := cli .Run ("core" , "list" , "--format" , "json" )
865
+ require .NoError (t , err )
866
+ requirejson .Len (t , stdout , 0 )
867
+
868
+ // Simulates creation of two new cores in the sketchbook hardware folder
869
+ wd , _ := paths .Getwd ()
870
+ testBoardsTxt := wd .Parent ().Join ("testdata" , "boards.local.txt" )
871
+ boardsTxt := cli .DataDir ().Join ("packages" , "PACKAGER" , "hardware" , "ARCH" , "1.0.0" , "boards.txt" )
872
+ require .NoError (t , boardsTxt .Parent ().MkdirAll ())
873
+ require .NoError (t , testBoardsTxt .CopyTo (boardsTxt ))
874
+
875
+ boardsTxt1 := cli .DataDir ().Join ("packages" , "packager" , "hardware" , "arch" , "1.0.0" , "boards.txt" )
876
+ require .NoError (t , boardsTxt1 .Parent ().MkdirAll ())
877
+ require .NoError (t , testBoardsTxt .CopyTo (boardsTxt1 ))
878
+
879
+ // Verifies the two cores are detected
880
+ stdout , _ , err = cli .Run ("core" , "list" , "--format" , "json" )
881
+ require .NoError (t , err )
882
+ requirejson .Len (t , stdout , 2 )
883
+
884
+ // Try to do an operation on the fake cores.
885
+ // The cli should not allow it since optimizing the casing results in finding two cores
886
+ _ , stderr , err := cli .Run ("core" , "upgrade" , "Packager:Arch" )
887
+ require .Error (t , err )
888
+ require .Contains (t , string (stderr ), "Invalid argument passed: Found 2 platform for reference" )
889
+ }
890
+
851
891
func TestCoreWithMissingCustomBoardOptionsIsLoaded (t * testing.T ) {
852
892
env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
853
893
defer env .CleanUp ()
0 commit comments