Skip to content

Commit ac39e1c

Browse files
Migrate TestCompileManuallyInstalledPlatformUsingBoardsLocalTxt from test_compile_part_4.py to compile_part_4_test.go
1 parent 15d7364 commit ac39e1c

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

internal/integrationtest/compile/compile_part_4_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,48 @@ import (
2828
"gopkg.in/src-d/go-git.v4/plumbing"
2929
)
3030

31+
func TestCompileManuallyInstalledPlatformUsingBoardsLocalTxt(t *testing.T) {
32+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
33+
defer env.CleanUp()
34+
35+
_, _, err := cli.Run("update")
36+
require.NoError(t, err)
37+
38+
sketchName := "CompileSketchManuallyInstalledPlatformUsingBoardsLocalTxt"
39+
sketchPath := cli.SketchbookDir().Join(sketchName)
40+
fqbn := "arduino-beta-development:avr:nessuno"
41+
_, _, err = cli.Run("sketch", "new", sketchPath.String())
42+
require.NoError(t, err)
43+
44+
// Manually installs a core in sketchbooks hardware folder
45+
gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
46+
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "avr")
47+
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{
48+
URL: gitUrl,
49+
ReferenceName: plumbing.NewTagReferenceName("1.8.3"),
50+
})
51+
require.NoError(t, err)
52+
53+
// Installs also the same core via CLI so all the necessary tools are installed
54+
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.3")
55+
require.NoError(t, err)
56+
57+
// Verifies compilation fails because board doesn't exist
58+
_, stderr, err := cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String())
59+
require.Error(t, err)
60+
require.Contains(t, string(stderr), "Error during build: Error resolving FQBN: board arduino-beta-development:avr:nessuno not found")
61+
62+
// Use custom boards.local.txt with made arduino:avr:nessuno board
63+
boardsLocalTxt := repoDir.Join("boards.local.txt")
64+
wd, err := paths.Getwd()
65+
require.NoError(t, err)
66+
err = wd.Parent().Join("testdata", "boards.local.txt").CopyTo(boardsLocalTxt)
67+
require.NoError(t, err)
68+
69+
_, _, err = cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String())
70+
require.NoError(t, err)
71+
}
72+
3173
func TestCompileWithLibrary(t *testing.T) {
3274
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
3375
defer env.CleanUp()

test/test_compile_part_4.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,6 @@
2020
from pathlib import Path
2121

2222

23-
def test_compile_manually_installed_platform_using_boards_local_txt(run_command, data_dir):
24-
assert run_command(["update"])
25-
26-
sketch_name = "CompileSketchManuallyInstalledPlatformUsingBoardsLocalTxt"
27-
sketch_path = Path(data_dir, sketch_name)
28-
fqbn = "arduino-beta-development:avr:nessuno"
29-
assert run_command(["sketch", "new", sketch_path])
30-
31-
# Manually installs a core in sketchbooks hardware folder
32-
git_url = "https://github.com/arduino/ArduinoCore-avr.git"
33-
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr")
34-
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"])
35-
36-
# Installs also the same core via CLI so all the necessary tools are installed
37-
assert run_command(["core", "install", "arduino:avr@1.8.3"])
38-
39-
# Verifies compilation fails because board doesn't exist
40-
res = run_command(["compile", "--clean", "-b", fqbn, sketch_path])
41-
assert res.failed
42-
assert (
43-
"Error during build: Error resolving FQBN: board arduino-beta-development:avr:nessuno not found" in res.stderr
44-
)
45-
46-
# Use custom boards.local.txt with made arduino:avr:nessuno board
47-
boards_local_txt = Path(repo_dir, "boards.local.txt")
48-
shutil.copyfile(Path(__file__).parent / "testdata" / "boards.local.txt", boards_local_txt)
49-
50-
assert run_command(["compile", "--clean", "-b", fqbn, sketch_path])
51-
52-
5323
def test_compile_with_relative_build_path(run_command, data_dir, copy_sketch):
5424
assert run_command(["update"])
5525

0 commit comments

Comments
 (0)