@@ -38,17 +38,17 @@ import (
3838"github.com/stretchr/testify/require"
3939)
4040
41- func producePrototypes (t * testing.T ,filename string ) ([]* types.Prototype ,int ) {
41+ func producePrototypes (t * testing.T ,filename string , mainFile string ) ([]* types.Prototype ,int ) {
4242bytes ,err := ioutil .ReadFile (filepath .Join ("test_data" ,filename ))
4343require .NoError (t ,err )
4444
4545parser := & CTagsParser {}
46- parser .Parse (string (bytes ))
46+ parser .Parse (string (bytes ), mainFile )
4747return parser .GeneratePrototypes ()
4848}
4949
5050func TestCTagsToPrototypesShouldListPrototypes (t * testing.T ) {
51- prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldListPrototypes.txt" )
51+ prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldListPrototypes.txt" , "/tmp/sketch7210316334309249705.cpp" )
5252require .Equal (t ,5 ,len (prototypes ))
5353require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
5454require .Equal (t ,"/tmp/sketch7210316334309249705.cpp" ,prototypes [0 ].File )
@@ -61,7 +61,7 @@ func TestCTagsToPrototypesShouldListPrototypes(t *testing.T) {
6161}
6262
6363func TestCTagsToPrototypesShouldListTemplates (t * testing.T ) {
64- prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldListTemplates.txt" )
64+ prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldListTemplates.txt" , "/tmp/sketch8398023134925534708.cpp" )
6565
6666require .Equal (t ,3 ,len (prototypes ))
6767require .Equal (t ,"template <typename T> T minimum (T a, T b);" ,prototypes [0 ].Prototype )
@@ -73,7 +73,7 @@ func TestCTagsToPrototypesShouldListTemplates(t *testing.T) {
7373}
7474
7575func TestCTagsToPrototypesShouldListTemplates2 (t * testing.T ) {
76- prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldListTemplates2.txt" )
76+ prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldListTemplates2.txt" , "/tmp/sketch463160524247569568.cpp" )
7777
7878require .Equal (t ,4 ,len (prototypes ))
7979require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
@@ -86,15 +86,15 @@ func TestCTagsToPrototypesShouldListTemplates2(t *testing.T) {
8686}
8787
8888func TestCTagsToPrototypesShouldDealWithClasses (t * testing.T ) {
89- prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldDealWithClasses.txt" )
89+ prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldDealWithClasses.txt" , "/tmp/sketch9043227824785312266.cpp" )
9090
9191require .Equal (t ,0 ,len (prototypes ))
9292
9393require .Equal (t ,8 ,line )
9494}
9595
9696func TestCTagsToPrototypesShouldDealWithStructs (t * testing.T ) {
97- prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldDealWithStructs.txt" )
97+ prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldDealWithStructs.txt" , "/tmp/sketch8930345717354294915.cpp" )
9898
9999require .Equal (t ,3 ,len (prototypes ))
100100require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
@@ -106,7 +106,7 @@ func TestCTagsToPrototypesShouldDealWithStructs(t *testing.T) {
106106}
107107
108108func TestCTagsToPrototypesShouldDealWithMacros (t * testing.T ) {
109- prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldDealWithMacros.txt" )
109+ prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldDealWithMacros.txt" , "/tmp/sketch5976699731718729500.cpp" )
110110
111111require .Equal (t ,5 ,len (prototypes ))
112112require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
@@ -120,7 +120,7 @@ func TestCTagsToPrototypesShouldDealWithMacros(t *testing.T) {
120120}
121121
122122func TestCTagsToPrototypesShouldDealFunctionWithDifferentSignatures (t * testing.T ) {
123- prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldDealFunctionWithDifferentSignatures.txt" )
123+ prototypes ,line := producePrototypes (t ,"TestCTagsParserShouldDealFunctionWithDifferentSignatures.txt" , "/tmp/test260613593/preproc/ctags_target.cpp" )
124124
125125require .Equal (t ,1 ,len (prototypes ))
126126require .Equal (t ,"boolean getBytes( byte addr, int amount );" ,prototypes [0 ].Prototype )
@@ -130,7 +130,7 @@ func TestCTagsToPrototypesShouldDealFunctionWithDifferentSignatures(t *testing.T
130130}
131131
132132func TestCTagsToPrototypesClassMembersAreFilteredOut (t * testing.T ) {
133- prototypes ,line := producePrototypes (t ,"TestCTagsParserClassMembersAreFilteredOut.txt" )
133+ prototypes ,line := producePrototypes (t ,"TestCTagsParserClassMembersAreFilteredOut.txt" , "/tmp/test834438754/preproc/ctags_target.cpp" )
134134
135135require .Equal (t ,2 ,len (prototypes ))
136136require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
@@ -141,7 +141,7 @@ func TestCTagsToPrototypesClassMembersAreFilteredOut(t *testing.T) {
141141}
142142
143143func 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" )
145145
146146require .Equal (t ,2 ,len (prototypes ))
147147require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
@@ -152,7 +152,7 @@ func TestCTagsToPrototypesStructWithFunctions(t *testing.T) {
152152}
153153
154154func TestCTagsToPrototypesDefaultArguments (t * testing.T ) {
155- prototypes ,line := producePrototypes (t ,"TestCTagsParserDefaultArguments.txt" )
155+ prototypes ,line := producePrototypes (t ,"TestCTagsParserDefaultArguments.txt" , "/tmp/test179252494/preproc/ctags_target.cpp" )
156156
157157require .Equal (t ,3 ,len (prototypes ))
158158require .Equal (t ,"void test(int x = 1);" ,prototypes [0 ].Prototype )
@@ -164,7 +164,7 @@ func TestCTagsToPrototypesDefaultArguments(t *testing.T) {
164164}
165165
166166func TestCTagsToPrototypesNamespace (t * testing.T ) {
167- prototypes ,line := producePrototypes (t ,"TestCTagsParserNamespace.txt" )
167+ prototypes ,line := producePrototypes (t ,"TestCTagsParserNamespace.txt" , "/tmp/test030883150/preproc/ctags_target.cpp" )
168168
169169require .Equal (t ,2 ,len (prototypes ))
170170require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
@@ -175,7 +175,7 @@ func TestCTagsToPrototypesNamespace(t *testing.T) {
175175}
176176
177177func TestCTagsToPrototypesStatic (t * testing.T ) {
178- prototypes ,line := producePrototypes (t ,"TestCTagsParserStatic.txt" )
178+ prototypes ,line := producePrototypes (t ,"TestCTagsParserStatic.txt" , "/tmp/test542833488/preproc/ctags_target.cpp" )
179179
180180require .Equal (t ,3 ,len (prototypes ))
181181require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
@@ -188,7 +188,7 @@ func TestCTagsToPrototypesStatic(t *testing.T) {
188188}
189189
190190func TestCTagsToPrototypesFunctionPointer (t * testing.T ) {
191- prototypes ,line := producePrototypes (t ,"TestCTagsParserFunctionPointer.txt" )
191+ prototypes ,line := producePrototypes (t ,"TestCTagsParserFunctionPointer.txt" , "/tmp/test547238273/preproc/ctags_target.cpp" )
192192
193193require .Equal (t ,3 ,len (prototypes ))
194194require .Equal (t ,"void t1Callback();" ,prototypes [0 ].Prototype )
@@ -200,7 +200,7 @@ func TestCTagsToPrototypesFunctionPointer(t *testing.T) {
200200}
201201
202202func TestCTagsToPrototypesFunctionPointers (t * testing.T ) {
203- prototypes ,line := producePrototypes (t ,"TestCTagsParserFunctionPointers.txt" )
203+ prototypes ,line := producePrototypes (t ,"TestCTagsParserFunctionPointers.txt" , "/tmp/test907446433/preproc/ctags_target.cpp" )
204204require .Equal (t ,2 ,len (prototypes ))
205205require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
206206require .Equal (t ,"/tmp/test907446433/preproc/ctags_target.cpp" ,prototypes [0 ].File )
@@ -210,7 +210,7 @@ func TestCTagsToPrototypesFunctionPointers(t *testing.T) {
210210}
211211
212212func TestCTagsToPrototypesFunctionPointersNoIndirect (t * testing.T ) {
213- prototypes ,line := producePrototypes (t ,"TestCTagsParserFunctionPointersNoIndirect.txt" )
213+ prototypes ,line := producePrototypes (t ,"TestCTagsParserFunctionPointersNoIndirect.txt" , "/tmp/test547238273/preproc/bug_callback.ino" )
214214require .Equal (t ,5 ,len (prototypes ))
215215require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
216216require .Equal (t ,"/tmp/test547238273/preproc/bug_callback.ino" ,prototypes [0 ].File )
@@ -220,10 +220,19 @@ func TestCTagsToPrototypesFunctionPointersNoIndirect(t *testing.T) {
220220}
221221
222222func 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" )
224224
225225require .Equal (t ,3 ,len (prototypes ))
226226require .Equal (t ,"void setup();" ,prototypes [0 ].Prototype )
227227require .Equal (t ,"void loop();" ,prototypes [1 ].Prototype )
228228require .Equal (t ,"void asdf();" ,prototypes [2 ].Prototype )
229229}
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+ }