@@ -102,7 +102,6 @@ func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
102
102
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
103
103
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
104
104
context [constants .CTX_VERBOSE ] = true
105
- context [constants .CTX_DEBUG_LEVEL ] = 10
106
105
107
106
commands := []types.Command {
108
107
& builder.SetupHumanLoggerIfMissing {},
@@ -144,7 +143,6 @@ func TestPrototypesAdderBaladuino(t *testing.T) {
144
143
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
145
144
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
146
145
context [constants .CTX_VERBOSE ] = true
147
- context [constants .CTX_DEBUG_LEVEL ] = 10
148
146
149
147
commands := []types.Command {
150
148
& builder.SetupHumanLoggerIfMissing {},
@@ -186,7 +184,6 @@ func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
186
184
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
187
185
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
188
186
context [constants .CTX_VERBOSE ] = true
189
- context [constants .CTX_DEBUG_LEVEL ] = 10
190
187
191
188
commands := []types.Command {
192
189
& builder.SetupHumanLoggerIfMissing {},
@@ -228,7 +225,6 @@ func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
228
225
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
229
226
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
230
227
context [constants .CTX_VERBOSE ] = true
231
- context [constants .CTX_DEBUG_LEVEL ] = 10
232
228
233
229
commands := []types.Command {
234
230
& builder.SetupHumanLoggerIfMissing {},
@@ -270,7 +266,6 @@ func TestPrototypesAdderLineContinuations(t *testing.T) {
270
266
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
271
267
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
272
268
context [constants .CTX_VERBOSE ] = true
273
- context [constants .CTX_DEBUG_LEVEL ] = 10
274
269
275
270
commands := []types.Command {
276
271
& builder.SetupHumanLoggerIfMissing {},
@@ -312,7 +307,6 @@ func TestPrototypesAdderStringWithComment(t *testing.T) {
312
307
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
313
308
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
314
309
context [constants .CTX_VERBOSE ] = true
315
- context [constants .CTX_DEBUG_LEVEL ] = 10
316
310
317
311
commands := []types.Command {
318
312
& builder.SetupHumanLoggerIfMissing {},
@@ -354,7 +348,6 @@ func TestPrototypesAdderSketchWithStruct(t *testing.T) {
354
348
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
355
349
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
356
350
context [constants .CTX_VERBOSE ] = true
357
- context [constants .CTX_DEBUG_LEVEL ] = 10
358
351
359
352
commands := []types.Command {
360
353
& builder.SetupHumanLoggerIfMissing {},
@@ -399,7 +392,6 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
399
392
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
400
393
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
401
394
context [constants .CTX_VERBOSE ] = true
402
- context [constants .CTX_DEBUG_LEVEL ] = 10
403
395
404
396
commands := []types.Command {
405
397
& builder.SetupHumanLoggerIfMissing {},
@@ -444,7 +436,6 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
444
436
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
445
437
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
446
438
context [constants .CTX_VERBOSE ] = true
447
- context [constants .CTX_DEBUG_LEVEL ] = 10
448
439
449
440
commands := []types.Command {
450
441
& builder.SetupHumanLoggerIfMissing {},
@@ -486,7 +477,6 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
486
477
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
487
478
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
488
479
context [constants .CTX_VERBOSE ] = true
489
- context [constants .CTX_DEBUG_LEVEL ] = 10
490
480
491
481
commands := []types.Command {
492
482
& builder.SetupHumanLoggerIfMissing {},
@@ -531,7 +521,6 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
531
521
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
532
522
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
533
523
context [constants .CTX_VERBOSE ] = true
534
- context [constants .CTX_DEBUG_LEVEL ] = 10
535
524
536
525
commands := []types.Command {
537
526
& builder.SetupHumanLoggerIfMissing {},
@@ -576,7 +565,6 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
576
565
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
577
566
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
578
567
context [constants .CTX_VERBOSE ] = true
579
- context [constants .CTX_DEBUG_LEVEL ] = 10
580
568
581
569
commands := []types.Command {
582
570
& builder.SetupHumanLoggerIfMissing {},
@@ -621,7 +609,6 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
621
609
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
622
610
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
623
611
context [constants .CTX_VERBOSE ] = true
624
- context [constants .CTX_DEBUG_LEVEL ] = 10
625
612
626
613
commands := []types.Command {
627
614
& builder.SetupHumanLoggerIfMissing {},
@@ -666,7 +653,6 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
666
653
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
667
654
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
668
655
context [constants .CTX_VERBOSE ] = true
669
- context [constants .CTX_DEBUG_LEVEL ] = 10
670
656
671
657
commands := []types.Command {
672
658
& builder.SetupHumanLoggerIfMissing {},
@@ -710,7 +696,6 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
710
696
context [constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ] = "10600"
711
697
context [constants .CTX_LIBRARIES_FOLDERS ] = []string {"libraries" , "downloaded_libraries" }
712
698
context [constants .CTX_VERBOSE ] = true
713
- context [constants .CTX_DEBUG_LEVEL ] = 10
714
699
715
700
commands := []types.Command {
716
701
& builder.SetupHumanLoggerIfMissing {},
@@ -755,7 +740,6 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
755
740
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
756
741
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
757
742
context [constants .CTX_VERBOSE ] = true
758
- context [constants .CTX_DEBUG_LEVEL ] = 10
759
743
760
744
commands := []types.Command {
761
745
& builder.SetupHumanLoggerIfMissing {},
@@ -803,7 +787,6 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
803
787
context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
804
788
context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
805
789
context [constants .CTX_VERBOSE ] = true
806
- context [constants .CTX_DEBUG_LEVEL ] = 10
807
790
808
791
commands := []types.Command {
809
792
& builder.SetupHumanLoggerIfMissing {},
@@ -831,3 +814,47 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
831
814
expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.SAM.txt" ), context )
832
815
require .Equal (t , expectedSource , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
833
816
}
817
+
818
+ func TestPrototypesAdderSketchWithConst (t * testing.T ) {
819
+ DownloadCoresAndToolsAndLibraries (t )
820
+
821
+ context := make (map [string ]interface {})
822
+
823
+ buildPath := SetupBuildPath (t , context )
824
+ defer os .RemoveAll (buildPath )
825
+
826
+ sketchLocation := filepath .Join ("sketch_with_const" , "sketch.ino" )
827
+ absoluteSketchLocation := strings .Replace (Abs (t , sketchLocation ), "\\ " , "\\ \\ " , - 1 )
828
+
829
+ context [constants .CTX_HARDWARE_FOLDERS ] = []string {filepath .Join (".." , "hardware" ), "hardware" , "downloaded_hardware" }
830
+ context [constants .CTX_TOOLS_FOLDERS ] = []string {"downloaded_tools" }
831
+ context [constants .CTX_FQBN ] = "arduino:avr:uno"
832
+ context [constants .CTX_SKETCH_LOCATION ] = sketchLocation
833
+ context [constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ] = "10600"
834
+ context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
835
+ context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
836
+ context [constants .CTX_VERBOSE ] = true
837
+
838
+ commands := []types.Command {
839
+ & builder.SetupHumanLoggerIfMissing {},
840
+
841
+ & builder.ContainerSetupHardwareToolsLibsSketchAndProps {},
842
+
843
+ & builder.ContainerMergeCopySketchFiles {},
844
+
845
+ & builder.ContainerFindIncludes {},
846
+
847
+ & builder.PrintUsedLibrariesIfVerbose {},
848
+ & builder.WarnAboutArchIncompatibleLibraries {},
849
+
850
+ & builder.ContainerAddPrototypes {},
851
+ }
852
+
853
+ for _ , command := range commands {
854
+ err := command .Run (context )
855
+ NoError (t , err )
856
+ }
857
+
858
+ require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
859
+ require .Equal (t , "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 2 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 4 \" " + absoluteSketchLocation + "\" \n const __FlashStringHelper* test();\n #line 6 \" " + absoluteSketchLocation + "\" \n const int test3();\n #line 8 \" " + absoluteSketchLocation + "\" \n volatile __FlashStringHelper* test2();\n #line 10 \" " + absoluteSketchLocation + "\" \n volatile int test4();\n #line 1\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
860
+ }
0 commit comments