Skip to content

Commit 158c626

Browse files
committed
add test for templates containing shifts
Signed-off-by: Martino Facchin <[email protected]>
1 parent bf70c66 commit 158c626

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/arduino.cc/builder/test/ctags_runner_test.go

+44
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,47 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) {
231231

232232
require.Equal(t, expectedOutput, strings.Replace(context[constants.CTX_CTAGS_OUTPUT].(string), "\r\n", "\n", -1))
233233
}
234+
235+
func TestCTagsRunnerSketchWithTemplates(t *testing.T) {
236+
DownloadCoresAndToolsAndLibraries(t)
237+
238+
context := make(map[string]interface{})
239+
240+
buildPath := SetupBuildPath(t, context)
241+
defer os.RemoveAll(buildPath)
242+
243+
sketchLocation := Abs(t, filepath.Join("sketch_with_templates_and_shift", "template_and_shift.cpp"))
244+
context[constants.CTX_HARDWARE_FOLDERS] = []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}
245+
context[constants.CTX_TOOLS_FOLDERS] = []string{"downloaded_tools"}
246+
context[constants.CTX_FQBN] = "arduino:avr:leonardo"
247+
context[constants.CTX_SKETCH_LOCATION] = sketchLocation
248+
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = "10600"
249+
context[constants.CTX_BUILT_IN_LIBRARIES_FOLDERS] = []string{"downloaded_libraries"}
250+
context[constants.CTX_OTHER_LIBRARIES_FOLDERS] = []string{"libraries"}
251+
context[constants.CTX_VERBOSE] = true
252+
253+
commands := []types.Command{
254+
&builder.SetupHumanLoggerIfMissing{},
255+
256+
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
257+
258+
&builder.ContainerMergeCopySketchFiles{},
259+
260+
&builder.ContainerFindIncludes{},
261+
262+
&builder.PrintUsedLibrariesIfVerbose{},
263+
&builder.WarnAboutArchIncompatibleLibraries{},
264+
&builder.CTagsTargetFileSaver{SourceField: constants.CTX_SOURCE, TargetFileName: constants.FILE_CTAGS_TARGET},
265+
&ctags.CTagsRunner{},
266+
}
267+
268+
for _, command := range commands {
269+
err := command.Run(context)
270+
NoError(t, err)
271+
}
272+
273+
sketchLocation = strings.Replace(sketchLocation, "\\", "\\\\", -1)
274+
expectedOutput := "printGyro\t" + sketchLocation + "\t/^void printGyro()$/;\"\tkind:function\tline:8\tsignature:()\treturntype:void\n"
275+
276+
require.Equal(t, expectedOutput, strings.Replace(context[constants.CTX_CTAGS_OUTPUT].(string), "\r\n", "\n", -1))
277+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
template<> class FastPin<0> : public _ARMPIN<0, 10, 1 << 10, 0> {};;
2+
3+
template <class SomeType, template <class> class OtherType> class NestedTemplateClass
4+
{
5+
OtherType<SomeType> f;
6+
};
7+
8+
void printGyro()
9+
{
10+
}

0 commit comments

Comments
 (0)