@@ -469,3 +469,41 @@ def test_core_install_removes_unused_tools(run_command, data_dir):
469
469
470
470
# Verifies tool is uninstalled since it's not used by newer core version
471
471
assert not tool_path .exists ()
472
+
473
+
474
+ def test_core_list_with_installed_json (run_command , data_dir ):
475
+ assert run_command ("update" )
476
+
477
+ # Install core
478
+ url = "https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"
479
+ assert run_command (f"core update-index --additional-urls={ url } " )
480
+ assert run_command (
f"core install adafruit:[email protected] --additional-urls={ url } " )
481
+
482
+ # Verifies installed core is correctly found and name is set
483
+ res = run_command ("core list --format json" )
484
+ assert res .ok
485
+ cores = json .loads (res .stdout )
486
+ mapped = {core ["ID" ]: core for core in cores }
487
+ assert len (mapped ) == 1
488
+ assert "adafruit:avr" in mapped
489
+ assert mapped ["adafruit:avr" ]["Name" ] == "Adafruit AVR Boards"
490
+
491
+ # Deletes installed.json file, this file stores information about the core,
492
+ # that is used mostly when removing package indexes and their cores are still installed;
493
+ # this way we don't lose much information about it.
494
+ # It might happen that the user has old cores installed before the addition of
495
+ # the installed.json file so we need to handle those cases.
496
+ installed_json = Path (data_dir , "packages" , "adafruit" , "hardware" , "avr" , "1.4.13" , "installed.json" )
497
+ installed_json .unlink ()
498
+
499
+ # Verifies installed core is still found and name is set
500
+ res = run_command ("core list --format json" )
501
+ assert res .ok
502
+ cores = json .loads (res .stdout )
503
+ mapped = {core ["ID" ]: core for core in cores }
504
+ assert len (mapped ) == 1
505
+ assert "adafruit:avr" in mapped
506
+ # Name for this core changes since if there's installed.json file we read it from
507
+ # platform.txt, turns out that this core has different names used in different files
508
+ # thus the change.
509
+ assert mapped ["adafruit:avr" ]["Name" ] == "Adafruit Boards"
0 commit comments