Skip to content

Commit 48f4a2a

Browse files
committed
Simplified ctags_runner test
1 parent f3c8208 commit 48f4a2a

File tree

1 file changed

+30
-85
lines changed

1 file changed

+30
-85
lines changed

legacy/builder/test/ctags_runner_test.go

Lines changed: 30 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,12 @@ func TestCTagsRunner(t *testing.T) {
4545
buildPath := SetupBuildPath(t, ctx)
4646
defer buildPath.RemoveAll()
4747

48-
var _err error
49-
var ctagsOutput []byte
50-
commands := []types.Command{
51-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
52-
types.BareCommand(func(ctx *types.Context) error {
53-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
54-
return _err
55-
}),
56-
types.BareCommand(func(ctx *types.Context) error {
57-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
58-
return _err
59-
}),
60-
}
61-
for _, command := range commands {
62-
err := command.Run(ctx)
63-
NoError(t, err)
64-
}
48+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
49+
NoError(t, err)
50+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, nil, ctx.SketchBuildPath)
51+
NoError(t, err)
52+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
53+
NoError(t, err)
6554

6655
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
6756
expectedOutput := "server " + quotedSketchLocation + " /^BridgeServer server;$/;\" kind:variable line:31\n" +
@@ -92,23 +81,12 @@ func TestCTagsRunnerSketchWithClass(t *testing.T) {
9281
buildPath := SetupBuildPath(t, ctx)
9382
defer buildPath.RemoveAll()
9483

95-
var _err error
96-
var ctagsOutput []byte
97-
commands := []types.Command{
98-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
99-
types.BareCommand(func(ctx *types.Context) error {
100-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
101-
return _err
102-
}),
103-
types.BareCommand(func(ctx *types.Context) error {
104-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
105-
return _err
106-
}),
107-
}
108-
for _, command := range commands {
109-
err := command.Run(ctx)
110-
NoError(t, err)
111-
}
84+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
85+
NoError(t, err)
86+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
87+
NoError(t, err)
88+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
89+
NoError(t, err)
11290

11391
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
11492
expectedOutput := "set_values\t" + quotedSketchLocation + "\t/^ void set_values (int,int);$/;\"\tkind:prototype\tline:4\tclass:Rectangle\tsignature:(int,int)\treturntype:void\n" +
@@ -137,23 +115,12 @@ func TestCTagsRunnerSketchWithTypename(t *testing.T) {
137115
buildPath := SetupBuildPath(t, ctx)
138116
defer buildPath.RemoveAll()
139117

140-
var _err error
141-
var ctagsOutput []byte
142-
commands := []types.Command{
143-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
144-
types.BareCommand(func(ctx *types.Context) error {
145-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
146-
return _err
147-
}),
148-
types.BareCommand(func(ctx *types.Context) error {
149-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
150-
return _err
151-
}),
152-
}
153-
for _, command := range commands {
154-
err := command.Run(ctx)
155-
NoError(t, err)
156-
}
118+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
119+
NoError(t, err)
120+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
121+
NoError(t, err)
122+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
123+
NoError(t, err)
157124

158125
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
159126
expectedOutput := "Foo\t" + quotedSketchLocation + "\t/^ struct Foo{$/;\"\tkind:struct\tline:2\n" +
@@ -181,23 +148,12 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) {
181148
buildPath := SetupBuildPath(t, ctx)
182149
defer buildPath.RemoveAll()
183150

184-
var _err error
185-
var ctagsOutput []byte
186-
commands := []types.Command{
187-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
188-
types.BareCommand(func(ctx *types.Context) error {
189-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
190-
return _err
191-
}),
192-
types.BareCommand(func(ctx *types.Context) error {
193-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
194-
return _err
195-
}),
196-
}
197-
for _, command := range commands {
198-
err := command.Run(ctx)
199-
NoError(t, err)
200-
}
151+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
152+
NoError(t, err)
153+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
154+
NoError(t, err)
155+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
156+
NoError(t, err)
201157

202158
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
203159
expectedOutput := "value\t" + quotedSketchLocation + "\t/^\tint value() {$/;\"\tkind:function\tline:2\tnamespace:Test\tsignature:()\treturntype:int\n" +
@@ -224,23 +180,12 @@ func TestCTagsRunnerSketchWithTemplates(t *testing.T) {
224180
buildPath := SetupBuildPath(t, ctx)
225181
defer buildPath.RemoveAll()
226182

227-
var _err error
228-
var ctagsOutput []byte
229-
commands := []types.Command{
230-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
231-
types.BareCommand(func(ctx *types.Context) error {
232-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
233-
return _err
234-
}),
235-
types.BareCommand(func(ctx *types.Context) error {
236-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
237-
return _err
238-
}),
239-
}
240-
for _, command := range commands {
241-
err := command.Run(ctx)
242-
NoError(t, err)
243-
}
183+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
184+
NoError(t, err)
185+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
186+
NoError(t, err)
187+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
188+
NoError(t, err)
244189

245190
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
246191
expectedOutput := "printGyro\t" + quotedSketchLocation + "\t/^void printGyro()$/;\"\tkind:function\tline:10\tsignature:()\treturntype:void\n" +

0 commit comments

Comments
 (0)