394
394
395
395
@pytest .mark .skipif (running_on_ci (), reason = "VMs have no serial ports" )
396
396
def test_board_list (run_command ):
397
- run_command ("core update-index" )
398
- result = run_command ("board list --format json" )
397
+ run_command ([ "core" , " update-index"] )
398
+ result = run_command ([ "board" , " list" , " --format" , " json"] )
399
399
assert result .ok
400
400
# check is a valid json and contains a list of ports
401
401
ports = json .loads (result .stdout )
@@ -406,9 +406,9 @@ def test_board_list(run_command):
406
406
407
407
408
408
def test_board_listall (run_command ):
409
- assert run_command ("update" )
410
- assert run_command (
"core install arduino:[email protected] " )
411
- res = run_command ("board listall --format json" )
409
+ assert run_command ([ "update" ] )
410
+ assert run_command (
[ "core" , " install" , " arduino:[email protected] "] )
411
+ res = run_command ([ "board" , " listall" , " --format" , " json"] )
412
412
assert res .ok
413
413
data = json .loads (res .stdout )
414
414
boards = {b ["fqbn" ]: b for b in data ["boards" ]}
@@ -431,14 +431,14 @@ def test_board_listall(run_command):
431
431
432
432
433
433
def test_board_listall_with_manually_installed_platform (run_command , data_dir ):
434
- assert run_command ("update" )
434
+ assert run_command ([ "update" ] )
435
435
436
436
# Manually installs a core in sketchbooks hardware folder
437
437
git_url = "https://github.com/arduino/ArduinoCore-samd.git"
438
438
repo_dir = Path (data_dir , "hardware" , "arduino-beta-development" , "samd" )
439
439
assert Repo .clone_from (git_url , repo_dir , multi_options = ["-b 1.8.11" ])
440
440
441
- res = run_command ("board listall --format json" )
441
+ res = run_command ([ "board" , " listall" , " --format" , " json"] )
442
442
assert res .ok
443
443
data = json .loads (res .stdout )
444
444
boards = {b ["fqbn" ]: b for b in data ["boards" ]}
@@ -461,21 +461,21 @@ def test_board_listall_with_manually_installed_platform(run_command, data_dir):
461
461
462
462
463
463
def test_board_details (run_command ):
464
- run_command ("core update-index" )
464
+ run_command ([ "core" , " update-index"] )
465
465
# Download samd core pinned to 1.8.6
466
- run_command (
"core install arduino:[email protected] " )
466
+ run_command (
[ "core" , " install" , " arduino:[email protected] "] )
467
467
468
468
# Test board listall with and without showing hidden elements
469
- result = run_command ("board listall MIPS --format json" )
469
+ result = run_command ([ "board" , " listall" , " MIPS" , " --format" , " json"] )
470
470
assert result .ok
471
471
assert result .stdout == "{}\n "
472
472
473
- result = run_command ("board listall MIPS -a --format json" )
473
+ result = run_command ([ "board" , " listall" , " MIPS" , "-a" , " --format" , " json"] )
474
474
assert result .ok
475
475
result = json .loads (result .stdout )
476
476
assert result ["boards" ][0 ]["name" ] == "Arduino Tian (MIPS Console port)"
477
477
478
- result = run_command ("board details -b arduino:samd:nano_33_iot --format json" )
478
+ result = run_command ([ "board" , " details" , "-b" , " arduino:samd:nano_33_iot" , " --format" , " json"] )
479
479
assert result .ok
480
480
# Sort everything before compare
481
481
result = json .loads (result .stdout )
@@ -494,20 +494,20 @@ def test_board_details(run_command):
494
494
assert programmer in result ["programmers" ]
495
495
496
496
# Download samd core pinned to 1.8.8
497
- run_command (
"core install arduino:[email protected] " )
497
+ run_command (
[ "core" , " install" , " arduino:[email protected] "] )
498
498
499
- result = run_command ("board details -b arduino:samd:nano_33_iot --format json" )
499
+ result = run_command ([ "board" , " details" , "-b" , " arduino:samd:nano_33_iot" , " --format" , " json"] )
500
500
assert result .ok
501
501
result = json .loads (result .stdout )
502
502
assert result ["debugging_supported" ] is True
503
503
504
504
505
505
# old `arduino-cli board details` did not need -b <fqbn> flag to work
506
506
def test_board_details_old (run_command ):
507
- run_command ("core update-index" )
507
+ run_command ([ "core" , " update-index"] )
508
508
# Download samd core pinned to 1.8.6
509
- run_command (
"core install arduino:[email protected] " )
510
- result = run_command ("board details arduino:samd:nano_33_iot --format json" )
509
+ run_command (
[ "core" , " install" , " arduino:[email protected] "] )
510
+ result = run_command ([ "board" , " details" , " arduino:samd:nano_33_iot" , " --format" , " json"] )
511
511
assert result .ok
512
512
# Sort everything before compare
513
513
result = json .loads (result .stdout )
@@ -527,20 +527,20 @@ def test_board_details_old(run_command):
527
527
528
528
529
529
def test_board_details_no_flags (run_command ):
530
- run_command ("core update-index" )
530
+ run_command ([ "core" , " update-index"] )
531
531
# Download samd core pinned to 1.8.6
532
- run_command (
"core install arduino:[email protected] " )
533
- result = run_command ("board details" )
532
+ run_command (
[ "core" , " install" , " arduino:[email protected] "] )
533
+ result = run_command ([ "board" , " details"] )
534
534
assert not result .ok
535
535
assert "Error getting board details: Invalid FQBN:" in result .stderr
536
536
assert result .stdout == ""
537
537
538
538
539
539
def test_board_details_list_programmers_without_flag (run_command ):
540
- run_command ("core update-index" )
540
+ run_command ([ "core" , " update-index"] )
541
541
# Download samd core pinned to 1.8.6
542
- run_command (
"core install arduino:[email protected] " )
543
- result = run_command ("board details -b arduino:samd:nano_33_iot" )
542
+ run_command (
[ "core" , " install" , " arduino:[email protected] "] )
543
+ result = run_command ([ "board" , " details" , "-b" , " arduino:samd:nano_33_iot"] )
544
544
assert result .ok
545
545
lines = [l .strip ().split () for l in result .stdout .splitlines ()]
546
546
assert ["Programmers:" , "Id" , "Name" ] in lines
@@ -550,10 +550,10 @@ def test_board_details_list_programmers_without_flag(run_command):
550
550
551
551
552
552
def test_board_details_list_programmers_flag (run_command ):
553
- run_command ("core update-index" )
553
+ run_command ([ "core" , " update-index"] )
554
554
# Download samd core pinned to 1.8.6
555
- run_command (
"core install arduino:[email protected] " )
556
- result = run_command ("board details -b arduino:samd:nano_33_iot --list-programmers" )
555
+ run_command (
[ "core" , " install" , " arduino:[email protected] "] )
556
+ result = run_command ([ "board" , " details" , "-b" , " arduino:samd:nano_33_iot" , " --list-programmers"] )
557
557
assert result .ok
558
558
559
559
lines = [l .strip () for l in result .stdout .splitlines ()]
@@ -564,9 +564,9 @@ def test_board_details_list_programmers_flag(run_command):
564
564
565
565
566
566
def test_board_search (run_command , data_dir ):
567
- assert run_command ("update" )
567
+ assert run_command ([ "update" ] )
568
568
569
- res = run_command ("board search --format json" )
569
+ res = run_command ([ "board" , " search" , " --format" , " json"] )
570
570
assert res .ok
571
571
data = json .loads (res .stdout )
572
572
# Verifies boards are returned
@@ -581,7 +581,7 @@ def test_board_search(run_command, data_dir):
581
581
assert "Arduino Portenta H7" in names
582
582
583
583
# Search in non installed boards
584
- res = run_command ("board search --format json nano 33" )
584
+ res = run_command ([ "board" , " search" , " --format" , " json" , " nano" , " 33"] )
585
585
assert res .ok
586
586
data = json .loads (res .stdout )
587
587
# Verifies boards are returned
@@ -593,9 +593,9 @@ def test_board_search(run_command, data_dir):
593
593
assert "Arduino Nano 33 IoT" in names
594
594
595
595
# Install a platform from index
596
- assert run_command (
"core install arduino:[email protected] " )
596
+ assert run_command (
[ "core" , " install" , " arduino:[email protected] "] )
597
597
598
- res = run_command ("board search --format json" )
598
+ res = run_command ([ "board" , " search" , " --format" , " json"] )
599
599
assert res .ok
600
600
data = json .loads (res .stdout )
601
601
assert len (data ) > 0
@@ -607,7 +607,7 @@ def test_board_search(run_command, data_dir):
607
607
assert "arduino:avr:yun" in installed_boards
608
608
assert "Arduino Yún" == installed_boards ["arduino:avr:yun" ]["name" ]
609
609
610
- res = run_command ("board search --format json arduino yun" )
610
+ res = run_command ([ "board" , " search" , " --format" , " json" , " arduino" , " yun"] )
611
611
assert res .ok
612
612
data = json .loads (res .stdout )
613
613
assert len (data ) > 0
@@ -620,7 +620,7 @@ def test_board_search(run_command, data_dir):
620
620
repo_dir = Path (data_dir , "hardware" , "arduino-beta-development" , "samd" )
621
621
assert Repo .clone_from (git_url , repo_dir , multi_options = ["-b 1.8.11" ])
622
622
623
- res = run_command ("board search --format json" )
623
+ res = run_command ([ "board" , " search" , " --format" , " json"] )
624
624
assert res .ok
625
625
data = json .loads (res .stdout )
626
626
assert len (data ) > 0
@@ -641,7 +641,7 @@ def test_board_search(run_command, data_dir):
641
641
assert "Arduino NANO 33 IoT" == installed_boards ["arduino-beta-development:samd:nano_33_iot" ]["name" ]
642
642
assert "arduino-beta-development:samd:arduino_zero_native" in installed_boards
643
643
644
- res = run_command ("board search --format json mkr1000" )
644
+ res = run_command ([ "board" , " search" , " --format" , " json" , " mkr1000"] )
645
645
assert res .ok
646
646
data = json .loads (res .stdout )
647
647
assert len (data ) > 0
@@ -652,25 +652,25 @@ def test_board_search(run_command, data_dir):
652
652
653
653
654
654
def test_board_attach_without_sketch_json (run_command , data_dir ):
655
- run_command ("update" )
655
+ run_command ([ "update" ] )
656
656
657
657
sketch_name = "BoardAttachWithoutSketchJson"
658
658
sketch_path = Path (data_dir , sketch_name )
659
659
fqbn = "arduino:avr:uno"
660
660
661
661
# Create a test sketch
662
- assert run_command (f "sketch new { sketch_path } " )
662
+ assert run_command ([ "sketch" , " new" , sketch_path ] )
663
663
664
- assert run_command (f "board attach { fqbn } { sketch_path } " )
664
+ assert run_command ([ "board" , " attach" , fqbn , sketch_path ] )
665
665
666
666
667
667
def test_board_search_with_outdated_core (run_command ):
668
- assert run_command ("update" )
668
+ assert run_command ([ "update" ] )
669
669
670
670
# Install an old core version
671
- assert run_command (
"core install arduino:[email protected] " )
671
+ assert run_command (
[ "core" , " install" , " arduino:[email protected] "] )
672
672
673
- res = run_command ("board search arduino:samd:mkrwifi1010 --format json" )
673
+ res = run_command ([ "board" , " search" , " arduino:samd:mkrwifi1010" , " --format" , " json"] )
674
674
675
675
data = json .loads (res .stdout )
676
676
assert len (data ) == 1
0 commit comments