Skip to content

Commit aa9e438

Browse files
committed
Simplified ctags_runner test
1 parent a58c901 commit aa9e438

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
@@ -32,23 +32,12 @@ func TestCTagsRunner(t *testing.T) {
3232
defer cleanUpBuilderTestContext(t, ctx)
3333
ctx.Verbose = true
3434

35-
var _err error
36-
var ctagsOutput []byte
37-
commands := []types.Command{
38-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
39-
types.BareCommand(func(ctx *types.Context) error {
40-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
41-
return _err
42-
}),
43-
types.BareCommand(func(ctx *types.Context) error {
44-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
45-
return _err
46-
}),
47-
}
48-
for _, command := range commands {
49-
err := command.Run(ctx)
50-
NoError(t, err)
51-
}
35+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
36+
NoError(t, err)
37+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, nil, ctx.SketchBuildPath)
38+
NoError(t, err)
39+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
40+
NoError(t, err)
5241

5342
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
5443
expectedOutput := "server " + quotedSketchLocation + " /^BridgeServer server;$/;\" kind:variable line:31\n" +
@@ -67,23 +56,12 @@ func TestCTagsRunnerSketchWithClass(t *testing.T) {
6756
defer cleanUpBuilderTestContext(t, ctx)
6857
ctx.Verbose = true
6958

70-
var _err error
71-
var ctagsOutput []byte
72-
commands := []types.Command{
73-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
74-
types.BareCommand(func(ctx *types.Context) error {
75-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
76-
return _err
77-
}),
78-
types.BareCommand(func(ctx *types.Context) error {
79-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
80-
return _err
81-
}),
82-
}
83-
for _, command := range commands {
84-
err := command.Run(ctx)
85-
NoError(t, err)
86-
}
59+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
60+
NoError(t, err)
61+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
62+
NoError(t, err)
63+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
64+
NoError(t, err)
8765

8866
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
8967
expectedOutput := "set_values\t" + quotedSketchLocation + "\t/^ void set_values (int,int);$/;\"\tkind:prototype\tline:4\tclass:Rectangle\tsignature:(int,int)\treturntype:void\n" +
@@ -100,23 +78,12 @@ func TestCTagsRunnerSketchWithTypename(t *testing.T) {
10078
defer cleanUpBuilderTestContext(t, ctx)
10179
ctx.Verbose = true
10280

103-
var _err error
104-
var ctagsOutput []byte
105-
commands := []types.Command{
106-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
107-
types.BareCommand(func(ctx *types.Context) error {
108-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
109-
return _err
110-
}),
111-
types.BareCommand(func(ctx *types.Context) error {
112-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
113-
return _err
114-
}),
115-
}
116-
for _, command := range commands {
117-
err := command.Run(ctx)
118-
NoError(t, err)
119-
}
81+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
82+
NoError(t, err)
83+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
84+
NoError(t, err)
85+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
86+
NoError(t, err)
12087

12188
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
12289
expectedOutput := "Foo\t" + quotedSketchLocation + "\t/^ struct Foo{$/;\"\tkind:struct\tline:2\n" +
@@ -132,23 +99,12 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) {
13299
defer cleanUpBuilderTestContext(t, ctx)
133100
ctx.Verbose = true
134101

135-
var _err error
136-
var ctagsOutput []byte
137-
commands := []types.Command{
138-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
139-
types.BareCommand(func(ctx *types.Context) error {
140-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
141-
return _err
142-
}),
143-
types.BareCommand(func(ctx *types.Context) error {
144-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
145-
return _err
146-
}),
147-
}
148-
for _, command := range commands {
149-
err := command.Run(ctx)
150-
NoError(t, err)
151-
}
102+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
103+
NoError(t, err)
104+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
105+
NoError(t, err)
106+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
107+
NoError(t, err)
152108

153109
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
154110
expectedOutput := "value\t" + quotedSketchLocation + "\t/^\tint value() {$/;\"\tkind:function\tline:2\tnamespace:Test\tsignature:()\treturntype:int\n" +
@@ -163,23 +119,12 @@ func TestCTagsRunnerSketchWithTemplates(t *testing.T) {
163119
defer cleanUpBuilderTestContext(t, ctx)
164120
ctx.Verbose = true
165121

166-
var _err error
167-
var ctagsOutput []byte
168-
commands := []types.Command{
169-
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
170-
types.BareCommand(func(ctx *types.Context) error {
171-
ctx.LineOffset, ctx.SketchSourceMerged, _err = bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
172-
return _err
173-
}),
174-
types.BareCommand(func(ctx *types.Context) error {
175-
ctagsOutput, _, _, _, _err = builder.RunCTags(ctx.Sketch, ctx.SketchSourceMerged, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
176-
return _err
177-
}),
178-
}
179-
for _, command := range commands {
180-
err := command.Run(ctx)
181-
NoError(t, err)
182-
}
122+
err := (&builder.ContainerSetupHardwareToolsLibsSketchAndProps{}).Run(ctx)
123+
NoError(t, err)
124+
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
125+
NoError(t, err)
126+
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
127+
NoError(t, err)
183128

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

0 commit comments

Comments
 (0)