Skip to content

Commit f39f146

Browse files
Migrate TestCompileWithExportBinariesConfig from test_compile_part_2.py
to compile_part_2_test.go
1 parent e175511 commit f39f146

File tree

2 files changed

+40
-37
lines changed

2 files changed

+40
-37
lines changed

internal/integrationtest/compile/compile_part_2_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,46 @@ func TestCompileWithExportBinariesEnvVar(t *testing.T) {
190190
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.with_bootloader.hex").String())
191191
}
192192

193+
func TestCompileWithExportBinariesConfig(t *testing.T) {
194+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
195+
defer env.CleanUp()
196+
197+
// Init the environment explicitly
198+
_, _, err := cli.Run("core", "update-index")
199+
require.NoError(t, err)
200+
201+
// Download latest AVR
202+
_, _, err = cli.Run("core", "install", "arduino:avr")
203+
require.NoError(t, err)
204+
205+
sketchName := "CompileWithExportBinariesEnvVar"
206+
sketchPath := cli.SketchbookDir().Join(sketchName)
207+
fqbn := "arduino:avr:uno"
208+
209+
// Create a test sketch
210+
_, _, err = cli.Run("sketch", "new", sketchPath.String())
211+
require.NoError(t, err)
212+
213+
// Create settings with export binaries set to true
214+
envVar := cli.GetDefaultEnv()
215+
envVar["ARDUINO_SKETCH_ALWAYS_EXPORT_BINARIES"] = "true"
216+
_, _, err = cli.RunWithCustomEnv(envVar, "config", "init", "--dest-dir", ".")
217+
require.NoError(t, err)
218+
219+
// Test compilation with export binaries env var set
220+
_, _, err = cli.RunWithCustomEnv(envVar, "compile", "-b", fqbn, sketchPath.String())
221+
require.NoError(t, err)
222+
require.DirExists(t, sketchPath.Join("build").String())
223+
224+
// Verifies binaries are exported when export binaries env var is set
225+
fqbn = strings.ReplaceAll(fqbn, ":", ".")
226+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.eep").String())
227+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.elf").String())
228+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.hex").String())
229+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.with_bootloader.bin").String())
230+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.with_bootloader.hex").String())
231+
}
232+
193233
func TestCompileWithInvalidUrl(t *testing.T) {
194234
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
195235
defer env.CleanUp()

test/test_compile_part_2.py

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

2121

22-
def test_compile_with_export_binaries_config(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 = "CompileWithExportBinariesConfig"
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-
# Create settings with export binaries set to true
37-
env = {
38-
"ARDUINO_DATA_DIR": data_dir,
39-
"ARDUINO_DOWNLOADS_DIR": downloads_dir,
40-
"ARDUINO_SKETCHBOOK_DIR": data_dir,
41-
"ARDUINO_SKETCH_ALWAYS_EXPORT_BINARIES": "true",
42-
}
43-
assert run_command(["config", "init", "--dest-dir", "."], custom_env=env)
44-
45-
# Test compilation with export binaries env var set
46-
result = run_command(["compile", "-b", fqbn, sketch_path])
47-
assert result.ok
48-
assert Path(sketch_path, "build").exists()
49-
assert Path(sketch_path, "build").is_dir()
50-
51-
# Verifies binaries are exported when export binaries env var is set
52-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.eep").exists()
53-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.elf").exists()
54-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.hex").exists()
55-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.with_bootloader.bin").exists()
56-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.with_bootloader.hex").exists()
57-
58-
5922
def test_compile_with_custom_libraries(run_command, copy_sketch):
6023
# Creates config with additional URL to install necessary core
6124
url = "http://arduino.esp8266.com/stable/package_esp8266com_index.json"

0 commit comments

Comments
 (0)