mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 04:25:32 +00:00
Tools: Export selected target actions
Added option --json to action help, for export selected target actions
This commit is contained in:
@@ -3,11 +3,14 @@
|
||||
# SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from unittest import TestCase, main, mock
|
||||
|
||||
import jsonschema
|
||||
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
@@ -227,5 +230,21 @@ class TestDeprecations(TestWithoutExtensions):
|
||||
self.assertNotIn('"test_0" is deprecated', output)
|
||||
|
||||
|
||||
class TestHelpOutput(TestWithoutExtensions):
|
||||
def test_output(self):
|
||||
def action_test(commands, schema):
|
||||
output_file = 'idf_py_help_output.json'
|
||||
with open(output_file, 'w') as outfile:
|
||||
subprocess.run(commands, env=os.environ, stdout=outfile)
|
||||
with open(output_file, 'r') as outfile:
|
||||
help_obj = json.load(outfile)
|
||||
self.assertIsNone(jsonschema.validate(help_obj, schema))
|
||||
|
||||
with open(os.path.join(current_dir, 'idf_py_help_schema.json'), 'r') as schema_file:
|
||||
schema_json = json.load(schema_file)
|
||||
action_test(['idf.py', 'help', '--json'], schema_json)
|
||||
action_test(['idf.py', 'help', '--json', '--add-options'], schema_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Reference in New Issue
Block a user