Skip to content

Commit 4478cdf

Browse files
Migrate TestCompileWithExportBinariesEnvVar from test_compile_part_2.py to compile_part_2_test.go
1 parent 6a8a9f1 commit 4478cdf

File tree

2 files changed

+37
-34
lines changed

2 files changed

+37
-34
lines changed

internal/integrationtest/compile/compile_part_2_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,43 @@ func TestCompileWithCustomBuildPath(t *testing.T) {
151151
require.NoFileExists(t, buildDir.Join(sketchName+".ino.with_bootloader.hex").String())
152152
}
153153

154+
func TestCompileWithExportBinariesEnvVar(t *testing.T) {
155+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
156+
defer env.CleanUp()
157+
158+
// Init the environment explicitly
159+
_, _, err := cli.Run("core", "update-index")
160+
require.NoError(t, err)
161+
162+
// Download latest AVR
163+
_, _, err = cli.Run("core", "install", "arduino:avr")
164+
require.NoError(t, err)
165+
166+
sketchName := "CompileWithExportBinariesEnvVar"
167+
sketchPath := cli.SketchbookDir().Join(sketchName)
168+
fqbn := "arduino:avr:uno"
169+
170+
// Create a test sketch
171+
_, _, err = cli.Run("sketch", "new", sketchPath.String())
172+
require.NoError(t, err)
173+
174+
envVar := cli.GetDefaultEnv()
175+
envVar["ARDUINO_SKETCH_ALWAYS_EXPORT_BINARIES"] = "true"
176+
177+
// Test compilation with export binaries env var set
178+
_, _, err = cli.RunWithCustomEnv(envVar, "compile", "-b", fqbn, sketchPath.String())
179+
require.NoError(t, err)
180+
require.DirExists(t, sketchPath.Join("build").String())
181+
182+
// Verifies binaries are exported when export binaries env var is set
183+
fqbn = strings.ReplaceAll(fqbn, ":", ".")
184+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.eep").String())
185+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.elf").String())
186+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.hex").String())
187+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.with_bootloader.bin").String())
188+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.with_bootloader.hex").String())
189+
}
190+
154191
func TestCompileWithInvalidUrl(t *testing.T) {
155192
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
156193
defer env.CleanUp()

test/test_compile_part_2.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,6 @@
1919
import simplejson as json
2020

2121

22-
def test_compile_with_export_binaries_env_var(run_command, data_dir, downloads_dir):
23-
# Init the environment explicitly
24-
run_command(["core", "update-index"])
25-
26-
# Download latest AVR
27-
run_command(["core", "install", "arduino:avr"])
28-
29-
sketch_name = "CompileWithExportBinariesEnvVar"
30-
sketch_path = Path(data_dir, sketch_name)
31-
fqbn = "arduino:avr:uno"
32-
33-
# Create a test sketch
34-
assert run_command(["sketch", "new", sketch_path])
35-
36-
env = {
37-
"ARDUINO_DATA_DIR": data_dir,
38-
"ARDUINO_DOWNLOADS_DIR": downloads_dir,
39-
"ARDUINO_SKETCHBOOK_DIR": data_dir,
40-
"ARDUINO_SKETCH_ALWAYS_EXPORT_BINARIES": "true",
41-
}
42-
# Test compilation with export binaries env var set
43-
result = run_command(["compile", "-b", fqbn, sketch_path], custom_env=env)
44-
assert result.ok
45-
assert Path(sketch_path, "build").exists()
46-
assert Path(sketch_path, "build").is_dir()
47-
48-
# Verifies binaries are exported when export binaries env var is set
49-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.eep").exists()
50-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.elf").exists()
51-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.hex").exists()
52-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.with_bootloader.bin").exists()
53-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.with_bootloader.hex").exists()
54-
55-
5622
def test_compile_with_export_binaries_config(run_command, data_dir, downloads_dir):
5723
# Init the environment explicitly
5824
run_command(["core", "update-index"])

0 commit comments

Comments
 (0)