Skip to content

Commit b6a4731

Browse files
Migrate TestCoreInstallEsp32 from test_core.py to core_test.go
1 parent 18c4706 commit b6a4731

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

internal/integrationtest/core/core_test.go

+28
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package core_test
1717

1818
import (
19+
"crypto/md5"
20+
"encoding/hex"
1921
"fmt"
2022
"runtime"
2123
"sort"
@@ -222,6 +224,32 @@ func TestCoreInstallWithoutUpdateIndex(t *testing.T) {
222224
require.Contains(t, string(stdout), "Downloading index: package_index.tar.bz2 downloaded")
223225
}
224226

227+
func TestCoreInstallEsp32(t *testing.T) {
228+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
229+
defer env.CleanUp()
230+
231+
// update index
232+
url := "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
233+
_, _, err := cli.Run("core", "update-index", "--additional-urls="+url)
234+
require.NoError(t, err)
235+
// install 3rd-party core
236+
_, _, err = cli.Run("core", "install", "esp32:[email protected]", "--additional-urls="+url)
237+
require.NoError(t, err)
238+
// create a sketch and compile to double check the core was successfully installed
239+
sketchName := "test_core_install_esp32"
240+
sketchPath := cli.SketchbookDir().Join(sketchName)
241+
_, _, err = cli.Run("sketch", "new", sketchPath.String())
242+
require.NoError(t, err)
243+
_, _, err = cli.Run("compile", "-b", "esp32:esp32:esp32", sketchPath.String())
244+
require.NoError(t, err)
245+
// prevent regressions for https://github.com/arduino/arduino-cli/issues/163
246+
md5 := md5.Sum(([]byte(sketchPath.String())))
247+
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
248+
require.NotEmpty(t, sketchPathMd5)
249+
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
250+
require.FileExists(t, buildDir.Join(sketchName+".ino.partitions.bin").String())
251+
}
252+
225253
func TestCoreDownload(t *testing.T) {
226254
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
227255
defer env.CleanUp()

test/test_core.py

-21
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,6 @@
2626
import semver
2727

2828

29-
@pytest.mark.skipif(
30-
platform.system() == "Windows",
31-
reason="core fails with fatal error: bits/c++config.h: No such file or directory",
32-
)
33-
def test_core_install_esp32(run_command, data_dir):
34-
# update index
35-
url = "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
36-
assert run_command(["core", "update-index", f"--additional-urls={url}"])
37-
# install 3rd-party core
38-
assert run_command(["core", "install", "esp32:[email protected]", f"--additional-urls={url}"])
39-
# create a sketch and compile to double check the core was successfully installed
40-
sketch_name = "test_core_install_esp32"
41-
sketch_path = os.path.join(data_dir, sketch_name)
42-
assert run_command(["sketch", "new", sketch_path])
43-
assert run_command(["compile", "-b", "esp32:esp32:esp32", sketch_path])
44-
# prevent regressions for https://github.com/arduino/arduino-cli/issues/163
45-
sketch_path_md5 = hashlib.md5(sketch_path.encode()).hexdigest().upper()
46-
build_dir = Path(tempfile.gettempdir(), f"arduino-sketch-{sketch_path_md5}")
47-
assert (build_dir / f"{sketch_name}.ino.partitions.bin").exists()
48-
49-
5029
def test_core_install_creates_installed_json(run_command, data_dir):
5130
assert run_command(["core", "update-index"])
5231
assert run_command(["core", "install", "arduino:[email protected]"])

0 commit comments

Comments
 (0)