-
-
Notifications
You must be signed in to change notification settings - Fork 405
Create a compile+upload combo command #326
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e3fd70c
Add an optional upload step in compile (CLI-35)
zmoog dc70f3d
Merge branch 'master' into create-a-compile+upload-combo-command
5e40c3a
Merge branch 'master' into create-a-compile+upload-combo-command
7abe0d5
Add few integration tests for compile command
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# This file is part of arduino-cli. | ||
|
||
# Copyright 2019 ARDUINO SA (http://www.arduino.cc/) | ||
|
||
# This software is released under the GNU General Public License version 3, | ||
# which covers the main part of arduino-cli. | ||
# The terms of this license can be found at: | ||
# https://www.gnu.org/licenses/gpl-3.0.en.html | ||
|
||
# You can be released from the requirements of the above licenses by purchasing | ||
# a commercial license. Buying such a license is mandatory if you want to modify or | ||
# 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 [email protected]. | ||
import pytest | ||
import json | ||
import os | ||
|
||
from .common import running_on_ci | ||
|
||
|
||
def test_compile_without_fqbn(run_command): | ||
# Init the environment explicitly | ||
result = run_command("core update-index") | ||
assert result.ok | ||
|
||
# Download latest AVR | ||
result = run_command("core install arduino:avr") | ||
assert result.ok | ||
|
||
# Build sketch without FQBN | ||
result = run_command("compile") | ||
assert result.failed | ||
|
||
|
||
def test_compile_with_simple_sketch(run_command, data_dir): | ||
# Init the environment explicitly | ||
result = run_command("core update-index") | ||
assert result.ok | ||
|
||
# # Download latest AVR | ||
result = run_command("core install arduino:avr") | ||
assert result.ok | ||
|
||
sketch_path = os.path.join(data_dir, "CompileIntegrationTest") | ||
|
||
# Create a test sketch | ||
result = run_command("sketch new CompileIntegrationTest") | ||
assert result.ok | ||
assert "Sketch created in: {}".format(sketch_path) in result.stdout | ||
|
||
# Build sketch for arduino:avr:uno | ||
result = run_command("compile -b arduino:avr:uno {}".format(sketch_path)) | ||
assert result.ok | ||
assert "Sketch uses" in result.stdout | ||
|
||
|
||
@pytest.mark.skipif(running_on_ci(), reason="VMs have no serial ports") | ||
def test_compile_and_compile_combo(run_command, data_dir): | ||
|
||
# Init the environment explicitly | ||
result = run_command("core update-index") | ||
assert result.ok | ||
|
||
# Install required core(s) | ||
result = run_command("core install arduino:avr") | ||
# result = run_command("core install arduino:samd") | ||
assert result.ok | ||
|
||
# Create a test sketch | ||
sketch_path = os.path.join(data_dir, "CompileAndUploadIntegrationTest") | ||
result = run_command("sketch new CompileAndUploadIntegrationTest") | ||
assert result.ok | ||
assert "Sketch created in: {}".format(sketch_path) in result.stdout | ||
|
||
# | ||
# Build a list of detected boards to test, if any. | ||
# | ||
result = run_command("board list --format json") | ||
assert result.ok | ||
|
||
# | ||
# The `board list --format json` returns a JSON that looks like to the following: | ||
# | ||
# [ | ||
# { | ||
# "address": "/dev/cu.usbmodem14201", | ||
# "protocol": "serial", | ||
# "protocol_label": "Serial Port (USB)", | ||
# "boards": [ | ||
# { | ||
# "name": "Arduino NANO 33 IoT", | ||
# "FQBN": "arduino:samd:nano_33_iot" | ||
# } | ||
# ] | ||
# } | ||
# ] | ||
|
||
detected_boards = [] | ||
|
||
ports = json.loads(result.stdout) | ||
assert isinstance(ports, list) | ||
for port in ports: | ||
boards = port.get('boards') | ||
assert isinstance(boards, list) | ||
for board in boards: | ||
detected_boards.append(dict(address=port.get('address'), fqbn=board.get('FQBN'))) | ||
|
||
assert len(detected_boards) >= 1, "There are no boards available for testing" | ||
|
||
# Build sketch for each detected board | ||
for board in detected_boards: | ||
zmoog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
result = run_command( | ||
"compile -b {fqbn} --upload -p {address} {sketch_path}".format( | ||
fqbn=board.get('fqbn'), | ||
address=board.get('address'), | ||
sketch_path=sketch_path) | ||
) | ||
assert result.ok | ||
assert "Verify successful" in result.stdout |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.