Skip to content

Commit e4b716e

Browse files
Migrate TestCoreDownloadMultiplePlatforms from test_core.py to core_test.go
1 parent f23b8a8 commit e4b716e

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
@@ -833,6 +833,46 @@ func TestCoreListPlatformWithoutPlatformTxt(t *testing.T) {
833833
requirejson.Query(t, stdout, ".[] | .name", "\"some-packager-some-arch\"")
834834
}
835835

836+
func TestCoreDownloadMultiplePlatforms(t *testing.T) {
837+
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
838+
t.Skip("macOS by default is case insensitive https://github.com/actions/virtual-environments/issues/865 ",
839+
"Windows too is case insensitive",
840+
"https://stackoverflow.com/questions/7199039/file-paths-in-windows-environment-not-case-sensitive")
841+
}
842+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
843+
defer env.CleanUp()
844+
845+
_, _, err := cli.Run("update")
846+
require.NoError(t, err)
847+
848+
// Verifies no core is installed
849+
stdout, _, err := cli.Run("core", "list", "--format", "json")
850+
require.NoError(t, err)
851+
requirejson.Len(t, stdout, 0)
852+
853+
// Simulates creation of two new cores in the sketchbook hardware folder
854+
wd, _ := paths.Getwd()
855+
testBoardsTxt := wd.Parent().Join("testdata", "boards.local.txt")
856+
boardsTxt := cli.DataDir().Join("packages", "PACKAGER", "hardware", "ARCH", "1.0.0", "boards.txt")
857+
require.NoError(t, boardsTxt.Parent().MkdirAll())
858+
require.NoError(t, testBoardsTxt.CopyTo(boardsTxt))
859+
860+
boardsTxt1 := cli.DataDir().Join("packages", "packager", "hardware", "arch", "1.0.0", "boards.txt")
861+
require.NoError(t, boardsTxt1.Parent().MkdirAll())
862+
require.NoError(t, testBoardsTxt.CopyTo(boardsTxt1))
863+
864+
// Verifies the two cores are detected
865+
stdout, _, err = cli.Run("core", "list", "--format", "json")
866+
require.NoError(t, err)
867+
requirejson.Len(t, stdout, 2)
868+
869+
// Try to do an operation on the fake cores.
870+
// The cli should not allow it since optimizing the casing results in finding two cores
871+
_, stderr, err := cli.Run("core", "upgrade", "Packager:Arch")
872+
require.Error(t, err)
873+
require.Contains(t, string(stderr), "Invalid argument passed: Found 2 platform for reference")
874+
}
875+
836876
func TestCoreWithMissingCustomBoardOptionsIsLoaded(t *testing.T) {
837877
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
838878
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)