Skip to content

Commit 0eb7441

Browse files
Migrate TestCoreDownloadMultiplePlatforms from test_core.py to core_test.go
1 parent 85719ae commit 0eb7441

File tree

2 files changed

+41
-50
lines changed

2 files changed

+41
-50
lines changed

internal/integrationtest/core/core_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,46 @@ func TestCoreListPlatformWithoutPlatformTxt(t *testing.T) {
848848
requirejson.Query(t, stdout, ".[] | .name", "\"some-packager-some-arch\"")
849849
}
850850

851+
func TestCoreDownloadMultiplePlatforms(t *testing.T) {
852+
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
853+
t.Skip("macOS by default is case insensitive https://github.com/actions/virtual-environments/issues/865 ",
854+
"Windows too is case insensitive",
855+
"https://stackoverflow.com/questions/7199039/file-paths-in-windows-environment-not-case-sensitive")
856+
}
857+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
858+
defer env.CleanUp()
859+
860+
_, _, err := cli.Run("update")
861+
require.NoError(t, err)
862+
863+
// Verifies no core is installed
864+
stdout, _, err := cli.Run("core", "list", "--format", "json")
865+
require.NoError(t, err)
866+
requirejson.Len(t, stdout, 0)
867+
868+
// Simulates creation of two new cores in the sketchbook hardware folder
869+
wd, _ := paths.Getwd()
870+
testBoardsTxt := wd.Parent().Join("testdata", "boards.local.txt")
871+
boardsTxt := cli.DataDir().Join("packages", "PACKAGER", "hardware", "ARCH", "1.0.0", "boards.txt")
872+
require.NoError(t, boardsTxt.Parent().MkdirAll())
873+
require.NoError(t, testBoardsTxt.CopyTo(boardsTxt))
874+
875+
boardsTxt1 := cli.DataDir().Join("packages", "packager", "hardware", "arch", "1.0.0", "boards.txt")
876+
require.NoError(t, boardsTxt1.Parent().MkdirAll())
877+
require.NoError(t, testBoardsTxt.CopyTo(boardsTxt1))
878+
879+
// Verifies the two cores are detected
880+
stdout, _, err = cli.Run("core", "list", "--format", "json")
881+
require.NoError(t, err)
882+
requirejson.Len(t, stdout, 2)
883+
884+
// Try to do an operation on the fake cores.
885+
// The cli should not allow it since optimizing the casing results in finding two cores
886+
_, stderr, err := cli.Run("core", "upgrade", "Packager:Arch")
887+
require.Error(t, err)
888+
require.Contains(t, string(stderr), "Invalid argument passed: Found 2 platform for reference")
889+
}
890+
851891
func TestCoreWithMissingCustomBoardOptionsIsLoaded(t *testing.T) {
852892
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
853893
defer env.CleanUp()

test/test_core.py

+1-50
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,9 @@
1212
# otherwise use the software for commercial activities involving the Arduino
1313
# software without disclosing the source code of your own applications. To purchase
1414
# a commercial license, send an email to [email protected].
15-
import os
16-
import datetime
17-
import shutil
18-
import time
19-
import platform
20-
import pytest
15+
2116
import simplejson as json
22-
import tempfile
23-
import hashlib
24-
from git import Repo
2517
from pathlib import Path
26-
import semver
2718

2819

2920
def test_core_install_creates_installed_json(run_command, data_dir):
@@ -45,43 +36,3 @@ def ordered(obj):
4536
return obj
4637

4738
assert ordered(installed_json) == ordered(expected_installed_json)
48-
49-
50-
@pytest.mark.skipif(
51-
platform.system() in ["Darwin", "Windows"],
52-
reason="macOS by default is case insensitive https://github.com/actions/virtual-environments/issues/865 "
53-
+ "Windows too is case insensitive"
54-
+ "https://stackoverflow.com/questions/7199039/file-paths-in-windows-environment-not-case-sensitive",
55-
)
56-
def test_core_download_multiple_platforms(run_command, data_dir):
57-
assert run_command(["update"])
58-
59-
# Verifies no core is installed
60-
res = run_command(["core", "list", "--format", "json"])
61-
assert res.ok
62-
cores = json.loads(res.stdout)
63-
assert len(cores) == 0
64-
65-
# Simulates creation of two new cores in the sketchbook hardware folder
66-
test_boards_txt = Path(__file__).parent / "testdata" / "boards.local.txt"
67-
boards_txt = Path(data_dir, "packages", "PACKAGER", "hardware", "ARCH", "1.0.0", "boards.txt")
68-
boards_txt.parent.mkdir(parents=True, exist_ok=True)
69-
boards_txt.touch()
70-
assert boards_txt.write_bytes(test_boards_txt.read_bytes())
71-
72-
boards_txt1 = Path(data_dir, "packages", "packager", "hardware", "arch", "1.0.0", "boards.txt")
73-
boards_txt1.parent.mkdir(parents=True, exist_ok=True)
74-
boards_txt1.touch()
75-
assert boards_txt1.write_bytes(test_boards_txt.read_bytes())
76-
77-
# Verifies the two cores are detected
78-
res = run_command(["core", "list", "--format", "json"])
79-
assert res.ok
80-
cores = json.loads(res.stdout)
81-
assert len(cores) == 2
82-
83-
# Try to do an operation on the fake cores.
84-
# The cli should not allow it since optimizing the casing results in finding two cores
85-
res = run_command(["core", "upgrade", "Packager:Arch"])
86-
assert res.failed
87-
assert "Invalid argument passed: Found 2 platform for reference" in res.stderr

0 commit comments

Comments
 (0)