2017-06-05 16:02:39 +03:00
|
|
|
# Copyright (c) 2014-present PlatformIO <contact@platformio.org>
|
2015-11-18 17:16:17 +02:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2015-02-20 13:48:17 +02:00
|
|
|
|
|
|
|
import json
|
|
|
|
|
2015-04-17 12:37:03 +01:00
|
|
|
from platformio.commands.boards import cli as cmd_boards
|
2016-08-02 19:10:29 +03:00
|
|
|
from platformio.commands.platform import platform_search as cmd_platform_search
|
2015-02-20 13:48:17 +02:00
|
|
|
|
|
|
|
|
2016-08-31 01:03:13 +03:00
|
|
|
def test_board_json_output(clirunner, validate_cliresult):
|
2016-05-28 22:51:33 +03:00
|
|
|
result = clirunner.invoke(cmd_boards, ["mbed", "--json-output"])
|
2015-02-21 15:15:00 +02:00
|
|
|
validate_cliresult(result)
|
2015-02-20 13:48:17 +02:00
|
|
|
boards = json.loads(result.output)
|
2016-05-28 22:51:33 +03:00
|
|
|
assert isinstance(boards, list)
|
|
|
|
assert any(["mbed" in b['frameworks'] for b in boards])
|
2015-02-20 13:48:17 +02:00
|
|
|
|
|
|
|
|
2016-08-31 01:03:13 +03:00
|
|
|
def test_board_raw_output(clirunner, validate_cliresult):
|
2019-07-22 00:57:01 +03:00
|
|
|
result = clirunner.invoke(cmd_boards, ["espidf"])
|
2015-02-21 15:15:00 +02:00
|
|
|
validate_cliresult(result)
|
2019-07-22 00:57:01 +03:00
|
|
|
assert "espressif32" in result.output
|
2015-02-20 16:41:42 +02:00
|
|
|
|
|
|
|
|
2016-08-31 01:03:13 +03:00
|
|
|
def test_board_options(clirunner, validate_cliresult):
|
2015-02-20 13:48:17 +02:00
|
|
|
required_opts = set(
|
2016-05-28 22:51:33 +03:00
|
|
|
["fcpu", "frameworks", "id", "mcu", "name", "platform"])
|
2015-02-20 13:48:17 +02:00
|
|
|
|
2015-02-21 15:15:00 +02:00
|
|
|
# fetch available platforms
|
2016-05-28 22:51:33 +03:00
|
|
|
result = clirunner.invoke(cmd_platform_search, ["--json-output"])
|
2015-02-21 15:15:00 +02:00
|
|
|
validate_cliresult(result)
|
2015-02-20 13:48:17 +02:00
|
|
|
search_result = json.loads(result.output)
|
|
|
|
assert isinstance(search_result, list)
|
|
|
|
assert len(search_result)
|
2016-05-28 22:51:33 +03:00
|
|
|
platforms = [item['name'] for item in search_result]
|
2015-02-20 13:48:17 +02:00
|
|
|
|
2016-05-28 22:51:33 +03:00
|
|
|
result = clirunner.invoke(cmd_boards, ["mbed", "--json-output"])
|
|
|
|
validate_cliresult(result)
|
|
|
|
boards = json.loads(result.output)
|
|
|
|
|
|
|
|
for board in boards:
|
|
|
|
assert required_opts.issubset(set(board))
|
|
|
|
assert board['platform'] in platforms
|