@@ -38,17 +38,17 @@ import (
38
38
"github.com/stretchr/testify/require"
39
39
)
40
40
41
- func producePrototypes (t * testing.T , filename string ) ([]* types.Prototype , int ) {
41
+ func producePrototypes (t * testing.T , filename string , mainFile string ) ([]* types.Prototype , int ) {
42
42
bytes , err := ioutil .ReadFile (filepath .Join ("test_data" , filename ))
43
43
require .NoError (t , err )
44
44
45
45
parser := & CTagsParser {}
46
- parser .Parse (string (bytes ))
46
+ parser .Parse (string (bytes ), mainFile )
47
47
return parser .GeneratePrototypes ()
48
48
}
49
49
50
50
func TestCTagsToPrototypesShouldListPrototypes (t * testing.T ) {
51
- prototypes , line := producePrototypes (t , "TestCTagsParserShouldListPrototypes.txt" )
51
+ prototypes , line := producePrototypes (t , "TestCTagsParserShouldListPrototypes.txt" , "/tmp/sketch7210316334309249705.cpp" )
52
52
require .Equal (t , 5 , len (prototypes ))
53
53
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
54
54
require .Equal (t , "/tmp/sketch7210316334309249705.cpp" , prototypes [0 ].File )
@@ -61,7 +61,7 @@ func TestCTagsToPrototypesShouldListPrototypes(t *testing.T) {
61
61
}
62
62
63
63
func TestCTagsToPrototypesShouldListTemplates (t * testing.T ) {
64
- prototypes , line := producePrototypes (t , "TestCTagsParserShouldListTemplates.txt" )
64
+ prototypes , line := producePrototypes (t , "TestCTagsParserShouldListTemplates.txt" , "/tmp/sketch8398023134925534708.cpp" )
65
65
66
66
require .Equal (t , 3 , len (prototypes ))
67
67
require .Equal (t , "template <typename T> T minimum (T a, T b);" , prototypes [0 ].Prototype )
@@ -73,7 +73,7 @@ func TestCTagsToPrototypesShouldListTemplates(t *testing.T) {
73
73
}
74
74
75
75
func TestCTagsToPrototypesShouldListTemplates2 (t * testing.T ) {
76
- prototypes , line := producePrototypes (t , "TestCTagsParserShouldListTemplates2.txt" )
76
+ prototypes , line := producePrototypes (t , "TestCTagsParserShouldListTemplates2.txt" , "/tmp/sketch463160524247569568.cpp" )
77
77
78
78
require .Equal (t , 4 , len (prototypes ))
79
79
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
@@ -86,15 +86,15 @@ func TestCTagsToPrototypesShouldListTemplates2(t *testing.T) {
86
86
}
87
87
88
88
func TestCTagsToPrototypesShouldDealWithClasses (t * testing.T ) {
89
- prototypes , line := producePrototypes (t , "TestCTagsParserShouldDealWithClasses.txt" )
89
+ prototypes , line := producePrototypes (t , "TestCTagsParserShouldDealWithClasses.txt" , "/tmp/sketch9043227824785312266.cpp" )
90
90
91
91
require .Equal (t , 0 , len (prototypes ))
92
92
93
93
require .Equal (t , 8 , line )
94
94
}
95
95
96
96
func TestCTagsToPrototypesShouldDealWithStructs (t * testing.T ) {
97
- prototypes , line := producePrototypes (t , "TestCTagsParserShouldDealWithStructs.txt" )
97
+ prototypes , line := producePrototypes (t , "TestCTagsParserShouldDealWithStructs.txt" , "/tmp/sketch8930345717354294915.cpp" )
98
98
99
99
require .Equal (t , 3 , len (prototypes ))
100
100
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
@@ -106,7 +106,7 @@ func TestCTagsToPrototypesShouldDealWithStructs(t *testing.T) {
106
106
}
107
107
108
108
func TestCTagsToPrototypesShouldDealWithMacros (t * testing.T ) {
109
- prototypes , line := producePrototypes (t , "TestCTagsParserShouldDealWithMacros.txt" )
109
+ prototypes , line := producePrototypes (t , "TestCTagsParserShouldDealWithMacros.txt" , "/tmp/sketch5976699731718729500.cpp" )
110
110
111
111
require .Equal (t , 5 , len (prototypes ))
112
112
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
@@ -120,7 +120,7 @@ func TestCTagsToPrototypesShouldDealWithMacros(t *testing.T) {
120
120
}
121
121
122
122
func TestCTagsToPrototypesShouldDealFunctionWithDifferentSignatures (t * testing.T ) {
123
- prototypes , line := producePrototypes (t , "TestCTagsParserShouldDealFunctionWithDifferentSignatures.txt" )
123
+ prototypes , line := producePrototypes (t , "TestCTagsParserShouldDealFunctionWithDifferentSignatures.txt" , "/tmp/test260613593/preproc/ctags_target.cpp" )
124
124
125
125
require .Equal (t , 1 , len (prototypes ))
126
126
require .Equal (t , "boolean getBytes( byte addr, int amount );" , prototypes [0 ].Prototype )
@@ -130,7 +130,7 @@ func TestCTagsToPrototypesShouldDealFunctionWithDifferentSignatures(t *testing.T
130
130
}
131
131
132
132
func TestCTagsToPrototypesClassMembersAreFilteredOut (t * testing.T ) {
133
- prototypes , line := producePrototypes (t , "TestCTagsParserClassMembersAreFilteredOut.txt" )
133
+ prototypes , line := producePrototypes (t , "TestCTagsParserClassMembersAreFilteredOut.txt" , "/tmp/test834438754/preproc/ctags_target.cpp" )
134
134
135
135
require .Equal (t , 2 , len (prototypes ))
136
136
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
@@ -141,7 +141,7 @@ func TestCTagsToPrototypesClassMembersAreFilteredOut(t *testing.T) {
141
141
}
142
142
143
143
func TestCTagsToPrototypesStructWithFunctions (t * testing.T ) {
144
- prototypes , line := producePrototypes (t , "TestCTagsParserStructWithFunctions.txt" )
144
+ prototypes , line := producePrototypes (t , "TestCTagsParserStructWithFunctions.txt" , "/tmp/build7315640391316178285.tmp/preproc/ctags_target.cpp" )
145
145
146
146
require .Equal (t , 2 , len (prototypes ))
147
147
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
@@ -152,7 +152,7 @@ func TestCTagsToPrototypesStructWithFunctions(t *testing.T) {
152
152
}
153
153
154
154
func TestCTagsToPrototypesDefaultArguments (t * testing.T ) {
155
- prototypes , line := producePrototypes (t , "TestCTagsParserDefaultArguments.txt" )
155
+ prototypes , line := producePrototypes (t , "TestCTagsParserDefaultArguments.txt" , "/tmp/test179252494/preproc/ctags_target.cpp" )
156
156
157
157
require .Equal (t , 3 , len (prototypes ))
158
158
require .Equal (t , "void test(int x = 1);" , prototypes [0 ].Prototype )
@@ -164,7 +164,7 @@ func TestCTagsToPrototypesDefaultArguments(t *testing.T) {
164
164
}
165
165
166
166
func TestCTagsToPrototypesNamespace (t * testing.T ) {
167
- prototypes , line := producePrototypes (t , "TestCTagsParserNamespace.txt" )
167
+ prototypes , line := producePrototypes (t , "TestCTagsParserNamespace.txt" , "/tmp/test030883150/preproc/ctags_target.cpp" )
168
168
169
169
require .Equal (t , 2 , len (prototypes ))
170
170
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
@@ -175,7 +175,7 @@ func TestCTagsToPrototypesNamespace(t *testing.T) {
175
175
}
176
176
177
177
func TestCTagsToPrototypesStatic (t * testing.T ) {
178
- prototypes , line := producePrototypes (t , "TestCTagsParserStatic.txt" )
178
+ prototypes , line := producePrototypes (t , "TestCTagsParserStatic.txt" , "/tmp/test542833488/preproc/ctags_target.cpp" )
179
179
180
180
require .Equal (t , 3 , len (prototypes ))
181
181
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
@@ -188,7 +188,7 @@ func TestCTagsToPrototypesStatic(t *testing.T) {
188
188
}
189
189
190
190
func TestCTagsToPrototypesFunctionPointer (t * testing.T ) {
191
- prototypes , line := producePrototypes (t , "TestCTagsParserFunctionPointer.txt" )
191
+ prototypes , line := producePrototypes (t , "TestCTagsParserFunctionPointer.txt" , "/tmp/test547238273/preproc/ctags_target.cpp" )
192
192
193
193
require .Equal (t , 3 , len (prototypes ))
194
194
require .Equal (t , "void t1Callback();" , prototypes [0 ].Prototype )
@@ -200,7 +200,7 @@ func TestCTagsToPrototypesFunctionPointer(t *testing.T) {
200
200
}
201
201
202
202
func TestCTagsToPrototypesFunctionPointers (t * testing.T ) {
203
- prototypes , line := producePrototypes (t , "TestCTagsParserFunctionPointers.txt" )
203
+ prototypes , line := producePrototypes (t , "TestCTagsParserFunctionPointers.txt" , "/tmp/test907446433/preproc/ctags_target.cpp" )
204
204
require .Equal (t , 2 , len (prototypes ))
205
205
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
206
206
require .Equal (t , "/tmp/test907446433/preproc/ctags_target.cpp" , prototypes [0 ].File )
@@ -210,7 +210,7 @@ func TestCTagsToPrototypesFunctionPointers(t *testing.T) {
210
210
}
211
211
212
212
func TestCTagsToPrototypesFunctionPointersNoIndirect (t * testing.T ) {
213
- prototypes , line := producePrototypes (t , "TestCTagsParserFunctionPointersNoIndirect.txt" )
213
+ prototypes , line := producePrototypes (t , "TestCTagsParserFunctionPointersNoIndirect.txt" , "/tmp/test547238273/preproc/bug_callback.ino" )
214
214
require .Equal (t , 5 , len (prototypes ))
215
215
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
216
216
require .Equal (t , "/tmp/test547238273/preproc/bug_callback.ino" , prototypes [0 ].File )
@@ -220,10 +220,19 @@ func TestCTagsToPrototypesFunctionPointersNoIndirect(t *testing.T) {
220
220
}
221
221
222
222
func TestCTagsRunnerSketchWithClassFunction (t * testing.T ) {
223
- prototypes , _ := producePrototypes (t , "TestCTagsRunnerSketchWithClassFunction.txt" )
223
+ prototypes , _ := producePrototypes (t , "TestCTagsRunnerSketchWithClassFunction.txt" , "/home/megabug/Workspace/arduino-builder/src/arduino.cc/builder/test/sketch_class_function/sketch_class_function.ino" )
224
224
225
225
require .Equal (t , 3 , len (prototypes ))
226
226
require .Equal (t , "void setup();" , prototypes [0 ].Prototype )
227
227
require .Equal (t , "void loop();" , prototypes [1 ].Prototype )
228
228
require .Equal (t , "void asdf();" , prototypes [2 ].Prototype )
229
229
}
230
+
231
+ func TestCTagsRunnerSketchWithMultiFile (t * testing.T ) {
232
+ prototypes , line := producePrototypes (t , "TestCTagsRunnerSketchWithMultifile.txt" , "/tmp/apUNI8a/main.ino" )
233
+
234
+ require .Equal (t , 0 , line )
235
+ require .Equal (t , "void A7105_Setup();" , prototypes [0 ].Prototype )
236
+ require .Equal (t , "void A7105_Reset();" , prototypes [1 ].Prototype )
237
+ require .Equal (t , "int A7105_calibrate_VCB(uint8_t channel);" , prototypes [2 ].Prototype )
238
+ }
0 commit comments