Skip to content

Commit ae07a8a

Browse files
Migrate TestCompileUsingPlatformLocalTxt from test_compile_part_3.py to compile_part_3_test.go
1 parent b87478b commit ae07a8a

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

internal/integrationtest/compile/compile_part_3_test.go

+32
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,35 @@ func TestCompileWithOnlyCompilationDatabaseFlag(t *testing.T) {
183183
// Verifies no binaries are exported
184184
require.NoDirExists(t, buildPath.String())
185185
}
186+
187+
func TestCompileUsingPlatformLocalTxt(t *testing.T) {
188+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
189+
defer env.CleanUp()
190+
191+
_, _, err := cli.Run("update")
192+
require.NoError(t, err)
193+
194+
_, _, err = cli.Run("core", "install", "arduino:[email protected]")
195+
require.NoError(t, err)
196+
197+
sketchName := "CompileSketchUsingPlatformLocalTxt"
198+
sketchPath := cli.SketchbookDir().Join(sketchName)
199+
fqbn := "arduino:avr:uno"
200+
201+
_, _, err = cli.Run("sketch", "new", sketchPath.String())
202+
require.NoError(t, err)
203+
204+
// Verifies compilation works without issues
205+
_, _, err = cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String())
206+
require.NoError(t, err)
207+
208+
// Overrides default platform compiler with an unexisting one
209+
platformLocalTxt := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.3", "platform.local.txt")
210+
err = platformLocalTxt.WriteFile([]byte("compiler.c.cmd=my-compiler-that-does-not-exist"))
211+
require.NoError(t, err)
212+
213+
// Verifies compilation now fails because compiler is not found
214+
_, stderr, err := cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String())
215+
require.Error(t, err)
216+
require.Contains(t, string(stderr), "my-compiler-that-does-not-exist")
217+
}

test/test_compile_part_3.py

-24
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,6 @@
3939
# assert "Skipping dependencies detection for precompiled library Arduino_TensorFlowLite" in result.stdout
4040

4141

42-
def test_compile_using_platform_local_txt(run_command, data_dir):
43-
assert run_command(["update"])
44-
45-
assert run_command(["core", "install", "arduino:[email protected]"])
46-
47-
sketch_name = "CompileSketchUsingPlatformLocalTxt"
48-
sketch_path = Path(data_dir, sketch_name)
49-
fqbn = "arduino:avr:uno"
50-
51-
assert run_command(["sketch", "new", sketch_path])
52-
53-
# Verifies compilation works without issues
54-
assert run_command(["compile", "--clean", "-b", fqbn, sketch_path])
55-
56-
# Overrides default platform compiler with an unexisting one
57-
platform_local_txt = Path(data_dir, "packages", "arduino", "hardware", "avr", "1.8.3", "platform.local.txt")
58-
platform_local_txt.write_text("compiler.c.cmd=my-compiler-that-does-not-exist")
59-
60-
# Verifies compilation now fails because compiler is not found
61-
res = run_command(["compile", "--clean", "-b", fqbn, sketch_path])
62-
assert res.failed
63-
assert "my-compiler-that-does-not-exist" in res.stderr
64-
65-
6642
def test_compile_using_boards_local_txt(run_command, data_dir):
6743
assert run_command(["update"])
6844

0 commit comments

Comments
 (0)