@@ -19,7 +19,6 @@ import (
1919 "encoding/json"
2020 "fmt"
2121 "os"
22- "path/filepath"
2322 "runtime"
2423 "sort"
2524 "strconv"
@@ -52,12 +51,16 @@ func TestCorrectHandlingOfPlatformVersionProperty(t *testing.T) {
5251 "platforms": [
5352 {
5453 "id":"DxCore-dev:megaavr",
54+ "manually_installed": true,
5555 "installed_version":"1.4.10",
5656 "releases": {
57- "1.4.10 ": {
57+ "": {
5858 "name":"DxCore"
5959 }
60- }
60+ },
61+ "installed_version": "",
62+ "latest_version": "",
63+ "has_manually_installed_release": true
6164 }
6265 ]
6366 }` )
@@ -512,63 +515,9 @@ func TestCoreListAllManuallyInstalledCore(t *testing.T) {
512515 requirejson .Contains (t , stdout , `{"platforms":[
513516 {
514517 "id": "arduino-beta-development:avr",
515- "latest_version": "1.8.3 ",
518+ "latest_version": "",
516519 "releases": {
517- "1.8.3": {
518- "name": "Arduino AVR Boards"
519- }
520- }
521- }
522- ]}` )
523- }
524-
525- func TestCoreListShowsLatestVersionWhenMultipleReleasesOfAManuallyInstalledCoreArePresent (t * testing.T ) {
526- env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
527- defer env .CleanUp ()
528-
529- _ , _ , err := cli .Run ("core" , "update-index" )
530- require .NoError (t , err )
531-
532- // Verifies only cores in board manager are shown
533- stdout , _ , err := cli .Run ("core" , "list" , "--all" , "--json" )
534- require .NoError (t , err )
535- requirejson .Query (t , stdout , `.platforms | length > 0` , `true` )
536- length , err := strconv .Atoi (requirejson .Parse (t , stdout ).Query (".platforms | length" ).String ())
537- require .NoError (t , err )
538-
539- // Manually installs a core in sketchbooks hardware folder
540- gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
541- repoDir := cli .SketchbookDir ().Join ("hardware" , "arduino-beta-development" , "avr" )
542- _ , err = git .PlainClone (filepath .Join (repoDir .String (), "1.8.3" ), false , & git.CloneOptions {
543- URL : gitUrl ,
544- ReferenceName : plumbing .NewTagReferenceName ("1.8.3" ),
545- })
546- require .NoError (t , err )
547-
548- tmp := paths .New (t .TempDir (), "1.8.4" )
549- _ , err = git .PlainClone (tmp .String (), false , & git.CloneOptions {
550- URL : gitUrl ,
551- ReferenceName : plumbing .NewTagReferenceName ("1.8.4" ),
552- })
553- require .NoError (t , err )
554-
555- err = tmp .Rename (repoDir .Join ("1.8.4" ))
556- require .NoError (t , err )
557-
558- // When manually installing 2 releases of the same core, the newest one takes precedence
559- stdout , _ , err = cli .Run ("core" , "list" , "--all" , "--json" )
560- require .NoError (t , err )
561- requirejson .Query (t , stdout , `.platforms | length` , fmt .Sprint (length + 1 ))
562- requirejson .Contains (t , stdout , `{"platforms":[
563- {
564- "id": "arduino-beta-development:avr",
565- "latest_version": "1.8.4",
566- "installed_version": "1.8.4",
567- "releases": {
568- "1.8.3": {
569- "name": "Arduino AVR Boards"
570- },
571- "1.8.3": {
520+ "": {
572521 "name": "Arduino AVR Boards"
573522 }
574523 }
@@ -606,12 +555,15 @@ func TestCoreListUpdatableAllFlags(t *testing.T) {
606555 requirejson .Contains (t , stdout , `{"platforms":[
607556 {
608557 "id": "arduino-beta-development:avr",
609- "latest_version": "1.8.3",
558+ "manually_installed": true,
559+ "installed_version": "",
560+ "latest_version": "",
610561 "releases": {
611- "1.8.3 ": {
562+ "": {
612563 "name": "Arduino AVR Boards"
613564 }
614- }
565+ },
566+ "has_manually_installed_release": true
615567 }
616568 ]}` )
617569}
@@ -1009,7 +961,7 @@ func TestCoreWithMissingCustomBoardOptionsIsLoaded(t *testing.T) {
1009961 {
1010962 "id": "arduino-beta-dev:platform_with_missing_custom_board_options",
1011963 "releases": {
1012- "4.2.0 ": {
964+ "": {
1013965 "boards": [
1014966 {
1015967 "fqbn": "arduino-beta-dev:platform_with_missing_custom_board_options:nessuno"
@@ -1396,10 +1348,10 @@ func TestCoreOverrideIfInstalledInSketchbook(t *testing.T) {
13961348 require .NoError (t , err )
13971349
13981350 // Copy it in the sketchbook hardware folder (simulate a user installed core)
1399- // avrCore := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.5")
1400- // avrCoreCopy := cli.SketchbookDir().Join("hardware", "arduino", "avr")
1401- // require.NoError(t, avrCoreCopy.Parent().MkdirAll())
1402- // require.NoError(t, avrCore.CopyDirTo(avrCoreCopy))
1351+ avrCore := cli .DataDir ().Join ("packages" , "arduino" , "hardware" , "avr" , "1.8.5" )
1352+ avrCoreCopy := cli .SketchbookDir ().Join ("hardware" , "arduino" , "avr" )
1353+ require .NoError (t , avrCoreCopy .Parent ().MkdirAll ())
1354+ require .NoError (t , avrCore .CopyDirTo (avrCoreCopy ))
14031355
14041356 // Install avr@1.8.6
14051357 _ , _ , err = cli .Run ("core" , "install" , "arduino:avr@1.8.6" )
@@ -1408,5 +1360,25 @@ func TestCoreOverrideIfInstalledInSketchbook(t *testing.T) {
14081360 // List cores and check that version 1.8.5 is listed
14091361 stdout , _ , err := cli .Run ("core" , "list" , "--json" )
14101362 require .NoError (t , err )
1411- requirejson .Query (t , stdout , `.platforms.[] | select(.id=="arduino:avr") | .installed_version` , `"1.8.5"` )
1363+ requirejson .Contains (t , stdout , `{
1364+ "platforms": [
1365+ {
1366+ "id": "arduino:avr",
1367+ "indexed": true,
1368+ "releases" : {
1369+ "": {
1370+ "name": "Arduino AVR Boards",
1371+ "installed": true
1372+ },
1373+ "1.8.6": {
1374+ "name": "Arduino AVR Boards",
1375+ "installed": true
1376+ }
1377+ },
1378+ "installed_version": "1.8.6",
1379+ "latest_version": "1.8.6",
1380+ "has_manually_installed_release": true
1381+ }
1382+ ]
1383+ }` )
14121384}
0 commit comments