Skip to content

Commit e175511

Browse files
Migrate TestCompileWithExportBinariesEnvVar from test_compile_part_2.py to compile_part_2_test.go
1 parent 06d9f8b commit e175511

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
@@ -153,6 +153,43 @@ func TestCompileWithCustomBuildPath(t *testing.T) {
153153
require.NoFileExists(t, buildDir.Join(sketchName+".ino.with_bootloader.hex").String())
154154
}
155155

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