@@ -82,8 +82,8 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
82
82
NoError (t , err )
83
83
}
84
84
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 ))
87
87
}
88
88
89
89
func TestPrototypesAdderSketchWithIfDef (t * testing.T ) {
@@ -418,8 +418,8 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
418
418
NoError (t , err )
419
419
}
420
420
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 ))
423
423
424
424
preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch_with_config" , "sketch_with_config.preprocessed.txt" ), context )
425
425
require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
@@ -433,6 +433,9 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
433
433
buildPath := SetupBuildPath (t , context )
434
434
defer os .RemoveAll (buildPath )
435
435
436
+ sketchLocation := filepath .Join ("sketch_no_functions_two_files" , "main.ino" )
437
+ absoluteSketchLocation := strings .Replace (Abs (t , sketchLocation ), "\\ " , "\\ \\ " , - 1 )
438
+
436
439
context [constants .CTX_HARDWARE_FOLDERS ] = []string {filepath .Join (".." , "hardware" ), "hardware" , "downloaded_hardware" }
437
440
context [constants .CTX_TOOLS_FOLDERS ] = []string {"downloaded_tools" }
438
441
context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
@@ -462,7 +465,7 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
462
465
NoError (t , err )
463
466
}
464
467
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 ))
466
469
require .Nil (t , context [constants .CTX_PROTOTYPE_SECTION ])
467
470
}
468
471
@@ -474,6 +477,9 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
474
477
buildPath := SetupBuildPath (t , context )
475
478
defer os .RemoveAll (buildPath )
476
479
480
+ sketchLocation := filepath .Join ("sketch_no_functions" , "main.ino" )
481
+ absoluteSketchLocation := strings .Replace (Abs (t , sketchLocation ), "\\ " , "\\ \\ " , - 1 )
482
+
477
483
context [constants .CTX_HARDWARE_FOLDERS ] = []string {filepath .Join (".." , "hardware" ), "hardware" , "downloaded_hardware" }
478
484
context [constants .CTX_TOOLS_FOLDERS ] = []string {"downloaded_tools" }
479
485
context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
@@ -503,7 +509,7 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
503
509
NoError (t , err )
504
510
}
505
511
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 ))
507
513
require .Nil (t , context [constants .CTX_PROTOTYPE_SECTION ])
508
514
}
509
515
@@ -547,8 +553,8 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
547
553
NoError (t , err )
548
554
}
549
555
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 ))
552
558
}
553
559
554
560
func TestPrototypesAdderSketchWithInlineFunction (t * testing.T ) {
@@ -591,9 +597,9 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
591
597
NoError (t , err )
592
598
}
593
599
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 ))
595
601
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 "
597
603
obtained := context [constants .CTX_PROTOTYPE_SECTION ].(string )
598
604
// ctags based preprocessing removes "inline" but this is still OK
599
605
// TODO: remove this exception when moving to a more powerful parser
@@ -646,8 +652,8 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
646
652
NoError (t , err )
647
653
}
648
654
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 ))
651
657
}
652
658
653
659
func TestPrototypesAdderSketchWithUSBCON (t * testing.T ) {
@@ -690,8 +696,8 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
690
696
NoError (t , err )
691
697
}
692
698
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 ))
695
701
}
696
702
697
703
func TestPrototypesAdderSketchWithTypename (t * testing.T ) {
@@ -733,8 +739,8 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
733
739
NoError (t , err )
734
740
}
735
741
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 "
738
744
obtained := context [constants .CTX_PROTOTYPE_SECTION ].(string )
739
745
// ctags based preprocessing ignores line with typename
740
746
// TODO: remove this exception when moving to a more powerful parser
@@ -783,8 +789,8 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
783
789
NoError (t , err )
784
790
}
785
791
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 ))
788
794
789
795
expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.txt" ), context )
790
796
require .Equal (t , expectedSource , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
@@ -830,8 +836,8 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
830
836
NoError (t , err )
831
837
}
832
838
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 ))
835
841
836
842
expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.SAM.txt" ), context )
837
843
require .Equal (t , expectedSource , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
@@ -877,8 +883,8 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) {
877
883
NoError (t , err )
878
884
}
879
885
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 ))
882
888
}
883
889
884
890
func TestPrototypesAdderSketchWithDosEol (t * testing.T ) {
0 commit comments