From 880684a2df48a6c8481a6b10a9abf5ec9e0d72ec Mon Sep 17 00:00:00 2001 From: Matteo Pologruto Date: Fri, 16 Sep 2022 15:18:49 +0200 Subject: [PATCH] Add CopySketch to the testsuite library CopySketch is a function that copies a sketch present in the "testdata" folder and copies it into the testing environment. --- internal/integrationtest/arduino-cli.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/integrationtest/arduino-cli.go b/internal/integrationtest/arduino-cli.go index 9b17de761f2..54a99da9b9e 100644 --- a/internal/integrationtest/arduino-cli.go +++ b/internal/integrationtest/arduino-cli.go @@ -126,6 +126,18 @@ func (cli *ArduinoCLI) SketchbookDir() *paths.Path { return cli.sketchbookDir } +// CopySketch copies a sketch inside the testing environment and returns its path +func (cli *ArduinoCLI) CopySketch(sketchName string) *paths.Path { + p, err := paths.Getwd() + cli.t.NoError(err) + cli.t.NotNil(p) + testSketch := p.Parent().Join("testdata", sketchName) + sketchPath := cli.SketchbookDir().Join(sketchName) + err = testSketch.CopyDirTo(sketchPath) + cli.t.NoError(err) + return sketchPath +} + // Run executes the given arduino-cli command and returns the output. func (cli *ArduinoCLI) Run(args ...string) ([]byte, []byte, error) { return cli.RunWithCustomEnv(cli.cliEnvVars, args...)