Skip to content

Commit 880684a

Browse files
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.
1 parent 7d1916d commit 880684a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: internal/integrationtest/arduino-cli.go

+12
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ func (cli *ArduinoCLI) SketchbookDir() *paths.Path {
126126
return cli.sketchbookDir
127127
}
128128

129+
// CopySketch copies a sketch inside the testing environment and returns its path
130+
func (cli *ArduinoCLI) CopySketch(sketchName string) *paths.Path {
131+
p, err := paths.Getwd()
132+
cli.t.NoError(err)
133+
cli.t.NotNil(p)
134+
testSketch := p.Parent().Join("testdata", sketchName)
135+
sketchPath := cli.SketchbookDir().Join(sketchName)
136+
err = testSketch.CopyDirTo(sketchPath)
137+
cli.t.NoError(err)
138+
return sketchPath
139+
}
140+
129141
// Run executes the given arduino-cli command and returns the output.
130142
func (cli *ArduinoCLI) Run(args ...string) ([]byte, []byte, error) {
131143
return cli.RunWithCustomEnv(cli.cliEnvVars, args...)

0 commit comments

Comments
 (0)