作者:facchin
项目:arduino-builde
func TestIncludesFinderWithRegExpEmptyOutput(t *testing.T) {
ctx := &types.Context{}
output := ""
ctx.Source = output
parser := builder.IncludesFinderWithRegExp{Source: &ctx.Source}
err := parser.Run(ctx)
NoError(t, err)
require.Equal(t, "", ctx.IncludeJustFound)
}
作者:facchin
项目:arduino-builde
func TestIncludesFinderWithRegExpPaddedIncludes4(t *testing.T) {
ctx := &types.Context{}
output := "In file included from /tmp/arduino_modified_sketch_815412/binouts.ino:52:0:\n" +
"/tmp/arduino_build_static/sketch/regtable.h:31:22: fatal error: register.h: No such file or directory\n"
ctx.Source = output
parser := builder.IncludesFinderWithRegExp{Source: &ctx.Source}
err := parser.Run(ctx)
NoError(t, err)
require.Equal(t, "register.h", ctx.IncludeJustFound)
}
作者:facchin
项目:arduino-builde
func TestIncludesFinderWithRegExpPaddedIncludes3(t *testing.T) {
ctx := &types.Context{}
output := "/some/path/sketch.ino:1:33: fatal error: SPI.h: No such file or directory\n" +
"compilation terminated.\n"
ctx.Source = output
parser := builder.IncludesFinderWithRegExp{Source: &ctx.Source}
err := parser.Run(ctx)
NoError(t, err)
require.Equal(t, "SPI.h", ctx.IncludeJustFound)
}
作者:cmagli
项目:arduino-builde
func TestIncludesFinderWithRegExpEmptyOutput(t *testing.T) {
context := make(map[string]interface{})
output := ""
context["source"] = output
parser := builder.IncludesFinderWithRegExp{ContextField: "source"}
err := parser.Run(context)
NoError(t, err)
require.NotNil(t, context[constants.CTX_INCLUDES])
includes := context[constants.CTX_INCLUDES].([]string)
require.Equal(t, 0, len(includes))
}
作者:me-no-de
项目:arduino-builde
func TestIncludesFinderWithRegExp(t *testing.T) {
ctx := &types.Context{}
output := "/some/path/sketch.ino:1:17: fatal error: SPI.h: No such file or directory\n" +
"#include <SPI.h>\n" +
"^\n" +
"compilation terminated."
ctx.Source = output
parser := builder.IncludesFinderWithRegExp{Source: &ctx.Source}
err := parser.Run(ctx)
NoError(t, err)
includes := ctx.Includes
require.Equal(t, 1, len(includes))
require.Equal(t, "SPI.h", includes[0])
}
作者:cmagli
项目:arduino-builde
func TestIncludesFinderWithRegExp(t *testing.T) {
context := make(map[string]interface{})
output := "/some/path/sketch.ino:1:17: fatal error: SPI.h: No such file or directory\n" +
"#include <SPI.h>\n" +
"^\n" +
"compilation terminated."
context["source"] = output
parser := builder.IncludesFinderWithRegExp{ContextField: "source"}
err := parser.Run(context)
NoError(t, err)
require.NotNil(t, context[constants.CTX_INCLUDES])
includes := context[constants.CTX_INCLUDES].([]string)
require.Equal(t, 1, len(includes))
require.Equal(t, "SPI.h", includes[0])
}
作者:ricklo
项目:arduino-builde
func TestIncludesFinderWithRegExp(t *testing.T) {
DownloadCoresAndToolsAndLibraries(t)
context := make(map[string]interface{})
buildPath := SetupBuildPath(t, context)
defer os.RemoveAll(buildPath)
context[constants.CTX_HARDWARE_FOLDERS] = []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}
context[constants.CTX_TOOLS_FOLDERS] = []string{"downloaded_tools"}
context[constants.CTX_FQBN] = "arduino:avr:leonardo"
context[constants.CTX_SKETCH_LOCATION] = filepath.Join("sketch2", "SketchWithIfDef.ino")
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = "10600"
context[constants.CTX_VERBOSE] = false
commands := []types.Command{
&builder.SetupHumanLoggerIfMissing{},
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
&builder.ContainerMergeCopySketchFiles{},
&builder.CoanRunner{},
}
for _, command := range commands {
err := command.Run(context)
NoError(t, err)
}
includesFinder := builder.IncludesFinderWithRegExp{}
err := includesFinder.Run(context)
NoError(t, err)
require.NotNil(t, context[constants.CTX_INCLUDES])
includes := context[constants.CTX_INCLUDES].([]string)
require.Equal(t, 2, len(includes))
require.Equal(t, "empty_1.h", includes[0])
require.Equal(t, "empty_2.h", includes[1])
}