@@ -726,3 +726,44 @@ func generateBuildDir(sketchPath *paths.Path, t *testing.T) *paths.Path {
726
726
require .NoError (t , buildDir .ToAbs ())
727
727
return buildDir
728
728
}
729
+
730
+ func TestUploadWithInputDirFlag (t * testing.T ) {
731
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
732
+ defer env .CleanUp ()
733
+
734
+ _ , _ , err := cli .Run ("core" , "install" , "arduino:mbed_opta" )
735
+ require .NoError (t , err )
736
+
737
+ sketchPath := cli .SketchbookDir ().Join ("TestSketchForUpload" )
738
+ _ , _ , err = cli .Run ("sketch" , "new" , sketchPath .String ())
739
+ require .NoError (t , err )
740
+
741
+ // Create a fake build directory
742
+ buildDir := sketchPath .Join ("build" )
743
+ require .NoError (t , buildDir .MkdirAll ())
744
+ require .NoError (t , buildDir .Join ("TestSketchForUpload.ino.bin" ).WriteFile (nil ))
745
+ require .NoError (t , buildDir .Join ("TestSketchForUpload.ino.elf" ).WriteFile (nil ))
746
+ require .NoError (t , buildDir .Join ("TestSketchForUpload.ino.hex" ).WriteFile (nil ))
747
+ require .NoError (t , buildDir .Join ("TestSketchForUpload.ino.map" ).WriteFile (nil ))
748
+
749
+ // Test with input-dir flag
750
+ _ , _ , err = cli .Run (
751
+ "upload" ,
752
+ "-b" , "arduino:mbed_opta:opta" ,
753
+ "-i" , buildDir .String (),
754
+ "-t" ,
755
+ "-p" , "/dev/ttyACM0" ,
756
+ "--dry-run" , "-v" ,
757
+ sketchPath .String ())
758
+ require .NoError (t , err )
759
+
760
+ // Test with input-dir flag and no sketch
761
+ _ , _ , err = cli .Run (
762
+ "upload" ,
763
+ "-b" , "arduino:mbed_opta:opta" ,
764
+ "-i" , buildDir .String (),
765
+ "-t" ,
766
+ "-p" , "/dev/ttyACM0" ,
767
+ "--dry-run" , "-v" )
768
+ require .NoError (t , err )
769
+ }
0 commit comments