@@ -102,7 +102,6 @@ func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
102102 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
103103 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
104104 context [constants .CTX_VERBOSE ] = true
105- context [constants .CTX_DEBUG_LEVEL ] = 10
106105
107106 commands := []types.Command {
108107 & builder.SetupHumanLoggerIfMissing {},
@@ -144,7 +143,6 @@ func TestPrototypesAdderBaladuino(t *testing.T) {
144143 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
145144 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
146145 context [constants .CTX_VERBOSE ] = true
147- context [constants .CTX_DEBUG_LEVEL ] = 10
148146
149147 commands := []types.Command {
150148 & builder.SetupHumanLoggerIfMissing {},
@@ -186,7 +184,6 @@ func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
186184 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
187185 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
188186 context [constants .CTX_VERBOSE ] = true
189- context [constants .CTX_DEBUG_LEVEL ] = 10
190187
191188 commands := []types.Command {
192189 & builder.SetupHumanLoggerIfMissing {},
@@ -228,7 +225,6 @@ func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
228225 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
229226 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
230227 context [constants .CTX_VERBOSE ] = true
231- context [constants .CTX_DEBUG_LEVEL ] = 10
232228
233229 commands := []types.Command {
234230 & builder.SetupHumanLoggerIfMissing {},
@@ -270,7 +266,6 @@ func TestPrototypesAdderLineContinuations(t *testing.T) {
270266 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
271267 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
272268 context [constants .CTX_VERBOSE ] = true
273- context [constants .CTX_DEBUG_LEVEL ] = 10
274269
275270 commands := []types.Command {
276271 & builder.SetupHumanLoggerIfMissing {},
@@ -312,7 +307,6 @@ func TestPrototypesAdderStringWithComment(t *testing.T) {
312307 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
313308 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
314309 context [constants .CTX_VERBOSE ] = true
315- context [constants .CTX_DEBUG_LEVEL ] = 10
316310
317311 commands := []types.Command {
318312 & builder.SetupHumanLoggerIfMissing {},
@@ -354,7 +348,6 @@ func TestPrototypesAdderSketchWithStruct(t *testing.T) {
354348 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
355349 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
356350 context [constants .CTX_VERBOSE ] = true
357- context [constants .CTX_DEBUG_LEVEL ] = 10
358351
359352 commands := []types.Command {
360353 & builder.SetupHumanLoggerIfMissing {},
@@ -399,7 +392,6 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
399392 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
400393 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
401394 context [constants .CTX_VERBOSE ] = true
402- context [constants .CTX_DEBUG_LEVEL ] = 10
403395
404396 commands := []types.Command {
405397 & builder.SetupHumanLoggerIfMissing {},
@@ -444,7 +436,6 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
444436 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
445437 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
446438 context [constants .CTX_VERBOSE ] = true
447- context [constants .CTX_DEBUG_LEVEL ] = 10
448439
449440 commands := []types.Command {
450441 & builder.SetupHumanLoggerIfMissing {},
@@ -486,7 +477,6 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
486477 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
487478 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
488479 context [constants .CTX_VERBOSE ] = true
489- context [constants .CTX_DEBUG_LEVEL ] = 10
490480
491481 commands := []types.Command {
492482 & builder.SetupHumanLoggerIfMissing {},
@@ -531,7 +521,6 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
531521 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
532522 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
533523 context [constants .CTX_VERBOSE ] = true
534- context [constants .CTX_DEBUG_LEVEL ] = 10
535524
536525 commands := []types.Command {
537526 & builder.SetupHumanLoggerIfMissing {},
@@ -576,7 +565,6 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
576565 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
577566 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
578567 context [constants .CTX_VERBOSE ] = true
579- context [constants .CTX_DEBUG_LEVEL ] = 10
580568
581569 commands := []types.Command {
582570 & builder.SetupHumanLoggerIfMissing {},
@@ -621,7 +609,6 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
621609 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
622610 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
623611 context [constants .CTX_VERBOSE ] = true
624- context [constants .CTX_DEBUG_LEVEL ] = 10
625612
626613 commands := []types.Command {
627614 & builder.SetupHumanLoggerIfMissing {},
@@ -666,7 +653,6 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
666653 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
667654 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
668655 context [constants .CTX_VERBOSE ] = true
669- context [constants .CTX_DEBUG_LEVEL ] = 10
670656
671657 commands := []types.Command {
672658 & builder.SetupHumanLoggerIfMissing {},
@@ -710,7 +696,6 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
710696 context [constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ] = "10600"
711697 context [constants .CTX_LIBRARIES_FOLDERS ] = []string {"libraries" , "downloaded_libraries" }
712698 context [constants .CTX_VERBOSE ] = true
713- context [constants .CTX_DEBUG_LEVEL ] = 10
714699
715700 commands := []types.Command {
716701 & builder.SetupHumanLoggerIfMissing {},
@@ -755,7 +740,6 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
755740 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
756741 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
757742 context [constants .CTX_VERBOSE ] = true
758- context [constants .CTX_DEBUG_LEVEL ] = 10
759743
760744 commands := []types.Command {
761745 & builder.SetupHumanLoggerIfMissing {},
@@ -803,7 +787,6 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
803787 context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
804788 context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"libraries" }
805789 context [constants .CTX_VERBOSE ] = true
806- context [constants .CTX_DEBUG_LEVEL ] = 10
807790
808791 commands := []types.Command {
809792 & builder.SetupHumanLoggerIfMissing {},
@@ -831,3 +814,47 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
831814 expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.SAM.txt" ), context )
832815 require .Equal (t , expectedSource , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
833816}
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