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