Skip to content

[skip changelog] Move integration tests to pytest #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
moved core tests to pytest
  • Loading branch information
Massimiliano Pippi authored and masci committed Jan 21, 2020
commit 0b506e0ee921a62b8dc8ff4a96ce841eaa7a5184
37 changes: 0 additions & 37 deletions cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/arduino/arduino-cli/cli/feedback"

"bou.ke/monkey"
paths "github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
semver "go.bug.st/relaxed-semver"
)
Expand Down Expand Up @@ -292,42 +291,6 @@ func TestUploadIntegration(t *testing.T) {
require.NotZero(t, exitCode)
}

func TestInvalidCoreURLIntegration(t *testing.T) {
configFile := filepath.Join("testdata", t.Name())

// Dump config with cmd-line specific file
exitCode, d := executeWithArgs("--config-file", configFile, "config", "dump")
require.Zero(t, exitCode)
require.Contains(t, string(d), "- http://www.invalid-domain-asjkdakdhadjkh.com/package_example_index.json")

// Update inexistent index
exitCode, _ = executeWithArgs("--config-file", configFile, "core", "update-index")
require.NotZero(t, exitCode)
}

func Test3rdPartyCoreIntegration(t *testing.T) {
configFile := filepath.Join("testdata", t.Name())

// Update index and install esp32:esp32
exitCode, _ := executeWithArgs("--config-file", configFile, "core", "update-index")
require.Zero(t, exitCode)
exitCode, d := executeWithArgs("--config-file", configFile, "core", "install", "esp32:esp32")
require.Zero(t, exitCode)
require.Contains(t, string(d), "installed")

// Build a simple sketch and check if all artifacts are copied
tmp := tmpDirOrDie()
defer os.RemoveAll(tmp)
tmpSketch := paths.New(tmp).Join("Blink")
err := paths.New("testdata/Blink").CopyDirTo(tmpSketch)
require.NoError(t, err, "copying test sketch into temp dir")
exitCode, d = executeWithArgs("--config-file", configFile, "compile", "-b", "esp32:esp32:esp32", tmpSketch.String())
require.Zero(t, exitCode)
require.True(t, tmpSketch.Join("Blink.esp32.esp32.esp32.bin").Exist())
require.True(t, tmpSketch.Join("Blink.esp32.esp32.esp32.elf").Exist())
require.True(t, tmpSketch.Join("Blink.esp32.esp32.esp32.partitions.bin").Exist()) // https://github.com/arduino/arduino-cli/issues/163
}

func TestCoreCommandsIntegration(t *testing.T) {
exitCode, _ := executeWithArgs("core", "update-index")
require.Zero(t, exitCode)
Expand Down
3 changes: 0 additions & 3 deletions cli/testdata/Blink/Blink.ino

This file was deleted.

3 changes: 0 additions & 3 deletions cli/testdata/Test3rdPartyCoreIntegration/arduino-cli.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions cli/testdata/TestInvalidCoreURLIntegration/arduino-cli.yaml

This file was deleted.

31 changes: 31 additions & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# otherwise use the software for commercial activities involving the Arduino
# software without disclosing the source code of your own applications. To purchase
# a commercial license, send an email to license@arduino.cc.
import os

import pytest
import simplejson as json

Expand Down Expand Up @@ -95,3 +97,32 @@ def test_core_search_no_args(run_command):
break
assert found
assert len(platforms) == num_platforms


def test_core_updateindex_invalid_url(run_command):
url = "http://www.invalid-domain-asjkdakdhadjkh.com/package_example_index.json"
result = run_command("core update-index --additional-urls={}".format(url))
assert result.failed


def test_core_install_esp32(run_command, data_dir):
# update index
url = "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
result = run_command("core update-index --additional-urls={}".format(url))
assert result.ok
# install 3rd-party core
result = run_command("core install esp32:esp32 --additional-urls={}".format(url))
assert result.ok

# create a sketch and compile to double check the core was successfully installed
sketch_path = os.path.join(data_dir, "test_core_install_esp32")
result = run_command("sketch new {}".format(sketch_path))
assert result.ok
result = run_command("compile -b esp32:esp32:esp32 {}".format(sketch_path))
assert result.ok
# prevent regressions for https://github.com/arduino/arduino-cli/issues/163
assert os.path.exists(
os.path.join(
sketch_path, "test_core_install_esp32.esp32.esp32.esp32.partitions.bin"
)
)