@@ -105,3 +105,48 @@ func TestCompileWithExportBinariesFlag(t *testing.T) {
105
105
require .FileExists (t , sketchPath .Join ("build" , fqbn , sketchName + ".ino.with_bootloader.bin" ).String ())
106
106
require .FileExists (t , sketchPath .Join ("build" , fqbn , sketchName + ".ino.with_bootloader.hex" ).String ())
107
107
}
108
+
109
+ func TestCompileWithCustomBuildPath (t * testing.T ) {
110
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
111
+ defer env .CleanUp ()
112
+
113
+ // Init the environment explicitly
114
+ _ , _ , err := cli .Run ("core" , "update-index" )
115
+ require .NoError (t , err )
116
+
117
+ // Download latest AVR
118
+ _ , _ , err = cli .Run ("core" , "install" , "arduino:avr" )
119
+ require .NoError (t , err )
120
+
121
+ sketchName := "CompileWithBuildPath"
122
+ sketchPath := cli .SketchbookDir ().Join (sketchName )
123
+ fqbn := "arduino:avr:uno"
124
+
125
+ // Create a test sketch
126
+ _ , _ , err = cli .Run ("sketch" , "new" , sketchPath .String ())
127
+ require .NoError (t , err )
128
+
129
+ // Test the --build-path flag with absolute path
130
+ buildPath := cli .DataDir ().Join ("test_dir" , "build_dir" )
131
+ _ , _ , err = cli .Run ("compile" , "-b" , fqbn , sketchPath .String (), "--build-path" , buildPath .String ())
132
+ require .NoError (t , err )
133
+
134
+ // Verifies expected binaries have been built to build_path
135
+ require .DirExists (t , buildPath .String ())
136
+ require .FileExists (t , buildPath .Join (sketchName + ".ino.eep" ).String ())
137
+ require .FileExists (t , buildPath .Join (sketchName + ".ino.elf" ).String ())
138
+ require .FileExists (t , buildPath .Join (sketchName + ".ino.hex" ).String ())
139
+ require .FileExists (t , buildPath .Join (sketchName + ".ino.with_bootloader.bin" ).String ())
140
+ require .FileExists (t , buildPath .Join (sketchName + ".ino.with_bootloader.hex" ).String ())
141
+
142
+ // Verifies there are no binaries in temp directory
143
+ md5 := md5 .Sum (([]byte (sketchPath .String ())))
144
+ sketchPathMd5 := strings .ToUpper (hex .EncodeToString (md5 [:]))
145
+ require .NotEmpty (t , sketchPathMd5 )
146
+ buildDir := paths .TempDir ().Join ("arduino-sketch-" + sketchPathMd5 )
147
+ require .NoFileExists (t , buildDir .Join (sketchName + ".ino.eep" ).String ())
148
+ require .NoFileExists (t , buildDir .Join (sketchName + ".ino.elf" ).String ())
149
+ require .NoFileExists (t , buildDir .Join (sketchName + ".ino.hex" ).String ())
150
+ require .NoFileExists (t , buildDir .Join (sketchName + ".ino.with_bootloader.bin" ).String ())
151
+ require .NoFileExists (t , buildDir .Join (sketchName + ".ino.with_bootloader.hex" ).String ())
152
+ }
0 commit comments