@@ -82,8 +82,8 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
8282 NoError (t , err )
8383 }
8484
85- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
86- require .Equal (t , "#line 33 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 46 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 62 \" " + absoluteSketchLocation + "\" \n void process(BridgeClient client);\n #line 82 \" " + absoluteSketchLocation + "\" \n void digitalCommand(BridgeClient client);\n #line 109 \" " + absoluteSketchLocation + "\" \n void analogCommand(BridgeClient client);\n #line 149 \" " + absoluteSketchLocation + "\" \n void modeCommand(BridgeClient client);\n #line 33\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
85+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
86+ require .Equal (t , "#line 33 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 46 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 62 \" " + absoluteSketchLocation + "\" \n void process(BridgeClient client);\n #line 82 \" " + absoluteSketchLocation + "\" \n void digitalCommand(BridgeClient client);\n #line 109 \" " + absoluteSketchLocation + "\" \n void analogCommand(BridgeClient client);\n #line 149 \" " + absoluteSketchLocation + "\" \n void modeCommand(BridgeClient client);\n #line 33 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
8787}
8888
8989func TestPrototypesAdderSketchWithIfDef (t * testing.T ) {
@@ -418,8 +418,8 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
418418 NoError (t , err )
419419 }
420420
421- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
422- require .Equal (t , "#line 13 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 17 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 13\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
421+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
422+ require .Equal (t , "#line 13 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 17 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 13 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
423423
424424 preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch_with_config" , "sketch_with_config.preprocessed.txt" ), context )
425425 require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
@@ -433,6 +433,9 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
433433 buildPath := SetupBuildPath (t , context )
434434 defer os .RemoveAll (buildPath )
435435
436+ sketchLocation := filepath .Join ("sketch_no_functions_two_files" , "main.ino" )
437+ absoluteSketchLocation := strings .Replace (Abs (t , sketchLocation ), "\\ " , "\\ \\ " , - 1 )
438+
436439 context [constants .CTX_HARDWARE_FOLDERS ] = []string {filepath .Join (".." , "hardware" ), "hardware" , "downloaded_hardware" }
437440 context [constants .CTX_TOOLS_FOLDERS ] = []string {"downloaded_tools" }
438441 context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
@@ -462,7 +465,7 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
462465 NoError (t , err )
463466 }
464467
465- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
468+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
466469 require .Nil (t , context [constants .CTX_PROTOTYPE_SECTION ])
467470}
468471
@@ -474,6 +477,9 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
474477 buildPath := SetupBuildPath (t , context )
475478 defer os .RemoveAll (buildPath )
476479
480+ sketchLocation := filepath .Join ("sketch_no_functions" , "main.ino" )
481+ absoluteSketchLocation := strings .Replace (Abs (t , sketchLocation ), "\\ " , "\\ \\ " , - 1 )
482+
477483 context [constants .CTX_HARDWARE_FOLDERS ] = []string {filepath .Join (".." , "hardware" ), "hardware" , "downloaded_hardware" }
478484 context [constants .CTX_TOOLS_FOLDERS ] = []string {"downloaded_tools" }
479485 context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
@@ -503,7 +509,7 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
503509 NoError (t , err )
504510 }
505511
506- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
512+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
507513 require .Nil (t , context [constants .CTX_PROTOTYPE_SECTION ])
508514}
509515
@@ -547,8 +553,8 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
547553 NoError (t , err )
548554 }
549555
550- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
551- require .Equal (t , "#line 4 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 7 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 1\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
556+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
557+ require .Equal (t , "#line 4 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 7 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
552558}
553559
554560func TestPrototypesAdderSketchWithInlineFunction (t * testing.T ) {
@@ -591,9 +597,9 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
591597 NoError (t , err )
592598 }
593599
594- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
600+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
595601
596- expected := "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 2 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 4 \" " + absoluteSketchLocation + "\" \n short unsigned int testInt();\n #line 8 \" " + absoluteSketchLocation + "\" \n static int8_t testInline();\n #line 12 \" " + absoluteSketchLocation + "\" \n __attribute__((always_inline)) uint8_t testAttribute();\n #line 1\n "
602+ expected := "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 2 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 4 \" " + absoluteSketchLocation + "\" \n short unsigned int testInt();\n #line 8 \" " + absoluteSketchLocation + "\" \n static int8_t testInline();\n #line 12 \" " + absoluteSketchLocation + "\" \n __attribute__((always_inline)) uint8_t testAttribute();\n #line 1 \" " + absoluteSketchLocation + " \" \n "
597603 obtained := context [constants .CTX_PROTOTYPE_SECTION ].(string )
598604 // ctags based preprocessing removes "inline" but this is still OK
599605 // TODO: remove this exception when moving to a more powerful parser
@@ -646,8 +652,8 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
646652 NoError (t , err )
647653 }
648654
649- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
650- require .Equal (t , "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 3 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 15 \" " + absoluteSketchLocation + "\" \n int8_t adalight();\n #line 1\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
655+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
656+ require .Equal (t , "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 3 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 15 \" " + absoluteSketchLocation + "\" \n int8_t adalight();\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
651657}
652658
653659func TestPrototypesAdderSketchWithUSBCON (t * testing.T ) {
@@ -690,8 +696,8 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
690696 NoError (t , err )
691697 }
692698
693- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
694- require .Equal (t , "#line 5 \" " + absoluteSketchLocation + "\" \n void ciao();\n #line 10 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 15 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 5\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
699+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
700+ require .Equal (t , "#line 5 \" " + absoluteSketchLocation + "\" \n void ciao();\n #line 10 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 15 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 5 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
695701}
696702
697703func TestPrototypesAdderSketchWithTypename (t * testing.T ) {
@@ -733,8 +739,8 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
733739 NoError (t , err )
734740 }
735741
736- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
737- expected := "#line 6 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 10 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 12 \" " + absoluteSketchLocation + "\" \n typename Foo<char>::Bar func();\n #line 6\n "
742+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
743+ expected := "#line 6 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 10 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 12 \" " + absoluteSketchLocation + "\" \n typename Foo<char>::Bar func();\n #line 6 \" " + absoluteSketchLocation + " \" \n "
738744 obtained := context [constants .CTX_PROTOTYPE_SECTION ].(string )
739745 // ctags based preprocessing ignores line with typename
740746 // TODO: remove this exception when moving to a more powerful parser
@@ -783,8 +789,8 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
783789 NoError (t , err )
784790 }
785791
786- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
787- require .Equal (t , "#line 5 \" " + absoluteSketchLocation + "\" \n void elseBranch();\n #line 9 \" " + absoluteSketchLocation + "\" \n void f1();\n #line 10 \" " + absoluteSketchLocation + "\" \n void f2();\n #line 12 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 14 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 5\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
792+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
793+ require .Equal (t , "#line 5 \" " + absoluteSketchLocation + "\" \n void elseBranch();\n #line 9 \" " + absoluteSketchLocation + "\" \n void f1();\n #line 10 \" " + absoluteSketchLocation + "\" \n void f2();\n #line 12 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 14 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 5 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
788794
789795 expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.txt" ), context )
790796 require .Equal (t , expectedSource , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
@@ -830,8 +836,8 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
830836 NoError (t , err )
831837 }
832838
833- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
834- require .Equal (t , "#line 2 \" " + absoluteSketchLocation + "\" \n void ifBranch();\n #line 9 \" " + absoluteSketchLocation + "\" \n void f1();\n #line 10 \" " + absoluteSketchLocation + "\" \n void f2();\n #line 12 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 14 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 2\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
839+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
840+ require .Equal (t , "#line 2 \" " + absoluteSketchLocation + "\" \n void ifBranch();\n #line 9 \" " + absoluteSketchLocation + "\" \n void f1();\n #line 10 \" " + absoluteSketchLocation + "\" \n void f2();\n #line 12 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 14 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 2 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
835841
836842 expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.SAM.txt" ), context )
837843 require .Equal (t , expectedSource , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
@@ -877,8 +883,8 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) {
877883 NoError (t , err )
878884 }
879885
880- require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
881- 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 ))
886+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
887+ 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 \" " + absoluteSketchLocation + " \" \n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
882888}
883889
884890func TestPrototypesAdderSketchWithDosEol (t * testing.T ) {
0 commit comments