Skip to content

Commit 26d7aa6

Browse files
Migrate TestCompileWithBuildPropertiesFlag from test_compile_part_1.py to compile_part_1_test.go
1 parent 7560739 commit 26d7aa6

File tree

5 files changed

+52
-75
lines changed

5 files changed

+52
-75
lines changed

internal/integrationtest/compile/compile_part_1_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,55 @@ func TestCompileWithoutPrecompiledLibraries(t *testing.T) {
312312
_, _, err = cli.Run("compile", "-b", "arduino:samd:mkrvidor4000", sketchPath.String())
313313
require.NoError(t, err)
314314
}
315+
316+
func TestCompileWithBuildPropertiesFlag(t *testing.T) {
317+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
318+
defer env.CleanUp()
319+
320+
// Init the environment explicitly
321+
_, _, err := cli.Run("core", "update-index")
322+
require.NoError(t, err)
323+
324+
// Install Arduino AVR Boards
325+
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.3")
326+
require.NoError(t, err)
327+
328+
sketchName := "sketch_with_single_string_define"
329+
sketchPath := cli.CopySketch(sketchName)
330+
fqbn := "arduino:avr:uno"
331+
332+
// Compile using a build property with quotes
333+
_, stderr, err := cli.Run("compile", "-b", fqbn, "--build-properties=\"build.extra_flags=\"-DMY_DEFINE=\"hello world\"\"", sketchPath.String(), "--verbose", "--clean")
334+
require.Error(t, err)
335+
require.NotContains(t, string(stderr), "Flag --build-properties has been deprecated, please use --build-property instead.")
336+
337+
// Try again with quotes
338+
_, stderr, err = cli.Run("compile", "-b", fqbn, "--build-properties=\"build.extra_flags=-DMY_DEFINE=\"hello\"\"", sketchPath.String(), "--verbose", "--clean")
339+
require.Error(t, err)
340+
require.NotContains(t, string(stderr), "Flag --build-properties has been deprecated, please use --build-property instead.")
341+
342+
sketchName = "sketch_with_single_int_define"
343+
sketchPath = cli.CopySketch(sketchName)
344+
345+
// Try without quotes
346+
stdout, stderr, err := cli.Run("compile", "-b", fqbn, "--build-properties=\"build.extra_flags=-DMY_DEFINE=1\"", sketchPath.String(), "--verbose", "--clean")
347+
require.NoError(t, err)
348+
require.Contains(t, string(stderr), "Flag --build-properties has been deprecated, please use --build-property instead.")
349+
require.Contains(t, string(stdout), "-DMY_DEFINE=1")
350+
351+
sketchName = "sketch_with_multiple_int_defines"
352+
sketchPath = cli.CopySketch(sketchName)
353+
354+
stdout, stderr, err = cli.Run("compile",
355+
"-b",
356+
fqbn,
357+
"--build-properties",
358+
"build.extra_flags=-DFIRST_PIN=1,compiler.cpp.extra_flags=-DSECOND_PIN=2",
359+
sketchPath.String(),
360+
"--verbose",
361+
"--clean")
362+
require.NoError(t, err)
363+
require.Contains(t, string(stderr), "Flag --build-properties has been deprecated, please use --build-property instead.")
364+
require.Contains(t, string(stdout), "-DFIRST_PIN=1")
365+
require.Contains(t, string(stdout), "-DSECOND_PIN=2")
366+
}

test/test_compile_part_1.py

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -25,81 +25,6 @@
2525
from .common import running_on_ci
2626

2727

28-
def test_compile_with_build_properties_flag(run_command, data_dir, copy_sketch):
29-
# Init the environment explicitly
30-
assert run_command(["core", "update-index"])
31-
32-
# Install Arduino AVR Boards
33-
assert run_command(["core", "install", "arduino:avr@1.8.3"])
34-
35-
sketch_path = copy_sketch("sketch_with_single_string_define")
36-
fqbn = "arduino:avr:uno"
37-
38-
# Compile using a build property with quotes
39-
res = run_command(
40-
[
41-
"compile",
42-
"-b",
43-
fqbn,
44-
'--build-properties="build.extra_flags=\\"-DMY_DEFINE=\\"hello world\\"\\""',
45-
sketch_path,
46-
"--verbose",
47-
"--clean",
48-
]
49-
)
50-
assert res.failed
51-
assert "Flag --build-properties has been deprecated, please use --build-property instead." not in res.stderr
52-
53-
# Try again with quotes
54-
res = run_command(
55-
[
56-
"compile",
57-
"-b",
58-
fqbn,
59-
'--build-properties="build.extra_flags=-DMY_DEFINE=\\"hello\\""',
60-
sketch_path,
61-
"--verbose",
62-
"--clean",
63-
]
64-
)
65-
assert res.failed
66-
assert "Flag --build-properties has been deprecated, please use --build-property instead." not in res.stderr
67-
68-
# Try without quotes
69-
sketch_path = copy_sketch("sketch_with_single_int_define")
70-
res = run_command(
71-
[
72-
"compile",
73-
"-b",
74-
fqbn,
75-
'--build-properties="build.extra_flags=-DMY_DEFINE=1"',
76-
sketch_path,
77-
"--verbose",
78-
"--clean",
79-
]
80-
)
81-
assert res.ok
82-
assert "Flag --build-properties has been deprecated, please use --build-property instead." in res.stderr
83-
assert "-DMY_DEFINE=1" in res.stdout
84-
85-
sketch_path = copy_sketch("sketch_with_multiple_int_defines")
86-
res = run_command(
87-
[
88-
"compile",
89-
"-b",
90-
fqbn,
91-
'--build-properties="build.extra_flags=-DFIRST_PIN=1,compiler.cpp.extra_flags=-DSECOND_PIN=2"',
92-
sketch_path,
93-
"--verbose",
94-
"--clean",
95-
]
96-
)
97-
assert res.ok
98-
assert "Flag --build-properties has been deprecated, please use --build-property instead." in res.stderr
99-
assert "-DFIRST_PIN=1" in res.stdout
100-
assert "-DSECOND_PIN=2" in res.stdout
101-
102-
10328
def test_compile_with_build_property_containing_quotes(run_command, data_dir, copy_sketch):
10429
# Init the environment explicitly
10530
assert run_command(["core", "update-index"])

0 commit comments

Comments
 (0)