Skip to content

Commit 59c435c

Browse files
Migrated TestCompileWithBuildPropertiesFlag from test_compile_part_1.py to compile_part_1_test.go
1 parent 01f429e commit 59c435c

File tree

5 files changed

+100
-75
lines changed

5 files changed

+100
-75
lines changed

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

+68
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,71 @@ 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:[email protected]")
326+
require.NoError(t, err)
327+
328+
// Copy sketch
329+
sketchName := "sketch_with_single_string_define"
330+
p, err := paths.Getwd()
331+
require.NoError(t, err)
332+
require.NotNil(t, p)
333+
testSketch := p.Parent().Join("testdata", sketchName)
334+
sketchPath := cli.SketchbookDir().Join(sketchName)
335+
err = testSketch.CopyDirTo(sketchPath)
336+
require.NoError(t, err)
337+
338+
fqbn := "arduino:avr:uno"
339+
340+
// Compile using a build property with quotes
341+
_, stderr, err := cli.Run("compile", "-b", fqbn, "--build-properties=\"build.extra_flags=\"-DMY_DEFINE=\"hello world\"\"", sketchPath.String(), "--verbose", "--clean")
342+
require.Error(t, err)
343+
require.NotContains(t, string(stderr), "Flag --build-properties has been deprecated, please use --build-property instead.")
344+
345+
// Try again with quotes
346+
_, stderr, err = cli.Run("compile", "-b", fqbn, "--build-properties=\"build.extra_flags=-DMY_DEFINE=\"hello\"\"", sketchPath.String(), "--verbose", "--clean")
347+
require.Error(t, err)
348+
require.NotContains(t, string(stderr), "Flag --build-properties has been deprecated, please use --build-property instead.")
349+
350+
// Copy sketch
351+
sketchName = "sketch_with_single_int_define"
352+
testSketch = p.Parent().Join("testdata", sketchName)
353+
sketchPath = cli.SketchbookDir().Join(sketchName)
354+
err = testSketch.CopyDirTo(sketchPath)
355+
require.NoError(t, err)
356+
357+
// Try without quotes
358+
stdout, stderr, err := cli.Run("compile", "-b", fqbn, "--build-properties=\"build.extra_flags=-DMY_DEFINE=1\"", sketchPath.String(), "--verbose", "--clean")
359+
require.NoError(t, err)
360+
require.Contains(t, string(stderr), "Flag --build-properties has been deprecated, please use --build-property instead.")
361+
require.Contains(t, string(stdout), "-DMY_DEFINE=1")
362+
363+
// Copy sketch
364+
sketchName = "sketch_with_multiple_int_defines"
365+
testSketch = p.Parent().Join("testdata", sketchName)
366+
sketchPath = cli.SketchbookDir().Join(sketchName)
367+
err = testSketch.CopyDirTo(sketchPath)
368+
require.NoError(t, err)
369+
370+
stdout, stderr, err = cli.Run("compile",
371+
"-b",
372+
fqbn,
373+
"--build-properties",
374+
"build.extra_flags=-DFIRST_PIN=1,compiler.cpp.extra_flags=-DSECOND_PIN=2",
375+
sketchPath.String(),
376+
"--verbose",
377+
"--clean")
378+
require.NoError(t, err)
379+
require.Contains(t, string(stderr), "Flag --build-properties has been deprecated, please use --build-property instead.")
380+
require.Contains(t, string(stdout), "-DFIRST_PIN=1")
381+
require.Contains(t, string(stdout), "-DSECOND_PIN=2")
382+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
const int MY_FIRST_PIN = FIRST_PIN;
3+
const int MY_SECOND_PIN = SECOND_PIN;
4+
5+
void setup() {
6+
Serial.begin(9600);
7+
Serial.println(MY_FIRST_PIN);
8+
Serial.println(MY_SECOND_PIN);
9+
}
10+
11+
void loop() {
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
const int FOO = MY_DEFINE;
3+
4+
void setup() {
5+
Serial.begin(9600);
6+
Serial.println(FOO);
7+
}
8+
9+
void loop() {
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
const String FOO = MY_DEFINE;
3+
4+
void setup() {
5+
Serial.begin(9600);
6+
Serial.println(FOO);
7+
}
8+
9+
void loop() {
10+
}

Diff for: test/test_compile_part_1.py

-75
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:[email protected]"])
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)