Skip to content

Commit dfa14ee

Browse files
Migrate TestCompileWithExportBinariesFlag from test_compile_part_2.py to compile_part_2_test.go
1 parent 79b6ce8 commit dfa14ee

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

internal/integrationtest/compile/compile_part_2_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,37 @@ func TestCompileWithOutputDirFlag(t *testing.T) {
7171
require.FileExists(t, outputDir.Join(sketchName+".ino.with_bootloader.bin").String())
7272
require.FileExists(t, outputDir.Join(sketchName+".ino.with_bootloader.hex").String())
7373
}
74+
75+
func TestCompileWithExportBinariesFlag(t *testing.T) {
76+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
77+
defer env.CleanUp()
78+
79+
// Init the environment explicitly
80+
_, _, err := cli.Run("core", "update-index")
81+
require.NoError(t, err)
82+
83+
// Download latest AVR
84+
_, _, err = cli.Run("core", "install", "arduino:avr")
85+
require.NoError(t, err)
86+
87+
sketchName := "CompileWithExportBinariesFlag"
88+
sketchPath := cli.SketchbookDir().Join(sketchName)
89+
fqbn := "arduino:avr:uno"
90+
91+
// Create a test sketch
92+
_, _, err = cli.Run("sketch", "new", sketchPath.String())
93+
require.NoError(t, err)
94+
95+
// Test the --output-dir flag with absolute path
96+
_, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--export-binaries")
97+
require.NoError(t, err)
98+
require.DirExists(t, sketchPath.Join("build").String())
99+
100+
// Verifies binaries are exported when --export-binaries flag is set
101+
fqbn = strings.ReplaceAll(fqbn, ":", ".")
102+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.eep").String())
103+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.elf").String())
104+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.hex").String())
105+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.with_bootloader.bin").String())
106+
require.FileExists(t, sketchPath.Join("build", fqbn, sketchName+".ino.with_bootloader.hex").String())
107+
}

test/test_compile_part_2.py

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

2121

22-
def test_compile_with_export_binaries_flag(run_command, data_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 = "CompileWithExportBinariesFlag"
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-
# Test the --output-dir flag with absolute path
37-
result = run_command(["compile", "-b", fqbn, sketch_path, "--export-binaries"])
38-
assert result.ok
39-
assert Path(sketch_path, "build").exists()
40-
assert Path(sketch_path, "build").is_dir()
41-
42-
# Verifies binaries are exported when --export-binaries flag is set
43-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.eep").exists()
44-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.elf").exists()
45-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.hex").exists()
46-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.with_bootloader.bin").exists()
47-
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.with_bootloader.hex").exists()
48-
49-
5022
def test_compile_with_custom_build_path(run_command, data_dir):
5123
# Init the environment explicitly
5224
run_command(["core", "update-index"])

0 commit comments

Comments
 (0)