Skip to content

Commit 4a4e4b3

Browse files
Migrate TestCompileManuallyInstalledPlatformUsingPlatformLocalTxt from test_compile_part_3.py to compile_part_3_test.go
1 parent 49b7c6f commit 4a4e4b3

File tree

2 files changed

+40
-29
lines changed

2 files changed

+40
-29
lines changed

Diff for: internal/integrationtest/compile/compile_part_3_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,43 @@ func TestCompileManuallyInstalledPlatform(t *testing.T) {
283283
_, _, err = cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String())
284284
require.NoError(t, err)
285285
}
286+
287+
func TestCompileManuallyInstalledPlatformUsingPlatformLocalTxt(t *testing.T) {
288+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
289+
defer env.CleanUp()
290+
291+
_, _, err := cli.Run("update")
292+
require.NoError(t, err)
293+
294+
sketchName := "CompileSketchManuallyInstalledPlatformUsingPlatformLocalTxt"
295+
sketchPath := cli.SketchbookDir().Join(sketchName)
296+
fqbn := "arduino-beta-development:avr:uno"
297+
_, _, err = cli.Run("sketch", "new", sketchPath.String())
298+
require.NoError(t, err)
299+
300+
// Manually installs a core in sketchbooks hardware folder
301+
gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
302+
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "avr")
303+
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{
304+
URL: gitUrl,
305+
ReferenceName: plumbing.NewTagReferenceName("1.8.3"),
306+
})
307+
require.NoError(t, err)
308+
309+
// Installs also the same core via CLI so all the necessary tools are installed
310+
_, _, err = cli.Run("core", "install", "arduino:[email protected]")
311+
require.NoError(t, err)
312+
313+
// Verifies compilation works without issues
314+
_, _, err = cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String())
315+
require.NoError(t, err)
316+
317+
// Overrides default platform compiler with an unexisting one
318+
platformLocalTxt := repoDir.Join("platform.local.txt")
319+
platformLocalTxt.WriteFile([]byte("compiler.c.cmd=my-compiler-that-does-not-exist"))
320+
321+
// Verifies compilation now fails because compiler is not found
322+
_, stderr, err := cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String())
323+
require.Error(t, err)
324+
require.Contains(t, string(stderr), "my-compiler-that-does-not-exist")
325+
}

Diff for: test/test_compile_part_3.py

-29
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,3 @@
3737
# result = run_command(["compile", "-b", fqbn, sketch_folder, "-v"])
3838
# assert result.ok
3939
# assert "Skipping dependencies detection for precompiled library Arduino_TensorFlowLite" in result.stdout
40-
41-
42-
def test_compile_manually_installed_platform_using_platform_local_txt(run_command, data_dir):
43-
assert run_command(["update"])
44-
45-
sketch_name = "CompileSketchManuallyInstalledPlatformUsingPlatformLocalTxt"
46-
sketch_path = Path(data_dir, sketch_name)
47-
fqbn = "arduino-beta-development:avr:uno"
48-
assert run_command(["sketch", "new", sketch_path])
49-
50-
# Manually installs a core in sketchbooks hardware folder
51-
git_url = "https://github.com/arduino/ArduinoCore-avr.git"
52-
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr")
53-
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"])
54-
55-
# Installs also the same core via CLI so all the necessary tools are installed
56-
assert run_command(["core", "install", "arduino:[email protected]"])
57-
58-
# Verifies compilation works without issues
59-
assert run_command(["compile", "--clean", "-b", fqbn, sketch_path])
60-
61-
# Overrides default platform compiler with an unexisting one
62-
platform_local_txt = Path(repo_dir, "platform.local.txt")
63-
platform_local_txt.write_text("compiler.c.cmd=my-compiler-that-does-not-exist")
64-
65-
# Verifies compilation now fails because compiler is not found
66-
res = run_command(["compile", "--clean", "-b", fqbn, sketch_path])
67-
assert res.failed
68-
assert "my-compiler-that-does-not-exist" in res.stderr

0 commit comments

Comments
 (0)