-
-
Notifications
You must be signed in to change notification settings - Fork 405
Added integration test #282
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
9 commits
Select commit
Hold shift + click to select a range
19494d9
Added integration test
mastrolinux a9fb4cd
Added command lib search testing
mastrolinux fccce60
Added update-index test and semver testinf for versioning
mastrolinux 380e85a
Merge branch 'master' of github.com:arduino/arduino-cli into integrat…
mastrolinux 95d575c
Improved error reporting, update test of version command
mastrolinux 2dd934c
Avoid UnexpectedExit error so the output is more understandable, adde…
mastrolinux 005ee71
Update requirements, removed unused comments
mastrolinux 6e7338a
moved from custom markers to pytest.ini config for slow files
mastrolinux 1e4264e
Testing with real lib names
mastrolinux 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
/debug | ||
/arduino-cli | ||
/main | ||
/.vscode/settings.json | ||
/.vscode/ | ||
/cmd/formatter/debug.test | ||
/arduino-cli.yaml | ||
/wiki | ||
.idea | ||
coverage_*.txt | ||
coverage_*.txt | ||
__pycache__ | ||
venv | ||
.pytest_cache |
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,15 @@ | ||
## Integration tests | ||
|
||
This dir contains integration tests, the aim is to test the Command Line Interface and its output | ||
from a pure user point of view. | ||
|
||
### Installation | ||
|
||
cd test | ||
virtualenv --python=python3 venv | ||
source venv/bin/activate | ||
pip install -r requirements.txt | ||
|
||
### Running tests | ||
|
||
pytest |
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,10 @@ | ||
[pytest] | ||
filterwarnings = | ||
error | ||
ignore::DeprecationWarning | ||
ignore::ResourceWarning | ||
|
||
markers = | ||
slow: marks tests as slow (deselect with '-m "not slow"') | ||
|
||
addopts = -s --verbose --tb=short |
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,22 @@ | ||
astroid==2.2.5 | ||
atomicwrites==1.3.0 | ||
attrs==19.1.0 | ||
importlib-metadata==0.18 | ||
invoke==1.2.0 | ||
isort==4.3.21 | ||
lazy-object-proxy==1.4.1 | ||
mccabe==0.6.1 | ||
more-itertools==7.1.0 | ||
packaging==19.0 | ||
pep8==1.7.1 | ||
pluggy==0.12.0 | ||
py==1.8.0 | ||
pylint==2.3.1 | ||
pyparsing==2.4.0 | ||
pytest==5.0.1 | ||
semver==2.8.1 | ||
six==1.12.0 | ||
typed-ast==1.4.0 | ||
wcwidth==0.1.7 | ||
wrapt==1.11.2 | ||
zipp==0.5.2 |
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,106 @@ | ||
from invoke import run, Responder, exceptions | ||
import os | ||
import json | ||
import pytest | ||
import semver | ||
from datetime import datetime | ||
|
||
this_test_path = os.path.dirname(os.path.realpath(__file__)) | ||
# Calculate absolute path of the CLI | ||
cli_path = os.path.join(this_test_path, '..', 'arduino-cli') | ||
|
||
# Useful reference: | ||
# http://docs.pyinvoke.org/en/1.2/api/runners.html#invoke.runners.Result | ||
|
||
|
||
def cli_line(*args): | ||
# Accept a list of arguments cli_line('lib list --format json') | ||
# Return a full command line string e.g. 'arduino-cli help --format json' | ||
cli_full_line = ' '.join([cli_path, ' '.join(str(arg) for arg in args)]) | ||
return cli_full_line | ||
|
||
|
||
def run_command(*args): | ||
result = run(cli_line(*args), echo=False, hide=True, warn=True) | ||
return result | ||
|
||
|
||
def test_command_help(): | ||
result = run_command('help') | ||
assert result.ok | ||
assert result.stderr == '' | ||
assert 'Usage' in result.stdout | ||
|
||
|
||
def test_command_lib_list(): | ||
result = run_command('lib list') | ||
assert result.ok | ||
assert result.stderr == '' | ||
result = run_command('lib list', '--format json') | ||
assert '{}' == result.stdout | ||
|
||
|
||
def test_command_lib_install(): | ||
libs = ['\"AzureIoTProtocol_MQTT\"', '\"CMMC MQTT Connector\"', '\"WiFiNINA\"'] | ||
# Should be safe to run install multiple times | ||
result_1 = run_command('lib install {}'.format(' '.join(libs))) | ||
assert result_1.ok | ||
result_2 = run_command('lib install {}'.format(' '.join(libs))) | ||
assert result_2.ok | ||
|
||
def test_command_lib_update_index(): | ||
result = run_command('lib update-index') | ||
assert result.ok | ||
assert 'Updating index: library_index.json downloaded' == result.stdout.splitlines()[-1].strip() | ||
|
||
def test_command_lib_remove(): | ||
libs = ['\"AzureIoTProtocol_MQTT\"', '\"CMMC MQTT Connector\"', '\"WiFiNINA\"'] | ||
result = run_command('lib uninstall {}'.format(' '.join(libs))) | ||
assert result.ok | ||
|
||
@pytest.mark.slow | ||
def test_command_lib_search(): | ||
result = run_command('lib search') | ||
assert result.ok | ||
out_lines = result.stdout.splitlines() | ||
libs = [] | ||
# Create an array with just the name of the vars | ||
for line in out_lines: | ||
if 'Name: ' in line: | ||
libs.append(line.split()[1].strip('\"')) | ||
number_of_libs = len(libs) | ||
assert sorted(libs) == libs | ||
assert ['WiFi101', 'WiFi101OTA'] == [lib for lib in libs if 'WiFi101' in lib] | ||
result = run_command('lib search --format json') | ||
assert result.ok | ||
libs_found_from_json = json.loads(result.stdout) | ||
number_of_libs_from_json = len(libs_found_from_json.get('libraries')) | ||
assert number_of_libs == number_of_libs_from_json | ||
|
||
|
||
def test_command_board_list(): | ||
result = run_command('board list --format json') | ||
assert result.ok | ||
# check is a valid json and contains a list of ports | ||
ports = json.loads(result.stdout).get('ports') | ||
assert isinstance(ports, list) | ||
for port in ports: | ||
assert 'protocol' in port | ||
assert 'protocol_label' in port | ||
|
||
|
||
def test_command_board_listall(): | ||
result = run_command('board listall') | ||
assert result.ok | ||
assert ['Board', 'Name', 'FQBN'] == result.stdout.splitlines()[0].strip().split() | ||
|
||
|
||
def test_command_version(): | ||
result = run_command('version --format json') | ||
assert result.ok | ||
parsed_out = json.loads(result.stdout) | ||
|
||
assert parsed_out.get('Application', False) == 'arduino-cli' | ||
assert isinstance(semver.parse(parsed_out.get('VersionString', False)), dict) | ||
assert isinstance(parsed_out.get('Commit', False), str) | ||
assert datetime.strptime(parsed_out.get('BuildDate')[:-2], '%Y-%m-%dT%H:%M:%S.%f') |
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.