func tryPreprocessWithContext(t *testing.T, ctx *types.Context, sketchPath ...string) { sketchLocation := filepath.Join(sketchPath...) ctx.SketchLocation = sketchLocation err := builder.RunPreprocess(ctx) NoError(t, err, "Build error for "+sketchLocation) }
func (s *SketchLoader) Run(ctx *types.Context) error { if ctx.SketchLocation == "" { return nil } sketchLocation := ctx.SketchLocation sketchLocation, err := filepath.Abs(sketchLocation) if err != nil { return i18n.WrapError(err) } mainSketchStat, err := os.Stat(sketchLocation) if err != nil { return i18n.WrapError(err) } if mainSketchStat.IsDir() { sketchLocation = filepath.Join(sketchLocation, mainSketchStat.Name()+".ino") } ctx.SketchLocation = sketchLocation allSketchFilePaths, err := collectAllSketchFiles(filepath.Dir(sketchLocation)) if err != nil { return i18n.WrapError(err) } logger := ctx.GetLogger() if !utils.SliceContains(allSketchFilePaths, sketchLocation) { return i18n.ErrorfWithLogger(logger, constants.MSG_CANT_FIND_SKETCH_IN_PATH, sketchLocation, filepath.Dir(sketchLocation)) } sketch, err := makeSketch(sketchLocation, allSketchFilePaths, logger) if err != nil { return i18n.WrapError(err) } ctx.SketchLocation = sketchLocation ctx.Sketch = sketch return nil }