mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-07 14:44:32 +02:00
ci: abort with all ImportErrors when detecting ImportError while search tests cases
This commit is contained in:
@@ -3500,7 +3500,6 @@ tools/ci/python_packages/tiny_test_fw/TinyFW.py
|
|||||||
tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py
|
tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py
|
||||||
tools/ci/python_packages/tiny_test_fw/Utility/CaseConfig.py
|
tools/ci/python_packages/tiny_test_fw/Utility/CaseConfig.py
|
||||||
tools/ci/python_packages/tiny_test_fw/Utility/GitlabCIJob.py
|
tools/ci/python_packages/tiny_test_fw/Utility/GitlabCIJob.py
|
||||||
tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py
|
|
||||||
tools/ci/python_packages/tiny_test_fw/Utility/TestCase.py
|
tools/ci/python_packages/tiny_test_fw/Utility/TestCase.py
|
||||||
tools/ci/python_packages/tiny_test_fw/Utility/__init__.py
|
tools/ci/python_packages/tiny_test_fw/Utility/__init__.py
|
||||||
tools/ci/python_packages/tiny_test_fw/bin/Runner.py
|
tools/ci/python_packages/tiny_test_fw/bin/Runner.py
|
||||||
|
@@ -1,30 +1,27 @@
|
|||||||
# Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
# SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
#
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# 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.
|
|
||||||
|
|
||||||
""" search test cases from a given file or path """
|
""" search test cases from a given file or path """
|
||||||
import copy
|
import copy
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import types
|
import types
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from . import load_source
|
from . import load_source
|
||||||
|
|
||||||
|
|
||||||
class Search(object):
|
class Search:
|
||||||
|
"""
|
||||||
|
This class is used as a class singleton. all the member functions are `classmethod`
|
||||||
|
"""
|
||||||
TEST_CASE_FILE_PATTERN = '*_test.py'
|
TEST_CASE_FILE_PATTERN = '*_test.py'
|
||||||
SUPPORT_REPLICATE_CASES_KEY = ['target']
|
SUPPORT_REPLICATE_CASES_KEY = ['target']
|
||||||
|
|
||||||
|
# this attribute would be modified while running
|
||||||
|
missing_import_warnings: List[str] = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _search_cases_from_file(cls, file_name):
|
def _search_cases_from_file(cls, file_name):
|
||||||
""" get test cases from test case .py file """
|
""" get test cases from test case .py file """
|
||||||
@@ -42,7 +39,8 @@ class Search(object):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print('ImportError: \r\n\tFile:' + file_name + '\r\n\tError:' + str(e))
|
warning_str = 'ImortError: \r\n\tFile:' + file_name + '\r\n\tError:' + str(e)
|
||||||
|
cls.missing_import_warnings.append(warning_str)
|
||||||
|
|
||||||
test_functions_out = []
|
test_functions_out = []
|
||||||
for case in test_functions:
|
for case in test_functions:
|
||||||
@@ -132,8 +130,14 @@ class Search(object):
|
|||||||
test_case_paths = [test_case_paths]
|
test_case_paths = [test_case_paths]
|
||||||
test_case_files = []
|
test_case_files = []
|
||||||
for path in test_case_paths:
|
for path in test_case_paths:
|
||||||
test_case_files.extend(cls._search_test_case_files(path, test_case_file_pattern or cls.TEST_CASE_FILE_PATTERN))
|
test_case_files.extend(
|
||||||
|
cls._search_test_case_files(path, test_case_file_pattern or cls.TEST_CASE_FILE_PATTERN))
|
||||||
test_cases = []
|
test_cases = []
|
||||||
for test_case_file in test_case_files:
|
for test_case_file in test_case_files:
|
||||||
test_cases += cls._search_cases_from_file(test_case_file)
|
test_cases += cls._search_cases_from_file(test_case_file)
|
||||||
|
|
||||||
|
if cls.missing_import_warnings:
|
||||||
|
print('\n\n'.join(cls.missing_import_warnings))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
return test_cases
|
return test_cases
|
||||||
|
Reference in New Issue
Block a user