@@ -25,6 +25,33 @@ import (
25
25
"gopkg.in/src-d/go-git.v4/plumbing"
26
26
)
27
27
28
+ func TestCompilePart3 (t * testing.T ) {
29
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
30
+ defer env .CleanUp ()
31
+
32
+ _ , _ , err := cli .Run ("update" )
33
+ require .NoError (t , err )
34
+
35
+ // Manually installs a core in sketchbooks hardware folder
36
+ gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
37
+ repoDir := cli .SketchbookDir ().Join ("hardware" , "arduino-beta-development" , "avr" )
38
+ _ , err = git .PlainClone (repoDir .String (), false , & git.CloneOptions {
39
+ URL : gitUrl ,
40
+ ReferenceName : plumbing .NewTagReferenceName ("1.8.3" ),
41
+ })
42
+ require .NoError (t , err )
43
+
44
+ // Installs also the same core via CLI so all the necessary tools are installed
45
+ _ ,
_ ,
err = cli .
Run (
"core" ,
"install" ,
"arduino:[email protected] " )
46
+ require .NoError (t , err )
47
+
48
+ integrationtest.CLISubtests {
49
+ {"ManuallyInstalledPlatform" , compileManuallyInstalledPlatform },
50
+ {"ManuallyInstalledPlatformUsingPlatformLocalTxt" , compileManuallyInstalledPlatformUsingPlatformLocalTxt },
51
+ {"ManuallyInstalledPlatformUsingBoardsLocalTxt" , compileManuallyInstalledPlatformUsingBoardsLocalTxt },
52
+ }.Run (t , env , cli )
53
+ }
54
+
28
55
func TestCompileWithFullyPrecompiledLibrary (t * testing.T ) {
29
56
env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
30
57
defer env .CleanUp ()
@@ -61,73 +88,65 @@ func TestCompileWithFullyPrecompiledLibrary(t *testing.T) {
61
88
require .Contains (t , string (stdout ), "Skipping dependencies detection for precompiled library Arduino_TensorFlowLite" )
62
89
}
63
90
64
- func TestCompileManuallyInstalledPlatform (t * testing.T ) {
65
- env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
66
- defer env .CleanUp ()
67
-
68
- _ , _ , err := cli .Run ("update" )
69
- require .NoError (t , err )
70
-
91
+ func compileManuallyInstalledPlatform (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI ) {
71
92
sketchName := "CompileSketchManuallyInstalledPlatformUsingPlatformLocalTxt"
72
93
sketchPath := cli .SketchbookDir ().Join (sketchName )
94
+ defer sketchPath .RemoveAll ()
73
95
fqbn := "arduino-beta-development:avr:uno"
74
- _ , _ , err = cli .Run ("sketch" , "new" , sketchPath .String ())
75
- require .NoError (t , err )
76
-
77
- // Manually installs a core in sketchbooks hardware folder
78
- gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
79
- repoDir := cli .SketchbookDir ().Join ("hardware" , "arduino-beta-development" , "avr" )
80
- _ , err = git .PlainClone (repoDir .String (), false , & git.CloneOptions {
81
- URL : gitUrl ,
82
- ReferenceName : plumbing .NewTagReferenceName ("1.8.3" ),
83
- })
84
- require .NoError (t , err )
85
-
86
- // Installs also the same core via CLI so all the necessary tools are installed
87
- _ ,
_ ,
err = cli .
Run (
"core" ,
"install" ,
"arduino:[email protected] " )
96
+ _ , _ , err := cli .Run ("sketch" , "new" , sketchPath .String ())
88
97
require .NoError (t , err )
89
98
90
99
// Verifies compilation works without issues
91
100
_ , _ , err = cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
92
101
require .NoError (t , err )
93
102
}
94
103
95
- func TestCompileManuallyInstalledPlatformUsingPlatformLocalTxt (t * testing.T ) {
96
- env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
97
- defer env .CleanUp ()
98
-
99
- _ , _ , err := cli .Run ("update" )
100
- require .NoError (t , err )
101
-
104
+ func compileManuallyInstalledPlatformUsingPlatformLocalTxt (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI ) {
102
105
sketchName := "CompileSketchManuallyInstalledPlatformUsingPlatformLocalTxt"
103
106
sketchPath := cli .SketchbookDir ().Join (sketchName )
107
+ defer sketchPath .RemoveAll ()
104
108
fqbn := "arduino-beta-development:avr:uno"
105
- _ , _ , err = cli .Run ("sketch" , "new" , sketchPath .String ())
106
- require .NoError (t , err )
107
-
108
- // Manually installs a core in sketchbooks hardware folder
109
- gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
110
- repoDir := cli .SketchbookDir ().Join ("hardware" , "arduino-beta-development" , "avr" )
111
- _ , err = git .PlainClone (repoDir .String (), false , & git.CloneOptions {
112
- URL : gitUrl ,
113
- ReferenceName : plumbing .NewTagReferenceName ("1.8.3" ),
114
- })
115
- require .NoError (t , err )
116
-
117
- // Installs also the same core via CLI so all the necessary tools are installed
118
- _ ,
_ ,
err = cli .
Run (
"core" ,
"install" ,
"arduino:[email protected] " )
109
+ _ , _ , err := cli .Run ("sketch" , "new" , sketchPath .String ())
119
110
require .NoError (t , err )
120
111
121
112
// Verifies compilation works without issues
122
113
_ , _ , err = cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
123
114
require .NoError (t , err )
124
115
125
116
// Overrides default platform compiler with an unexisting one
117
+ repoDir := cli .SketchbookDir ().Join ("hardware" , "arduino-beta-development" , "avr" )
126
118
platformLocalTxt := repoDir .Join ("platform.local.txt" )
119
+ defer platformLocalTxt .Remove ()
127
120
platformLocalTxt .WriteFile ([]byte ("compiler.c.cmd=my-compiler-that-does-not-exist" ))
128
121
129
122
// Verifies compilation now fails because compiler is not found
130
123
_ , stderr , err := cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
131
124
require .Error (t , err )
132
125
require .Contains (t , string (stderr ), "my-compiler-that-does-not-exist" )
133
126
}
127
+
128
+ func compileManuallyInstalledPlatformUsingBoardsLocalTxt (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI ) {
129
+ sketchName := "CompileSketchManuallyInstalledPlatformUsingBoardsLocalTxt"
130
+ sketchPath := cli .SketchbookDir ().Join (sketchName )
131
+ defer sketchPath .RemoveAll ()
132
+ fqbn := "arduino-beta-development:avr:nessuno"
133
+ _ , _ , err := cli .Run ("sketch" , "new" , sketchPath .String ())
134
+ require .NoError (t , err )
135
+
136
+ // Verifies compilation fails because board doesn't exist
137
+ _ , stderr , err := cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
138
+ require .Error (t , err )
139
+ require .Contains (t , string (stderr ), "Error during build: Error resolving FQBN: board arduino-beta-development:avr:nessuno not found" )
140
+
141
+ // Use custom boards.local.txt with made arduino:avr:nessuno board
142
+ repoDir := cli .SketchbookDir ().Join ("hardware" , "arduino-beta-development" , "avr" )
143
+ boardsLocalTxt := repoDir .Join ("boards.local.txt" )
144
+ defer boardsLocalTxt .Remove ()
145
+ wd , err := paths .Getwd ()
146
+ require .NoError (t , err )
147
+ err = wd .Parent ().Join ("testdata" , "boards.local.txt" ).CopyTo (boardsLocalTxt )
148
+ require .NoError (t , err )
149
+
150
+ _ , _ , err = cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
151
+ require .NoError (t , err )
152
+ }
0 commit comments