@@ -28,6 +28,46 @@ import (
2828 "gopkg.in/src-d/go-git.v4/plumbing"
2929)
3030
31+ func TestCompileManuallyInstalledPlatformUsingBoardsLocalTxt (t * testing.T ) {
32+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
33+ defer env .CleanUp ()
34+
35+ _ , _ , err := cli .Run ("update" )
36+ require .NoError (t , err )
37+
38+ sketchName := "CompileSketchManuallyInstalledPlatformUsingBoardsLocalTxt"
39+ sketchPath := cli .SketchbookDir ().Join (sketchName )
40+ fqbn := "arduino-beta-development:avr:nessuno"
41+ _ , _ , err = cli .Run ("sketch" , "new" , sketchPath .String ())
42+ require .NoError (t , err )
43+
44+ // Manually installs a core in sketchbooks hardware folder
45+ gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
46+ repoDir := cli .SketchbookDir ().Join ("hardware" , "arduino-beta-development" , "avr" )
47+ _ , err = git .PlainClone (repoDir .String (), false , & git.CloneOptions {
48+ URL : gitUrl ,
49+ ReferenceName : plumbing .NewTagReferenceName ("1.8.3" ),
50+ })
51+ require .NoError (t , err )
52+
53+ // Installs also the same core via CLI so all the necessary tools are installed
54+ _ , _ , err = cli .Run ("core" , "install" , "arduino:avr@1.8.3" )
55+ require .NoError (t , err )
56+
57+ // Verifies compilation fails because board doesn't exist
58+ _ , stderr , err := cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
59+ require .Error (t , err )
60+ require .Contains (t , string (stderr ), "Error during build: Error resolving FQBN: board arduino-beta-development:avr:nessuno not found" )
61+
62+ // Use custom boards.local.txt with made arduino:avr:nessuno board
63+ boardsLocalTxt := repoDir .Join ("boards.local.txt" )
64+ err = paths .New (".." , "testdata" , "boards.local.txt" ).CopyTo (boardsLocalTxt )
65+ require .NoError (t , err )
66+
67+ _ , _ , err = cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
68+ require .NoError (t , err )
69+ }
70+
3171func TestCompileWithLibrary (t * testing.T ) {
3272 env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
3373 defer env .CleanUp ()
0 commit comments